Skip to content

Instantly share code, notes, and snippets.

@albihasani94
Last active July 1, 2018 21:21
Show Gist options
  • Save albihasani94/5413c3410fd027dd98688f7a1cb8ea7a to your computer and use it in GitHub Desktop.
Save albihasani94/5413c3410fd027dd98688f7a1cb8ea7a to your computer and use it in GitHub Desktop.
Thorntail 2.0 with Arquillian 1.2.1.Final
package org.wildfly.swarm.jaxrs.rest;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.Invocation;
import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.wildfly.swarm.Swarm;
import org.wildfly.swarm.arquillian.CreateSwarm;
import org.wildfly.swarm.jaxrs.JAXRSArchive;
@RunWith(Arquillian.class)
public class ApplicationTest {
private static final Logger LOGGER = LoggerFactory.getLogger(ApplicationTest.class);
private static final String CREATE_DEPLOYMENT = "=====Create deployment=====";
private static final String RETURN_DEPLOYMENT_ARCHIVE = "=====Return deployment archive: {}=====";
private static final String CREATE_SWARM = "=====Create swarm=====";
@Deployment(name = "arquillian_test_single_deployment")
public static Archive createDeployment() {
LOGGER.info(CREATE_DEPLOYMENT);
JAXRSArchive deployment = ShrinkWrap.create(JAXRSArchive.class);
deployment.addClass(HelloWorldEndpoint.class);
deployment.addClass(JAXRSConfiguration.class);
LOGGER.info(RETURN_DEPLOYMENT_ARCHIVE, deployment.getName());
return deployment;
}
@CreateSwarm
public static Swarm newContainer() throws Exception {
LOGGER.info(CREATE_SWARM);
return new Swarm();
}
@Test
public void testMyService() {
Client client = ClientBuilder.newClient();
WebTarget target = client.target("http://localhost:8080/hello");
Invocation.Builder invocationBuilder = target.request(MediaType.TEXT_PLAIN_TYPE);
Response response = invocationBuilder.get();
Assert.assertEquals(200, response.getStatus());
}
@Test
public void doNothing() {
}
}
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.wildfly.swarm</groupId>
<artifactId>wf-swarm-examples</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<artifactId>jaxrs</artifactId>
<name>Thorntail JAXRS with Arquillian</name>
<version>1.0.0-SNAPSHOT</version>
<packaging>war</packaging>
<properties>
<version.io.thorntail>2.0.0.Final</version.io.thorntail>
<version.jboss.arquillian>1.2.1.Final</version.jboss.arquillian>
<version.org.slf4j>1.7.25</version.org.slf4j>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<failOnMissingWebXml>false</failOnMissingWebXml>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.thorntail</groupId>
<artifactId>bom-all</artifactId>
<version>${version.io.thorntail}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian</groupId>
<artifactId>arquillian-bom</artifactId>
<version>${version.jboss.arquillian}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<finalName>jaxrs-example</finalName>
<plugins>
<plugin>
<groupId>io.thorntail</groupId>
<artifactId>thorntail-maven-plugin</artifactId>
<version>${version.io.thorntail}</version>
<executions>
<execution>
<goals>
<goal>package</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.thorntail</groupId>
<artifactId>jaxrs</artifactId>
</dependency>
<dependency>
<groupId>io.thorntail</groupId>
<artifactId>arquillian</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.junit</groupId>
<artifactId>arquillian-junit-container</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>${version.org.slf4j}</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
@albihasani94
Copy link
Author

thorntail.2.0.arquillian.1.2.1.log

