Re: Bundle loading during unit testing outside Eclipse
Re: Bundle loading during unit testing outside Eclipse
- Subject: Re: Bundle loading during unit testing outside Eclipse
- From: Chuck Hill <email@hidden>
- Date: Mon, 19 Sep 2011 15:03:51 -0700
Hi Paul,
On 2011-09-19, at 2:48 PM, Paul Hoadley wrote:
> Hi Chuck,
>
> On 20/09/2011, at 2:49 AM, Chuck Hill wrote:
>
>>> That is, it can't find JavaMemoryAdaptor.framework when it needs it. I'm having this problem when running unit tests in both application and framework bundles of my own. JavaMemoryAdaptor.framework is on the .classpath (confirmed by running 'ant -v'),
>>
>> The jar file in Resources/Java is on the classpath? That is what gets used to locate the bundle.
>
> Yes. This is in Ant's classpath as it's running the test case:
>
> /Users/paulh/tmp/WT/workspace/Root/Library/Frameworks/JavaMemoryAdaptor.framework/Resources/Java/JavaMemoryAdaptor.jar
And that file is really there and you have permissions? :-)
>>> and it's present in Root/Library/Frameworks of the Hudson workspace. Root/wolips.properties points wo.local.frameworks to that directory. I use WOPath to construct the testing classpath (for User, Local, System anyway). And yet when I add something like this to a test method:
>>>
>>> NSArray bundles = NSBundle.frameworkBundles();
>>> System.out.println(bundles.count());
>>> System.out.println(bundles);
>>>
>>> Inside Eclipse I get 29 bundles, including JavaMemoryAdaptor.framework, and outside Eclipse I get 9 bundles, just the core WO System bundles. Surely this is the source of the problem?
>>
>> Yes. Do you have project bundles enabled in Eclipse?
>
> Yes, I have "Generate bundles" checked in Eclipse. Just in case there's some confusion here, though, I am _not_ using Ant to run the tests within Eclipse. When I say it works in Eclipse, I mean I selected the test class, then Run As > JUnit Test.
That then runs in an eclipse constructed classpath.
>>> I've been bothering Henrique about this for a while, but I'm just not convinced it's WOUnit's problem. I think it's my Hudson build environment. I know I'm not giving a lot to go on here, but can anyone suggest where I even _start_ looking to clarify this further?
>>
>> I doubt this is a WOUnit problem. For Hudson, are you wanting to use the source project as the bundle (project bundles enabled) or the built .woa or .framework directory as the bundle? If you can tell me how you have things setup, I should be able to help you figure out what needs to be done.
>
> I'm using the .woa directory as the bundle.
The .woa directory inside the source project (dist/Foo.woa)? Or built someplace else?
> I call junit like this:
>
> <junit haltonfailure="false"
> fork="true"
> dir="${dest.dir}/${project.name}.woa"
> printsummary="true"
> failureproperty="test.failed">
> <classpath refid="testing.classpath" />
> <classpath>
> <pathelement location="bin" />
What is that for? Those are the compiled classes in the app?
> <pathelement location="${junit.jar}" />
> <pathelement location="${wounit.jar}" />
> <pathelement location="${bin.tests}" />
> <!-- WTModel models -->
> <pathelement location="Root/Library/Frameworks/WTModel.framework" />
> </classpath>
> <formatter type="brief" usefile="false" />
> <formatter type="xml" />
> <batchtest todir="${junit.results}">
> <fileset dir="${bin.tests}">
> <include name="**/*Test.class" />
> </fileset>
> </batchtest>
> </junit>
>
> There's a bit of additional stuff in the 'junit' target (test results and so on), but I doubt it's relevant. 'testing.classpath' is defined like this:
>
> <typedef name="wopath" classname="org.objectstyle.woproject.ant.WOPath" />
> <wopath id="testing.classpath">
> <frameworks root="User" eclipse="true" />
> <frameworks root="Local" eclipse="true" />
> <frameworks root="System" eclipse="true" />
> </wopath>
It sounds like that this your problem. I think this is only going to work if you are running this in the project source dir where the .classpath file is. Is that the case?
Try adding
<pathconvert property="junit.testing.classpath" refid="testing.classpath"/>
<echo> testing.classpath is ${testing.classpath} />
And see if the result is what you expect.
> 'junit.jar' and 'wounit.jar' are supplied on the command line, and the JARs exist and are being found. 'bin.tests' has been defined.
>
> I am using the popular setupWorkspace.sh script to setup the workspace. I've made a few modifications to that script, but the workspace structure itself remains unchanged. That is, it creates a Root directory, which contains Library, Network, System, User directories, all containing the frameworks you would expect. JavaMemoryAdaptor.framework (and the rest of Wonder) is in /Users/paulh/tmp/WT/workspace/Root/Library/Frameworks at test runtime. wolips.properties (passed in on the command line) is also in Root and looks like this:
>
> wo.system.root=/Users/paulh/tmp/WT/workspace/Root/System
> wo.user.frameworks=/Users/paulh/tmp/WT/workspace/Root/User/Library/Frameworks
> wo.system.frameworks=/Users/paulh/tmp/WT/workspace/Root/System/Library/Frameworks
> wo.bootstrapjar=/System/Library/WebObjects/JavaApplications/wotaskd.woa/WOBootstrap.jar
> wo.network.frameworks=/Users/paulh/tmp/WT/workspace/Root/Network/Library/Frameworks
> wo.api.root=/Developer/ADC Reference Library/documentation/WebObjects/Reference/API/
> wo.network.root=/Users/paulh/tmp/WT/workspace/Root/Network
> wo.extensions=/Users/paulh/tmp/WT/workspace/Root/Library/WebObjects/Extensions
> wo.user.root=/Users/paulh/tmp/WT/workspace/Root/User
> wo.local.frameworks=/Users/paulh/tmp/WT/workspace/Root/Library/Frameworks
> wo.apps.root=/Users/paulh/tmp/WT/workspace/Root/Library/WebObjects/Applications
> wo.local.root=/Users/paulh/tmp/WT/workspace/Root
>
> Finally, this is the command line I'm running by hand which should be exactly what Hudson is running:
>
> ant -propertyfile Root/wolips.properties -lib Root/lib -lib /Users/paulh/Projects/Hudson/Deps -Djunit.jar=/Users/paulh/Projects/Hudson/Deps/junit-4.8.2.jar -Dwounit.jar=/Users/paulh/Projects/Hudson/Deps/wounit-1.2-SNAPSHOT-2.jar junit
>
> Thanks Chuckâlet me know if you can think of anything that might be causing a problem here.
Chuck
--
Chuck Hill Senior Consultant / VP Development
Practical WebObjects - for developers who want to increase their overall knowledge of WebObjects or who are trying to solve specific problems.
http://www.global-village.net/products/practical_webobjects
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden