You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by Chris Owens <ct...@chris-owens.com> on 2013/07/30 02:04:58 UTC

ApplicationComposer, one set-up for multiple tests

In an applicationComposer environment, how can I set up the EJB "plumbing"
once for several JUnit tests?

I would normally use a static @BeforeClass method to set things up and a
static @AfterClass method to tear things down, but I don't understand how
these would interact with the @Module annotation in ApplicationComposer.  I
have searched but cannot find any comprehensive documentation on
ApplicationComposer or @Module. 


Following the general pattern  here
<http://tomee.apache.org/examples-trunk/application-composer/>  , I have set
up some tests using application composer, as follows:



What this code does, though is set up a persistence context once for each
test, and then tear it down afterward.  The result is horribly slow testing.




--
View this message in context: http://openejb.979440.n4.nabble.com/ApplicationComposer-one-set-up-for-multiple-tests-tp4664421.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: ApplicationComposer, one set-up for multiple tests

Posted by Chris Owens <ct...@chris-owens.com>.
I will get back to you with some more detailed timing results.  I am pretty
sure that you are right and that openJPA is eating the time.




--
View this message in context: http://openejb.979440.n4.nabble.com/ApplicationComposer-one-set-up-for-multiple-tests-tp4664421p4664434.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: ApplicationComposer, one set-up for multiple tests

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Hmm, looks fine, is it complicated for you to remove openjpa to check if
the time "lost" is jpa related?
Le 30 juil. 2013 19:22, "Chris Owens" <ct...@chris-owens.com> a
écrit :

> Good suggestion re: building things in static @BeforeClass methods and then
> just returning the values from @Module.
>
> I'm still getting run times in excess of 3 minutes for very simple tests.
> One thing I'm noticing is that OpenJPA is trying to do runtime enhancement
> even though I believe I have correctly configured build-time enhancement.
> I'm looking into that.  But, in case you notice something else wrong with
> my
> approach, here's a sample.
>
> 1) A generic integration test class, which is never run directly:
>
>
>
> 2. A concrete instantiation of the generic test:
>
>
>
> And, finally, a run transcript
>
>
>
>
>
>
> --
> View this message in context:
> http://openejb.979440.n4.nabble.com/ApplicationComposer-one-set-up-for-multiple-tests-tp4664421p4664432.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.
>

Re: ApplicationComposer, one set-up for multiple tests

Posted by Chris Owens <ct...@chris-owens.com>.
Good suggestion re: building things in static @BeforeClass methods and then
just returning the values from @Module. 

I'm still getting run times in excess of 3 minutes for very simple tests. 
One thing I'm noticing is that OpenJPA is trying to do runtime enhancement
even though I believe I have correctly configured build-time enhancement. 
I'm looking into that.  But, in case you notice something else wrong with my
approach, here's a sample.

1) A generic integration test class, which is never run directly:



2. A concrete instantiation of the generic test:



And, finally, a run transcript






--
View this message in context: http://openejb.979440.n4.nabble.com/ApplicationComposer-one-set-up-for-multiple-tests-tp4664421p4664432.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: ApplicationComposer, one set-up for multiple tests

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Well, the ApplicationComposer lifecycle is linked to the class lifecycle =
we deploy/undeploy the app by test. This allows us to get finer integration
with frameworks like mockito (compared to arquillian for instance) and to
do real unit testing without side effects between tests.

IMO if you want a single deployment go with arquillian openejb embedded.

@Module, @Configuration... needs to be instance methods and not static but
what can be commonly done is to prepare the returned values in @BeforeClass
and just return the already computed model in @Module.

Would be great to see what is slow for you, i used it a lot and was pretty
fast. Maybe you use this tool for something it is not designed for, do you
have more details about it? maybe the startup logs?

*Romain Manni-Bucau*
*Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
*Blog: **http://rmannibucau.wordpress.com/*<http://rmannibucau.wordpress.com/>
*LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
*Github: https://github.com/rmannibucau*



2013/7/30 Chris Owens <ct...@chris-owens.com>

> In an applicationComposer environment, how can I set up the EJB "plumbing"
> once for several JUnit tests?
>
> I would normally use a static @BeforeClass method to set things up and a
> static @AfterClass method to tear things down, but I don't understand how
> these would interact with the @Module annotation in ApplicationComposer.  I
> have searched but cannot find any comprehensive documentation on
> ApplicationComposer or @Module.
>
>
> Following the general pattern  here
> <http://tomee.apache.org/examples-trunk/application-composer/>  , I have
> set
> up some tests using application composer, as follows:
>
>
>
> What this code does, though is set up a persistence context once for each
> test, and then tear it down afterward.  The result is horribly slow
> testing.
>
>
>
>
> --
> View this message in context:
> http://openejb.979440.n4.nabble.com/ApplicationComposer-one-set-up-for-multiple-tests-tp4664421.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.
>