Arquillian Configuration For Embedded GlassFish 3.1.2 and Maven 3

Maven 3 dependencies for Arquillian integration tests with GlassFish 3.1.2 require the declaration of a few dependencies:


<project>
    <modelVersion></modelVersion>
    <groupId></groupId>
    <artifactId></artifactId>
    <version></version>
    <packaging>war</packaging>
    <name>alienfish</name>
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.jboss.arquillian</groupId>
                <artifactId>arquillian-bom</artifactId>
                <version>1.0.0.Final</version>
                <scope>import</scope>
                <type>pom</type>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <dependencies>
        <dependency>
            <groupId>org.glassfish.main.extras</groupId>
            <artifactId>glassfish-embedded-all</artifactId>
            <version>3.1.2</version>
            <scope>provided</scope>
        </dependency>        
        <dependency>
            <groupId>org.jboss.arquillian.container</groupId>
            <artifactId>arquillian-glassfish-embedded-3.1</artifactId>
            <version>1.0.0.CR3</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.jboss.arquillian.junit</groupId>
            <artifactId>arquillian-junit-container</artifactId>
            <scope>test</scope>
        </dependency> 
                   
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.10</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
</project>

The missing Maven 3 parts can be easily created from CLI.
Enjoy integration testing with the Alien and the Fish :-).

[x-ray's configuration and logging subsystems were tested with Arquillian. You will also find the integration tests in the git repo (project x-ray-services, class eg. ConfigurationIT), See also page 115 "Injection and Infrastructure Testing with Aliens" in Real World Java EE Night Hacks--Dissecting the Business Tier.]

Comments:

Hi,

configuration does not work for me, i am getting an exception[1] when adding "@RunWith(Arquillian.class)" to a JUnit-Test. Any suggestions? I am using glassfish 3.1.2.2

[1]
java.lang.RuntimeException: Could not create a new instance of class org.jboss.arquillian.test.impl.EventTestRunnerAdaptor see cause.
at org.jboss.arquillian.test.spi.SecurityActions.newInstance(SecurityActions.java:170)
at org.jboss.arquillian.test.spi.TestRunnerAdaptorBuilder.build(TestRunnerAdaptorBuilder.java:52)
at org.jboss.arquillian.junit.Arquillian.run(Arquillian.java:93)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.jboss.arquillian.test.spi.SecurityActions.newInstance(SecurityActions.java:166)
... 8 more
Caused by: java.lang.AbstractMethodError: org.apache.xerces.dom.DocumentImpl.setXmlStandalone(Z)V
at org.jboss.shrinkwrap.descriptor.spi.node.dom.XmlDomDescriptorExporterImpl.to(XmlDomDescriptorExporterImpl.java:62)
at org.jboss.shrinkwrap.descriptor.spi.node.NodeDescriptorExporterImpl.to(NodeDescriptorExporterImpl.java:55)
at org.jboss.shrinkwrap.descriptor.spi.node.NodeDescriptorExporterImpl.to(NodeDescriptorExporterImpl.java:30)
at org.jboss.shrinkwrap.descriptor.spi.node.dom.XmlDomDescriptorExporter.to(XmlDomDescriptorExporter.java:51)
at org.jboss.shrinkwrap.descriptor.spi.node.dom.XmlDomDescriptorExporter.to(XmlDomDescriptorExporter.java:34)
at org.jboss.shrinkwrap.descriptor.spi.node.NodeDescriptorImplBase.exportTo(NodeDescriptorImplBase.java:55)
at org.jboss.shrinkwrap.descriptor.spi.DescriptorImplBase.exportAsString(DescriptorImplBase.java:84)
at org.jboss.arquillian.config.impl.extension.ConfigurationSysPropResolver.resolveSystemProperties(ConfigurationSysPropResolver.java:54)
at org.jboss.arquillian.config.impl.extension.ConfigurationRegistrar.loadConfiguration(ConfigurationRegistrar.java:62)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:90)
at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99)
at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81)
at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:135)
at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:115)
at org.jboss.arquillian.core.impl.ManagerImpl.start(ManagerImpl.java:261)
at org.jboss.arquillian.test.impl.EventTestRunnerAdaptor.<init>(EventTestRunnerAdaptor.java:56)
... 13 more

Posted by Markus Schulte on September 27, 2012 at 07:04 PM CEST #

@Markus,

strange. I use embedded GF with arquillian all the time (= a few hours ago). My common mistake: a standalone GF is already running.

Checkout one of my examples from http://kenai.com/projects/javaee-patterns/, e.g. http://kenai.com/projects/javaee-patterns/sources/hg/show/ConfiguringJavaEE?rev=446

does it work?

thanks for testing!
--adam

Posted by Adam Bien on September 28, 2012 at 12:19 AM CEST #

@Markus,

this error occurs, if you do not include the <dependencyManagement> part in the pom.

Dieter

Posted by Dieter Tremel on January 25, 2013 at 01:46 PM CET #

Hi Adam,

Arquillian is definitely a great framework to assist testing, particularly Java EE.

I was just wondering how to test secured EJB, or perhaps the case where one tries to get caller principal in the body of an EJB method?

I have googled around, whilst there are some attempts, most of the end up in failure.

Kind regards,

DWuysan

Posted by DWuysan on July 18, 2013 at 05:11 PM CEST #

java.lang.NoSuchMethodError: org.apache.jasper.xmlparser.ParserUtils.setSchemaResourcePrefix(Ljava/lang/String;)V

Having this issue. Help is greatly required

Posted by AZEEZ IDRIS on March 25, 2017 at 03:53 PM CET #

Post a Comment:
  • HTML Syntax: NOT allowed
...the last 150 posts
...the last 10 comments
License