Tech Tip #34 explained how to create a testable Java EE 7 application. This is useful if you are starting a new application. But what if you already have an application and Arquillian-enable it ?
That’s where Forge and Forge-Arquillian add-on comes in handy. That’s how I added support for Arquillian in javaee7-simple-sample. The updated source code is at github.com/arun-gupta/javaee7-continuous-delivery.
Lets see what was done!
- Download and install Forge. You can download ZIP and unzip in your favorite location, or just use the following command that does it for you:
123456789101112131415161718192021222324Downloads> curl http://forge.jboss.org/sh | sh% Total % Received % Xferd Average Speed Time Time Time CurrentDload Upload Total Spent Left Speed100 2725 0 2725 0 0 4641 0 --:--:-- --:--:-- --:--:-- 4642/usr/bin/javaDownloading Forge######################################################################## 100.0%Archive: /Users/arungupta/.forge/forge_installer.zipcreating: /Users/arungupta/forge/forge-distribution-2.12.2.Final/creating: /Users/arungupta/forge/forge-distribution-2.12.2.Final/img/. . .If you have not yet seen the Forge built-in commands, you may either press TAB to see a list of the currently available commands, or get a more descriptive list by typing:$ command-listThen to get started - see the docs athttp://forge.jboss.org/documentationConsider installing Git and Maven 3.1+ (both optional)Restart Terminal to use forge. - Clone the simple-javaee7-sample repo
123git clone https://github.com/javaee-samples/javaee7-simple-sample.git - Change the directory to
javaee7-simple-sample
and start Forge:
12345678910111213javaee7-simple-sample> ~/tools/forge-distribution-2.12.2.Final/bin/forgeUsing Forge at /Users/arungupta/tools/forge-distribution-2.12.2.Final_____| ___|__ _ __ __ _ ___| |_ / _ \| `__/ _` |/ _ \ \\| _| (_) | | | (_| | __/ //|_| \___/|_| \__, |\___||__/JBoss Forge, version [ 2.12.2.Final ] - JBoss, by Red Hat, Inc. [ http://forge.jboss.org ] - Install the Forge-Arquillian add-on:
123456789101112131415161718[javaee7-simple-sample]$ addon-install-from-git --url https://github.com/forge/addon-arquillian.git***INFO*** Installing Addon from Git [0/4] ...***INFO*** Installing Addon from Git:Cloning repository in /var/folders/3v/syxsk5zx3yqd_8g9m206py_h0000gn/T/1416131293813-0 [0/4] ...***INFO*** Installing Addon from Git:Installing project into local repository [1/4] ...[INFO] Scanning for projects...[INFO][INFO] ------------------------------------------------------------------------[INFO] Building Arquillian Forge Addon 1.0.0-SNAPSHOT[INFO] ------------------------------------------------------------------------[INFO]. . .Downloading: http://repo1.maven.org/maven2/org/jboss/forge/addon/maven-impl-projects/2.12.2.Final/maven-impl-projects-2.12.2.Final.pomDownloaded: http://repo1.maven.org/maven2/org/jboss/forge/addon/maven-impl-projects/2.12.2.Final/maven-impl-projects-2.12.2.Final.pom (4 KB at 16.9 KB/sec)***SUCCESS*** Addon org.arquillian.forge:arquillian-addon,1.0.0-SNAPSHOT was installed successfully. - Configure Arquillian add-on and install WildFly adapter:
12345678910[javaee7-simple-sample]$ arquillian-setup --testFramework junit --containerAdapter wildfly-remoteDownloading: http://repo1.maven.org/maven2/org/wildfly/wildfly-arquillian-container-remote/maven-metadata.xmlDownloaded: http://repo1.maven.org/maven2/org/wildfly/wildfly-arquillian-container-remote/maven-metadata.xml (702 B at 4.2 KB/sec)***SUCCESS*** Arquillian setup complete***SUCCESS*** Installed Arquillian 1.1.5.Final***SUCCESS*** Installed junit***SUCCESS*** Installed Arquillian Container WildFly Remote 8.x***SUCCESS*** Installed Arquillian Container WildFly Remote 8.x dependencies
1234567891011121314glassfish-embedded-3.1 jetty-embedded-6.1 tomee-remoteglassfish-managed-3.1 jetty-embedded-7 was-embedded-8glassfish-remote-3.1 openejb-embedded-3.1 was-remote-7jbossas-embedded-6 openejb-embedded-4 was-remote-8jbossas-managed-4.2 openshift-express weld-ee-embedded-1.1jbossas-managed-5.1 openwebbeans-embedded-1 weld-se-embedded-1jbossas-managed-6 tomcat-embedded-6 weld-se-embedded-1.1jbossas-managed-7 tomcat-embedded-7 wildfly-managedjbossas-remote-4.2 tomcat-managed-5.5 wildfly-remotejbossas-remote-5 tomcat-managed-6 wls-remote-10.3jbossas-remote-5.1 tomcat-managed-7jbossas-remote-6 tomcat-remote-6
1234567891011121314151617181920212223242526<profile><id>arquillian-wildfly-remote</id><build><plugins><plugin><artifactId>maven-surefire-plugin</artifactId><version>2.14.1</version><configuration><systemPropertyVariables><arquillian.launch>arquillian-wildfly-remote</arquillian.launch></systemPropertyVariables></configuration></plugin></plugins></build><dependencies><dependency><groupId>org.wildfly</groupId><artifactId>wildfly-arquillian-container-remote</artifactId><version>8.1.0.Final</version><scope>test</scope></dependency></dependencies></profile>“arquillian.xml” is used to define configuration settings to locate or communicate with the container. In our case, WildFly is running on default host and port and so there is no need to update this file. The important part to note is that the “container” qualifier matches with the “arquillian.launch” qualifier value.
123456<?xml version="1.0" encoding="UTF-8" standalone="no"?><arquillian xmlns="http://jboss.org/schema/arquillian" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jboss.org/schema/arquillian http://jboss.org/schema/arquillian/arquillian_1_0.xsd"><container qualifier="arquillian-wildfly-remote"/></arquillian>This file. More details about this configuration file are available here.
- Until FORGE-2148 is fixed, you also need to add a JAX-RS implementation as well, and the corresponding JAXB provider. This test is using RESTEasy and so the following needs to be added:
1234567891011121314<dependency><groupId>org.jboss.resteasy</groupId><artifactId>resteasy-client</artifactId><version>3.0.5.Final</version><scope>test</scope></dependency><dependency><groupId>org.jboss.resteasy</groupId><artifactId>resteasy-jaxb-provider</artifactId><version>3.0.5.Final</version><scope>test</scope></dependency>
This can be added either in the profile or project-wide dependencies.
And now you are ready to test!
Download WildFly 8.1 and unzip. Start the server as:
1
2
3
|
./bin/standalone.sh
|
Run the tests:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
javaee7-simple-sample> mvn test
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building helloworld 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ helloworld ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ helloworld ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ helloworld ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ helloworld ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.14.1:test (default-test) @ helloworld ---
[INFO] Surefire report directory: /Users/arungupta/workspaces/javaee7-simple-sample/target/surefire-reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running org.javaee7.sample.PersonTest
Nov 16, 2014 1:53:57 PM org.xnio.Xnio
INFO: XNIO version 3.2.0.Beta4
Nov 16, 2014 1:53:57 PM org.xnio.nio.NioXnio
INFO: XNIO NIO Implementation Version 3.2.0.Beta4
Nov 16, 2014 1:53:57 PM org.jboss.remoting3.EndpointImpl
INFO: JBoss Remoting version (unknown)
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 2.963 sec
Results :
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.403 s
[INFO] Finished at: 2014-11-16T13:53:59+02:00
[INFO] Final Memory: 17M/309M
[INFO] ------------------------------------------------------------------------
|
And now you’ve Arquillian-enabled your existing project!
Once again, the complete source code is available at github.com/arun-gupta/javaee7-continuous-delivery.
File any issues here.
Enjoy!
Hi Arun,
just a question: the cloned repo (simple-javaee7-sample repo) has no test in it… how is it possible than that running mvn test executes 2 tests?
Thanks in advance,
Pietro
The PersonTest.java class can be found in the finished example: https://github.com/arun-gupta/javaee7-continuous-delivery
Another issue I found was that when I ran ‘mvn test’ I got this error:
org.jboss.arquillian.container.test.impl.client.deployment.ValidationException: DeploymentScenario contains a target (_DEFAULT_) not matching any defined Container in the registry.
Please include at least 1 Deployable Container on your Classpath.
That was just because I failed to specify the ‘arquillian-wildfly-remote’ profile when running the test, eg:
mvn test -Parquillian-wildfly-remote
Now it has became easier to clarify your all hurdles regarding windows 10 sync settings also you can move to windows 10 update settings which will meet the requirement you are are looking for. Also all information available here will be displayed you in the form of images.
Arquillian venture for JavaMagazin article. Arquillian empowers you to test your business rationale in a remote or installed holder. On the other hand, it can convey a file to the compartment so the test can interface as a remote customer. http://www.domyassignmentforme.com