arquillian / arquillian-container-glassfish Goto Github PK
View Code? Open in Web Editor NEWArquillian GlassFish Containers
Arquillian GlassFish Containers
I'm unable to run simplest possible test scenario due to NPE from DeploymentGenerator
Test run
java.lang.NullPointerException
at org.jboss.arquillian.container.test.impl.client.deployment.DeploymentGenerator.validate(DeploymentGenerator.java:94)
package com.crmsuite.autosoftconnect;
import com.crmsuite.autosoftconnect.client.gen.ConnectService;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.arquillian.test.api.ArquillianResource;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.Before;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.MethodSorters;
import javax.xml.namespace.QName;
import java.net.URL;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.junit.Assert.assertThat;
@RunWith(Arquillian.class)
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class MainTest {
private static ConnectService connectService;
@Deployment(testable = false)
public static JavaArchive createDeployment() {
return ShrinkWrap.create(JavaArchive.class);
}
@ArquillianResource
private URL url;
@Before
public void setUp() throws Exception {
connectService = new ConnectService(
new URL(url, "EBookStoreImplService?wsdl"),
new QName("http://endpoint.jaxws.javaee7.org/", "EBookStoreImplService"));
}
@Test
public void testNothing() {
assertThat("1", equalTo("1"));
}
}
<details>
<summary>pom.xml</summary>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.core</groupId>
<artifactId>arquillian-core-impl-base</artifactId>
<version>${arquillian.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.test</groupId>
<artifactId>arquillian-test-impl-base</artifactId>
<version>${arquillian.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.junit</groupId>
<artifactId>arquillian-junit-core</artifactId>
<version>${arquillian.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.container</groupId>
<artifactId>arquillian-container-test-api</artifactId>
<version>${arquillian.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.container</groupId>
<artifactId>arquillian-glassfish-embedded-3.1</artifactId>
<version>1.0.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.shrinkwrap</groupId>
<artifactId>shrinkwrap-api</artifactId>
<version>${shrinkwrap.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.shrinkwrap</groupId>
<artifactId>shrinkwrap-impl-base</artifactId>
<version>${shrinkwrap.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.shrinkwrap.resolver</groupId>
<artifactId>shrinkwrap-resolver-impl-maven-archive</artifactId>
<version>2.2.5</version>
<scope>test</scope>
</dependency>
</dependencies>
</details>
mvn clean test
Apache Maven 3.3.9
Maven home: /usr/share/maven
Java version: 1.8.0_152-ea, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-8-oracle/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "4.4.0-124-generic", arch: "amd64", family: "unix"
<details>
<summary>$ mvn dependency:tree</summary>
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building crmsuite 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ crmsuite ---
[INFO] autosoftconnect:crmsuite:jar:1.0-SNAPSHOT
[INFO] +- junit:junit:jar:4.12:test
[INFO] | \- org.hamcrest:hamcrest-core:jar:1.3:test
[INFO] +- org.jboss.arquillian.core:arquillian-core-impl-base:jar:1.4.0.Final:test
[INFO] | +- org.jboss.arquillian.core:arquillian-core-api:jar:1.4.0.Final:test
[INFO] | \- org.jboss.arquillian.core:arquillian-core-spi:jar:1.4.0.Final:test
[INFO] +- org.jboss.arquillian.test:arquillian-test-impl-base:jar:1.4.0.Final:test
[INFO] | +- org.jboss.arquillian.test:arquillian-test-api:jar:1.4.0.Final:test
[INFO] | \- org.jboss.arquillian.test:arquillian-test-spi:jar:1.4.0.Final:test
[INFO] +- org.jboss.arquillian.junit:arquillian-junit-core:jar:1.4.0.Final:test
[INFO] +- org.jboss.arquillian.container:arquillian-container-test-api:jar:1.4.0.Final:test
[INFO] | \- org.jboss.shrinkwrap.descriptors:shrinkwrap-descriptors-api-base:jar:2.0.0:test
[INFO] +- org.jboss.arquillian.container:arquillian-glassfish-embedded-3.1:jar:1.0.2:test
[INFO] | +- org.jboss.arquillian.container:arquillian-container-spi:jar:1.1.15.Final:test
[INFO] | | +- org.jboss.arquillian.config:arquillian-config-api:jar:1.1.15.Final:test
[INFO] | | \- org.jboss.arquillian.config:arquillian-config-impl-base:jar:1.1.15.Final:test
[INFO] | +- org.jboss.arquillian.container:arquillian-container-test-spi:jar:1.1.15.Final:test
[INFO] | +- org.jboss.arquillian.protocol:arquillian-protocol-servlet:jar:1.1.15.Final:test
[INFO] | | +- org.jboss.arquillian.container:arquillian-container-test-impl-base:jar:1.1.15.Final:test
[INFO] | | \- org.jboss.shrinkwrap.descriptors:shrinkwrap-descriptors-spi:jar:2.0.0:test
[INFO] | +- org.jboss.arquillian.testenricher:arquillian-testenricher-cdi:jar:1.1.15.Final:test
[INFO] | +- org.jboss.arquillian.testenricher:arquillian-testenricher-ejb:jar:1.1.15.Final:test
[INFO] | +- org.jboss.arquillian.testenricher:arquillian-testenricher-resource:jar:1.1.15.Final:test
[INFO] | \- org.jboss.arquillian.testenricher:arquillian-testenricher-initialcontext:jar:1.1.15.Final:test
[INFO] +- org.jboss.shrinkwrap:shrinkwrap-api:jar:1.2.6:test
[INFO] +- org.jboss.shrinkwrap:shrinkwrap-impl-base:jar:1.2.6:test
[INFO] | \- org.jboss.shrinkwrap:shrinkwrap-spi:jar:1.2.6:test
[INFO] \- org.jboss.shrinkwrap.resolver:shrinkwrap-resolver-impl-maven-archive:jar:2.2.5:test
[INFO] +- org.jboss.shrinkwrap.resolver:shrinkwrap-resolver-api-maven:jar:2.2.5:test
[INFO] | \- org.jboss.shrinkwrap.resolver:shrinkwrap-resolver-api:jar:2.2.5:test
[INFO] +- org.jboss.shrinkwrap.resolver:shrinkwrap-resolver-api-maven-archive:jar:2.2.5:test
[INFO] | \- org.jboss.shrinkwrap.resolver:shrinkwrap-resolver-spi:jar:2.2.5:test
[INFO] +- org.jboss.shrinkwrap.resolver:shrinkwrap-resolver-spi-maven-archive:jar:2.2.5:test
[INFO] +- org.jboss.shrinkwrap.resolver:shrinkwrap-resolver-impl-maven:jar:2.2.5:test
[INFO] | +- org.jboss.shrinkwrap.resolver:shrinkwrap-resolver-spi-maven:jar:2.2.5:test
[INFO] | +- org.eclipse.aether:aether-api:jar:1.0.0.v20140518:test
[INFO] | +- org.eclipse.aether:aether-impl:jar:1.0.0.v20140518:test
[INFO] | +- org.eclipse.aether:aether-spi:jar:1.0.0.v20140518:test
[INFO] | +- org.eclipse.aether:aether-util:jar:1.0.0.v20140518:test
[INFO] | +- org.eclipse.aether:aether-connector-basic:jar:1.0.0.v20140518:test
[INFO] | +- org.eclipse.aether:aether-transport-wagon:jar:1.0.0.v20140518:test
[INFO] | +- org.apache.maven:maven-aether-provider:jar:3.2.5:test
[INFO] | +- org.apache.maven:maven-model:jar:3.2.5:test
[INFO] | +- org.apache.maven:maven-model-builder:jar:3.2.5:test
[INFO] | +- org.apache.maven:maven-repository-metadata:jar:3.2.5:test
[INFO] | +- org.apache.maven:maven-settings:jar:3.2.5:test
[INFO] | +- org.apache.maven:maven-settings-builder:jar:3.2.5:test
[INFO] | +- com.google.guava:guava:jar:18.0:test
[INFO] | +- org.codehaus.plexus:plexus-interpolation:jar:1.21:test
[INFO] | +- org.sonatype.plexus:plexus-sec-dispatcher:jar:1.3:test
[INFO] | | \- org.sonatype.plexus:plexus-cipher:jar:1.4:test
[INFO] | +- org.apache.maven.wagon:wagon-provider-api:jar:2.6:test
[INFO] | +- org.apache.maven.wagon:wagon-file:jar:2.6:test
[INFO] | | \- commons-lang:commons-lang:jar:2.6:test
[INFO] | \- org.apache.maven.wagon:wagon-http-lightweight:jar:2.6:test
[INFO] | \- org.apache.maven.wagon:wagon-http-shared:jar:2.6:test
[INFO] | +- org.jsoup:jsoup:jar:1.7.2:test
[INFO] | \- commons-io:commons-io:jar:2.2:test
[INFO] +- org.eclipse.sisu:org.eclipse.sisu.plexus:jar:0.3.0.M1:test
[INFO] | +- javax.enterprise:cdi-api:jar:1.0:test
[INFO] | | +- javax.annotation:jsr250-api:jar:1.0:test
[INFO] | | \- javax.inject:javax.inject:jar:1:test
[INFO] | +- org.eclipse.sisu:org.eclipse.sisu.inject:jar:0.3.0.M1:test
[INFO] | \- org.codehaus.plexus:plexus-component-annotations:jar:1.5.5:test
[INFO] +- org.codehaus.plexus:plexus-compiler-javac:jar:2.3:test
[INFO] | \- org.codehaus.plexus:plexus-compiler-api:jar:2.3:test
[INFO] \- org.codehaus.plexus:plexus-utils:jar:3.0.20:test
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.230 s
[INFO] Finished at: 2018-05-16T11:59:06+02:00
[INFO] Final Memory: 14M/303M
[INFO] ------------------------------------------------------------------------
</details>
OS - Ubuntu 16.04 LTS
JDK -
java version "1.8.0_152-ea"
Java(TM) SE Runtime Environment (build 1.8.0_152-ea-b05)
Java HotSpot(TM) 64-Bit Server VM (build 25.152-b05, mixed mode)
<details>
<summary>$ mvn clean test</summary>
java.lang.NullPointerException
at org.jboss.arquillian.container.test.impl.client.deployment.DeploymentGenerator.validate(DeploymentGenerator.java:94)
at org.jboss.arquillian.container.test.impl.client.deployment.DeploymentGenerator.generateDeployment(DeploymentGenerator.java:81)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:86)
at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:103)
at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:90)
at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:133)
at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:105)
at org.jboss.arquillian.core.impl.EventImpl.fire(EventImpl.java:62)
at org.jboss.arquillian.container.test.impl.client.ContainerEventController.execute(ContainerEventController.java:95)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:86)
at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:103)
at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:90)
at org.jboss.arquillian.test.impl.TestContextHandler.createClassContext(TestContextHandler.java:83)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:86)
at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:95)
at org.jboss.arquillian.test.impl.TestContextHandler.createSuiteContext(TestContextHandler.java:69)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:86)
at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:95)
at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:133)
at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:105)
at org.jboss.arquillian.test.impl.EventTestRunnerAdaptor.beforeClass(EventTestRunnerAdaptor.java:89)
at org.jboss.arquillian.junit.Arquillian$2.evaluate(Arquillian.java:163)
at org.jboss.arquillian.junit.Arquillian.multiExecute(Arquillian.java:350)
at org.jboss.arquillian.junit.Arquillian.access$200(Arquillian.java:54)
at org.jboss.arquillian.junit.Arquillian$3.evaluate(Arquillian.java:177)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.jboss.arquillian.junit.Arquillian.run(Arquillian.java:115)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
</details>
Can someone tell me what is wrong in my config ?
This is the content of my file arquillian.xml
<defaultProtocol type="Servlet 3.0"/>
<container default="true" qualifier="glassfish-embedded">
<configuration>
<property name="bindHttpPort">7075</property>
<property name="instanceRoot">src/test/domain</property>
<property name="resourcesXml">src/test/resources/glassfish-resources.xml</property>
</configuration>
</container>
my file structure:
src/test/domain
src/test/resources/arquillian.xml
src/test/resources/glassfish-embedded.xml
Running any test will trigger the error messages below :
The instanceRoot property should be a directory. Instead, it was a file
or
The resourcesXml property does not appear to be a valid file path.
For long outputs such as stacktraces please use HTML5 <details>
<details>
<summary>$mvn --version 3.3.9</summary>
Java version: 1.8.0_152, vendor: Oracle Corporation
Default locale: en_US, platform encoding: UTF-8
OS name: windows x64
</details>
I'm currently faced with the problem that my Glassfish Managed Container fails to start properly.
Whenever I'm executing my tests it fails deploy my application with following output:
Starting container using command: [java, -jar, /opt/payara41/glassfish/modules/admin-cli.jar, start-domain, domain1, -t]
Successfully started the domain : domain1
domain Location: /opt/payara41/glassfish/domains/domain1
Log File: /opt/payara41/glassfish/domains/domain1/logs/server.log
Admin Port: 4848
Jul 13, 2017 3:08:40 PM org.jboss.arquillian.container.glassfish.clientutils.GlassFishClientUtil getResponseMap
SEVERE: exit_code: FAILURE, message: An error occurred while processing the request. Please see the server logs for details. [status: SERVER_ERROR reason: Service Unavailable]
Looking at the server log I'm assuming it's a class loading problem:
java.lang.ClassNotFoundException: org.glassfish.admin.rest.resources.generatedASM.DomainResource not found by org.glassfish.main.admin.rest-service [312]
at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1532)
at org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:75)
at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1955)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at org.glassfish.admin.rest.adapter.RestManagementResourceProvider.getResourceClasses(RestManagementResourceProvider.java:110)
at org.glassfish.admin.rest.adapter.RestAdapter.exposeContext(RestAdapter.java:294)
at org.glassfish.admin.rest.adapter.RestAdapter.service(RestAdapter.java:175)
at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:466)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:169)
at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:206)
at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:180)
at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:235)
at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:284)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:201)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:133)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:112)
at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:539)
at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:56)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:593)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:573)
at java.lang.Thread.run(Thread.java:748)
]]
After manually starting the server with the exact same command as mentioned in my test output, I'm able to successfully run my tests after connecting to the running server.
I'm on a Linux machine
Linux Leger 4.10.0-26-generic #30-Ubuntu SMP Tue Jun 27 09:30:12 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
with Arquillian Glassfish adapter v1.0.1
<dependency>
<groupId>org.jboss.arquillian.container</groupId>
<artifactId>arquillian-glassfish-managed-3.1</artifactId>
<version>${arquillian.glassfish.version}</version>
<scope>test</scope>
</dependency>
in combination with
payara-4.1.2.172
I'd be grateful for any pointers on this problem!
While running CDI 2.0 TCK in GlassFish (Weld 3.0.0.Final) Following test is failing
testSessionContextActiveOnStartAsync(org.jboss.cdi.tck.tests.context.session.async.SessionContextAsyncListenerTest): 500 Internal Server Error for http://localhost:8080/12e3cd06754c1b9f72abe8f0c31ecb930cd13/AsyncServlet?test=loop
It would be nice, if adding of multiple sun-resources to glassfish-embedded 3.1 were supported.
With this, a separation of big sun-resources would be possible, which would lead to better maintainability of sun-resources.
When testing JMS against the Glassfish embedded adapter, but I think it does not include a JMS connection factory configuration. I have to add it myself to make the test passed.
Multiple deployment seems to work randomly on Glassfish 3.1 embedded (didynt test in on remote config)
By randomly i mean that randomly is selected and used one of deployments..
I created test case at my fork witch fails at test: ingwarsw@6c1fb2f
Mayby im doing something wrong but AFAIK it should be ok..
In configuration, e.g.
target/test-classes/glassfish-resources.xmlresourcesXml is interpreted in
https://github.com/arquillian/arquillian-container-glassfish/blob/master/glassfish-embedded-3.1/src/main/java/org/jboss/arquillian/container/glassfish/embedded_3_1/GlassFishConfiguration.java#L266
as new File which makes it vulnerable to where is the main directory.
interpretting file path as classpath resource would make it work always when given resource is on the classpath.
there may be two strategies for that, keeping current one as the first and having a fallback on classpath resource
The complete codes can be found here.
Java:
D:\jdk8\bin\java -version
openjdk version "1.8.0_242"
OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_242-b08)
OpenJDK 64-Bit Server VM (AdoptOpenJDK)(build 25.242-b08, mixed mode)
Maven:
mvn -v
Apache Maven 3.6.2 (40f52333136460af0dc0d7232c0dc0bcf0d9e117; 2019-08-27T23:06:16+08:00)
Maven home: D:\build\maven\bin\..
Java version: 1.8.0_242, vendor: AdoptOpenJDK, runtime: D:\jdk8\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"
Test class.
@RunWith(Arquillian.class)
public class GreetingResourceTest {
private final static Logger LOGGER = Logger.getLogger(GreetingResourceTest.class.getName());
@Deployment(testable = false)
public static WebArchive createDeployment() {
return ShrinkWrap.create(WebArchive.class)
.addClass(GreetingMessage.class)
.addClass(GreetingService.class)
.addClasses(GreetingResource.class, JaxrsActivator.class)
// Enable CDI
.addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml");
}
@ArquillianResource
private URL base;
private Client client;
@Before
public void setup() {
this.client = ClientBuilder.newClient();
try {
Class<?> clazz = Class.forName("com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider");
this.client.register(clazz);
} catch (ClassNotFoundException e) {
LOGGER.warning("Only use for OpenLiberty/CXF which does not register a json provider automatically.");
}
}
@After
public void teardown() {
if(this.client != null) {
this.client.close();
}
}
@Test
public void should_create_greeting() throws MalformedURLException {
final WebTarget greetingTarget = client.target(URI.create(new URL(base, "api/greeting/JakartaEE").toExternalForm()));
try (final Response greetingGetResponse = greetingTarget.request()
.accept(MediaType.APPLICATION_JSON)
.get()) {
assertEquals("response status is ok", 200, greetingGetResponse.getStatus());
assertTrue("message should start with \"Say Hello to JakartaEE at \"",
greetingGetResponse.readEntity(GreetingMessage.class).getMessage().startsWith("Say Hello to JakartaEE"));
}
}
}
Manven profile for glassfish embedded.
<profile>
<!-- JAXRS testing failed with aruqillian glassfish embedded -->
<id>arq-glassfish-embedded</id>
<properties>
<skipTests>true</skipTests>
</properties>
<dependencies>
<!-- Jersey Client -->
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-sse</artifactId>
<version>${jersey.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-json-binding</artifactId>
<version>${jersey.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.json</artifactId>
<version>1.0.4</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.inject</groupId>
<artifactId>jersey-hk2</artifactId>
<version>${jersey.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-client</artifactId>
<version>${jersey.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.glassfish.main.extras</groupId>
<artifactId>glassfish-embedded-all</artifactId>
<version>${glassfish.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.container</groupId>
<artifactId>arquillian-glassfish-embedded-3.1</artifactId>
<version>${arquillian-glassfish.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
</profile>
In a complex setup with multiple TestNG classes including both, Arquilian and non-Arquillian tests, the glassfish embedded container fails to deploy the second Arquillian test with the error
org.glassfish.embeddable.GlassFishException: Already bootstrapped
(the first test runs w/o problems).
From an educated guess, the culprit appears to be the second call to the static method GlassFishRuntime.bootstrap(bootstrapProps) in GlassFishContainer.java for the deployment of the second test, since in the same JVM the runtime has already been bootstrapped.
As a workaround is possible to force a new JVM for each test class with the Maven Surefire plugin as follows:
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.16</version>
<configuration>
<reuseForks>false</reuseForks>
</configuration>
</plugin>
Support configuration of https listener for glassfish embedded (bindHttpsPort property)
Currently, the glassfish embedded container only configures an http port. For applications that might configure CONFIDENTAL element in security constraints of web.xml, the lack of https listener causes http 403 responses because a forward to an equivalent SSL uri is not possible.
I have set drop-and-create
as database action properties in the persistence.xml.
<property name="javax.persistence.schema-generation.database.action" value="drop-and-create"/>
When running the tests, it is ok on Glassfish managed, but failed on embedded due to a transaction exception(duplicated primary key insertion). I researched the logging and I think it is caused by the embedded database in Glassfish embedded. It was not recreated as expected when deploying test arcihve, but the runtime persistence context was cleaned.
I have to do an extra manual clean in the @Before
hooks to overcome this issue.
It's hard to find the corresponding documentation:
https://docs.jboss.org/author/display/ARQ/GlassFish+3.1+-+Remote
It would be great to have a lean README file with some basic information.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.