users@glassfish.java.net

Re: testing glassfish JEE application

From: Marina Vatkina <marina.vatkina_at_oracle.com>
Date: Thu, 01 Sep 2011 14:43:31 -0700

Hi Jakub,

jmilkiewicz_at_gmail.com wrote:
> Hi
>
> After reading a few articles/blog entries on Java EE testing it seems
> there are multiple options in this domain. Can anyone provide me a
> high level overview of Java EE/Glassfish testing approaches? From
> glassfish perspective i see 2 approaches:
>
> - using glassfish-embedded-all as dependency and
> EJBContainer.createEJBContainer(props)/org.glassfish.embeddable API in
> Junit/TestNg Tests
>
> - using embedded glassfish (for example 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.
>

Webservices are not supported for the EJBContainer.createEJBContainer
testing. There are other limitations as well (only EJB Lite features are
required to be supported in the embeddable EJB container). For the
EJBContainer.createEJBContainer testing you can also use a pre-installed
GlassFish with a lib/embedded/glassfish-embedded-static-shell.jar as
your classpath dependency.

On the other hand, you can use GlassFish embedded API (with either jar
as the dependency) to be in complete control of what you are running.

-marina
> In the second option a full glassfish is started manuall/by Maven in a separate
> JVM and then application is deployed. To let your tests communicate with the
> application a "standard remote mechanisms" : HTTP, Corba, SOAP are used.
> 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 applications in glassfish ?
>
> regards,
>
> Jakub
>