Re: Maven Unit tests with EOF
Re: Maven Unit tests with EOF
- Subject: Re: Maven Unit tests with EOF
- From: Aaron Rosenzweig via Webobjects-dev <email@hidden>
- Date: Wed, 22 Jan 2020 23:31:43 -0500
Markus, moin moin! Yes it’s been a long time :-) Thanks for the tip - I located
the thread you mentioned where Hugi recommended "JarResourceRequestHandler()” -
I think he might be onto something with respect to Jars but that particular
thing is for serving static resources not for NSBundle. I’d be interested to
know how you patched things, that might shed some additional light. I hear you,
you’d rather not patch but sometimes you gotta do what you gotta do.
Hey Paul - Yeah the MockEC is neat and doesn’t even need to go to the DB so
it’s easier in many ways but I have a mandate to be destructive with the DB so
I cannot use the MockEC for this unit test.
Henrique - you are so close I think! I tried your suggestion, it didn’t work
but your hot.
There are three types of concrete (not abstract) NSBundles:
1) NSLegacyBundle
2) NSFluffyBunnyProjectBundle
3) NSMavenProjectBundle
When I run this from Eclipse I can hit breakpoints and I confirmed that it is
making an NSFluffyBunnyProjectBundle.
I don’t know how to debug a maven run or if it is even possible… But it is
actually giving me a "java.lang.NoClassDefFoundError: Could not initialize
class com.webobjects.foundation.NSBundle” that later morphs into a null pointer
in ERXApplication$Loader.collectMainProps()
NSBundle itself is abstract… and I’m trying to run a test on a framework -
maybe that’s just a bad idea and I should move the test to a WOApplication
project that uses the framework… Not sure.
The “NSMavenProjectBundle” seems to be for running from within Eclipse too but
I don’t know much about it.
AARON ROSENZWEIG / Chat 'n Bike <http://www.chatnbike.com/>
e: email@hidden <mailto:email@hidden> t: (301) 956-2319
> On Jan 22, 2020, at 8:28 PM, Henrique Prange <email@hidden> wrote:
>
> Hey Aaron,
>
> This error rings a bell. I don't recall all the details. It looks like the
> collectMainProps method is trying to find the Properties file of your project
> in the wrong place.
>
> When you build your project in Eclipse with WOLips, it generates a build
> folder containing your project's WOA bundle. Maven, however, puts the
> generated WOA bundle in the target folder. I'm afraid the application
> initialization code keeps looking for the build folder when you run your
> tests with Maven.
>
> I'm not sure if there's a better way to solve this problem. Anyway, the code
> below may fix it.
>
> // That's the main bundle when running tests from Eclipse
> Path mainBundlePath = Paths.get("build/your-project.woa");
>
> if (Files.notExists(mainBundlePath)) {
> // Maven doesn't create a build directory. The WOA bundle goes into the
> target folder instead.
> mainBundlePath = Paths.get("target/your-project.woa");
> }
>
> ERXExtensions.initApp("your-project", mainBundlePath.toUri().toURL(),
> ACUnitTestingApplication.class, args);
>
> Cheers,
>
> HP
>
>> On Jan 22, 2020, at 2:09 PM, Aaron Rosenzweig via Webobjects-dev
>> <email@hidden <mailto:email@hidden>>
>> wrote:
>>
>> Hi,
>>
>> I’m trying to run maven unit tests with the surefire plugin that make use of
>> EOF but it’s not working out.
>>
>> I can run them in Eclipse with a direct launch as a bundless build and it
>> works. I make a call in the static initializer of the test case to:
>> ERXExtensions.initApp(ACUnitTestingApplication.class, arguments);
>>
>> And it thinks it’s a WO app and has access to the model group and all of EOF
>> and I can do destructive stuff like creating and saving Eos to the DB all
>> inside a launch from Eclipse.
>>
>> Where I’m running into trouble is trying to do it with Maven. At the moment
>> I’m getting a null pointer from maven launch at the following place.
>>
>> er.extensions.appserver.ERXApplication$Loader.collectMainProps(ERXApplication.java:757)
>>
>> I think because it is wanting to treat it as a bundle but it isn’t and so…
>> I’m not sure where to go from here. Any advice?
>>
>> AARON ROSENZWEIG / Chat 'n Bike <http://www.chatnbike.com/>
>> e: email@hidden <mailto:email@hidden> t: (301) 956-2319
>>
>>
>>
>> _______________________________________________
>> Do not post admin requests to the list. They will be ignored.
>> Webobjects-dev mailing list (email@hidden
>> <mailto:email@hidden>)
>> Help/Unsubscribe/Update your Subscription:
>>
>> This email sent to email@hidden
>
_______________________________________________
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