[INFO] Scanning for projects...
[INFO] 
[INFO] ------------------------------------------------------------------------
[INFO] Building Thorntail JAXRS with Arquillian 1.0.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ jaxrs ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO] 
[INFO] --- maven-compiler-plugin:3.5.1:compile (default-compile) @ jaxrs ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 3 source files to /home/albihasani94/Desktop/wildfly-swarm-jaxrs/jaxrs/target/classes
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ jaxrs ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /home/albihasani94/Desktop/wildfly-swarm-jaxrs/jaxrs/src/test/resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.5.1:testCompile (default-testCompile) @ jaxrs ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to /home/albihasani94/Desktop/wildfly-swarm-jaxrs/jaxrs/target/test-classes
[INFO] 
[INFO] --- maven-surefire-plugin:2.18.1:test (default-test) @ jaxrs ---
[INFO] Surefire report directory: /home/albihasani94/Desktop/wildfly-swarm-jaxrs/jaxrs/target/surefire-reports

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running org.wildlfy.swarm.jaxrs.rest.ApplicationTest
[main] INFO org.wildlfy.swarm.jaxrs.rest.ApplicationTest - =====Create deployment=====
[main] INFO org.wildlfy.swarm.jaxrs.rest.ApplicationTest - =====Return deployment archive: c662c643-12c5-41c4-b6df-f30924cb5f65.war=====
Resolving 0 out of 525 artifacts
Sun Jul 01 17:04:14 CEST 2018 INFO [org.wildfly.swarm.bootstrap] (main) Dependencies not bundled; resolving from M2REPO.
[main] INFO org.wildlfy.swarm.jaxrs.rest.ApplicationTest - =====Create swarm=====
2018-07-01 17:04:16,825 INFO  [org.wildfly.swarm] (main) WFSWARM0013: Installed fraction:                 Undertow - STABLE          io.thorntail:undertow:2.0.0.Final
2018-07-01 17:04:16,833 INFO  [org.wildfly.swarm] (main) WFSWARM0013: Installed fraction:               Arquillian - STABLE          io.thorntail:arquillian:2.0.0.Final
2018-07-01 17:04:16,833 INFO  [org.wildfly.swarm] (main) WFSWARM0013: Installed fraction:                  Logging - STABLE          io.thorntail:logging:2.0.0.Final
2018-07-01 17:04:16,833 INFO  [org.wildfly.swarm] (main) WFSWARM0013: Installed fraction:                  Elytron - STABLE          io.thorntail:elytron:2.0.0.Final
2018-07-01 17:04:16,834 INFO  [org.wildfly.swarm] (main) WFSWARM0013: Installed fraction:                   JAX-RS - STABLE          io.thorntail:jaxrs:2.0.0.Final
2018-07-01 17:04:18,454 INFO  [org.jboss.msc] (main) JBoss MSC version 1.2.7.SP1
2018-07-01 17:04:18,548 INFO  [org.jboss.as] (MSC service thread 1-7) WFLYSRV0049: Thorntail 2.0.0.Final (WildFly Core 3.0.8.Final) starting
2018-07-01 17:04:18,579 INFO  [org.wildfly.swarm] (MSC service thread 1-7) WFSWARM0019: Install MSC service for command line args: []
2018-07-01 17:04:18,807 INFO  [org.wildfly.swarm.arquillian.daemon.server.Server] (MSC service thread 1-3) Arquillian Daemon server started on localhost:12345
2018-07-01 17:04:19,335 INFO  [org.wildfly.security] (ServerService Thread Pool -- 3) ELY00001: WildFly Elytron version 1.1.6.Final
2018-07-01 17:04:19,394 INFO  [org.jboss.as.naming] (ServerService Thread Pool -- 16) WFLYNAM0001: Activating Naming Subsystem
2018-07-01 17:04:19,390 INFO  [org.jboss.as.jaxrs] (ServerService Thread Pool -- 17) WFLYRS0016: RESTEasy version 3.0.24.Final
2018-07-01 17:04:19,409 INFO  [org.xnio] (ServerService Thread Pool -- 13) XNIO version 3.5.4.Final
2018-07-01 17:04:19,416 INFO  [org.jboss.as.security] (ServerService Thread Pool -- 14) WFLYSEC0002: Activating Security Subsystem
2018-07-01 17:04:19,439 INFO  [org.xnio.nio] (ServerService Thread Pool -- 13) XNIO NIO Implementation Version 3.5.4.Final
2018-07-01 17:04:19,460 INFO  [org.jboss.as.naming] (MSC service thread 1-2) WFLYNAM0003: Starting Naming Service
2018-07-01 17:04:19,468 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-1) WFLYUT0003: Undertow 1.4.18.Final starting
2018-07-01 17:04:19,467 INFO  [org.jboss.as.security] (MSC service thread 1-4) WFLYSEC0001: Current PicketBox version=5.0.2.Final
2018-07-01 17:04:19,468 INFO  [org.wildfly.extension.io] (ServerService Thread Pool -- 13) WFLYIO001: Worker 'default' has auto-configured to 8 core threads with 64 task threads based on your 4 available processors
2018-07-01 17:04:19,745 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-8) WFLYUT0012: Started server default-server.
2018-07-01 17:04:19,790 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-8) WFLYUT0006: Undertow HTTP listener default listening on 0.0.0.0:8080
2018-07-01 17:04:19,857 INFO  [org.jboss.as.server] (Controller Boot Thread) WFLYSRV0212: Resuming server
2018-07-01 17:04:19,860 INFO  [org.jboss.as] (Controller Boot Thread) WFLYSRV0025: Thorntail 2.0.0.Final (WildFly Core 3.0.8.Final) started in 1457ms - Started 99 of 116 services (27 services are lazy, passive or on-demand)
2018-07-01 17:04:20,221 INFO  [org.wildfly.swarm.runtime.deployer] (main) deploying c662c643-12c5-41c4-b6df-f30924cb5f65.war
2018-07-01 17:04:20,245 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-5) WFLYSRV0027: Starting deployment of "c662c643-12c5-41c4-b6df-f30924cb5f65.war" (runtime-name: "c662c643-12c5-41c4-b6df-f30924cb5f65.war")
2018-07-01 17:04:20,943 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-5) WFLYUT0018: Host default-host starting
2018-07-01 17:04:21,135 INFO  [org.jboss.resteasy.resteasy_jaxrs.i18n] (ServerService Thread Pool -- 10) RESTEASY002225: Deploying javax.ws.rs.core.Application: class org.wildfly.swarm.jaxrs.rest.JAXRSConfiguration
2018-07-01 17:04:21,155 INFO  [org.wildfly.extension.undertow] (ServerService Thread Pool -- 10) WFLYUT0021: Registered web context: '/' for server 'default-server'
2018-07-01 17:04:21,189 INFO  [org.jboss.as.server] (main) WFLYSRV0010: Deployed "c662c643-12c5-41c4-b6df-f30924cb5f65.war" (runtime-name : "c662c643-12c5-41c4-b6df-f30924cb5f65.war")
2018-07-01 17:04:21,190 INFO  [org.wildfly.swarm] (main) WFSWARM99999: Thorntail is Ready
2018-07-01 17:04:21,337 INFO  [org.jboss.arquillian.testenricher.cdi.container.BeanManagerProducer] (nioEventLoopGroup-3-1) BeanManager not found.
2018-07-01 17:04:21,394 INFO  [org.jboss.arquillian.testenricher.cdi.container.BeanManagerProducer] (nioEventLoopGroup-3-1) BeanManager not found.
2018-07-01 17:04:21,607 INFO  [stdout] (MSC service thread 1-4) [Server] Requesting shutdown...
2018-07-01 17:04:21,607 INFO  [null] (MSC service thread 1-4) Requesting shutdown...
2018-07-01 17:04:21,625 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-6) WFLYUT0008: Undertow HTTP listener default suspending
2018-07-01 17:04:21,629 INFO  [stdout] (MSC service thread 1-4) [Server] Server shutdown.
2018-07-01 17:04:21,629 INFO  [null] (MSC service thread 1-4) Server shutdown.
2018-07-01 17:04:21,638 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-6) WFLYUT0007: Undertow HTTP listener default stopped, was bound to 0.0.0.0:8080
2018-07-01 17:04:21,646 INFO  [org.wildfly.extension.undertow] (ServerService Thread Pool -- 10) WFLYUT0022: Unregistered web context: '/' from server 'default-server'
2018-07-01 17:04:21,679 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-8) WFLYUT0019: Host default-host stopping
2018-07-01 17:04:21,680 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-8) WFLYUT0004: Undertow 1.4.18.Final stopping
2018-07-01 17:04:21,722 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-3) WFLYSRV0028: Stopped deployment c662c643-12c5-41c4-b6df-f30924cb5f65.war (runtime-name: c662c643-12c5-41c4-b6df-f30924cb5f65.war) in 125ms
2018-07-01 17:04:21,736 INFO  [org.jboss.as] (MSC service thread 1-3) WFLYSRV0050: Thorntail 2.0.0.Final (WildFly Core 3.0.8.Final) stopped in 139ms
2018-07-01 17:04:21,834 INFO  [org.jboss.weld.Bootstrap] (pool-1-thread-1) WELD-ENV-002001: Weld SE container internal shut down

Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 11.301 sec - in org.wildlfy.swarm.jaxrs.rest.ApplicationTest

Results :

Tests run: 2, Failures: 0, Errors: 0, Skipped: 0

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 14.144 s
[INFO] Finished at: 2018-07-01T17:04:22+02:00
[INFO] Final Memory: 38M/345M
[INFO] ------------------------------------------------------------------------

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment