I'm currently trying to setup automated integration testing of my webapp
which uses ejbs and have been looking at some of the arquillian examples 
https://svn.apache.org/repos/asf/openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-moviefun-example/src/test/java/org/superbiz/moviefun
here .

It looks like there's a couple of ways to startup an embedded tomee server
and i was wondering if any way was preferrable to another.

In MoviesHtmlUnitTest.java, the tomee server is started without arquillian
using this code...

@BeforeClass public static void start() throws IOException {
        webApp = createWebApp();
        Properties p = new Properties();
        p.setProperty(EJBContainer.APP_NAME, "moviefun");
        p.setProperty(EJBContainer.PROVIDER, "tomee-embedded"); // need web
feature
        p.setProperty(EJBContainer.MODULES, webApp.getAbsolutePath());
        p.setProperty(EmbeddedTomEEContainer.TOMEE_EJBCONTAINER_HTTP_PORT,
"9999");
        container = EJBContainer.createEJBContainer(p);
    }

In MoviesSeleniumTest.java, the tomee server is started like this...

@Deployment(testable = false)
    public static WebArchive createDeployment() {
        WebArchive archive = ShrinkWrap.create(WebArchive.class,
"moviefun.war")
                        .addClasses(ActionServlet.class, SetupServlet.class, 
Movie.class,
MovieController.class, Movies.class, MoviesImpl.class, MoviesRemote.class,
JsfUtil.class, PaginationHelper.class, ExampleDataProducer.class,
Examples.class, Setup.class)
                        .addAsResource(new 
ClassLoaderAsset("META-INF/ejb-jar.xml") ,
"META-INF/ejb-jar.xml")
                        .addAsResource(new 
ClassLoaderAsset("META-INF/persistence.xml") ,
"META-INF/persistence.xml")
                        .addAsLibraries(new
File("target/test-libs/commons-beanutils.jar"),
                                        new 
File("target/test-libs/commons-codec.jar"),
                                        new 
File("target/test-libs/commons-collections.jar"),
                                        new 
File("target/test-libs/commons-digester.jar"),
                                        new 
File("target/test-libs/commons-logging.jar"),
                                        new File("target/test-libs/jstl.jar"),
                                        new File("target/test-libs/log4j.jar"),
                                        new 
File("target/test-libs/standard.jar"));
        
        addResources("src/main/webapp", "", archive);
        System.out.println(archive.toString(true));
                return archive;
    }

The first way looks simpler to me, but I'm wondering if I'm missing some
benefit provided by the arquillian way.

Also is there an easy way to just use the .war file created in the target
folder and have that deployed in tomee-embedded.  Programmatically creating
the archive seems like hard work to me if the war file has already been
created, but again being new to all this, i could have easily missed the
point.  I also don't get why you have to manually copy the dependent jars
when you have already specified the jars you need in your maven depedencies. 
This is probably more arquillian related questions than openejb questions
but appreciate any directions or tips i can get since i know openejb dev
guys are working on this sort of integration testing capability.

--
View this message in context: 
http://openejb.979440.n4.nabble.com/tomee-embedded-test-case-best-practice-tp4117711p4117711.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Reply via email to