Hi
Sorry for hijacking this thread but i am also interested in writing
integration tests for my application. What i conclude from reading
articles/posts on this group that there are 2 approaches to testing:
- using glassfish-embedded-all as dependency and
EJBContainer.createEJBContainer(props)/org.glassfish.embeddable API in
Junit/TestNg Tests
- using embedded glassfish (through maven-embedded-glassfish-plugin )
with fail-safe plugin to run tests
The first option allows you to start EJB containter directly from test
classes and test EJBs locally. Both test classes and EjbContainer are
run in the same JVM, so you can test local EJB with this approach.
These kind of tests are used for testing EJBs (EJB-based Webservices ?
) so these test could be categorized as integration tests.
In the second option full glassfish is started by Maven in a separate
JVM and then application is deployed. To communicate with the
application you use "standard remote mechanisms": HTTP, Corba, SOAP.
In the end it seems that you would communicate with full-blown
glassfish instead of embedded one which starts/runs faster. These
tests would be mostly end-to-end tests since to communicate with
application-under-test you would communicate with it via one of its
remote interface - just to mimic consumer of your application.
Can anyone confirm on my understanding of testing in glassfish topic ?
regards,
Jakub
2011/8/3 Bhavanishankar <bhavanishankara.sapaliga_at_oracle.com>:
> Hi Laird,
>
> IMO surefire/failsafe plugin runs in its own VM/classloader. So, for local
> EJB testing either you have to bootstrap/start GlassFish from the surefire
> test itself (w/o embedded plugin -- either using
> EJBContainer.createContainer or org.glassfish.embeddable APIs)[1] OR test
> the local EJB from within the deployed servlet (the surefire test will
> invoke only the servlet).[2]
>
> [1] 3.1.1/tests/embedded/ejb/basic
> [2] 3.1.1/tests/embedded/maven-plugin/localejbs
>
> HTH,
> Bhavani.
>
> On 08/03/2011 11:29 PM, Laird Nelson wrote:
>
> On Wed, Aug 3, 2011 at 1:56 PM, Bhavanishankar wrote:
>>
>> Do you want to try and run 3.1.1/tests/embedded/maven-plugin/remoteejbs
>> and see if it runs fine in your environment w/ 3.1.1 plugin/glassfish.
>
> OK. Will do.
>
> {looks warily around} I'm not (in this case) testing a @Remote EJB. Does
> the global JNDI name that Glassfish reports is valid not work for @Local
> EJBs (even in the embedded case)?
>
> Thanks,
> Laird
>
> --
> Sun, an Oracle Company