Skip to content

Commit fff02d3

Browse files
committed
Merge pull request javaee-samples#350 from arjantijms/master
Applied @rmannibucau changes for TomEE profile and added comments
2 parents 71635cb + 40db02a commit fff02d3

File tree

3 files changed

+136
-23
lines changed

3 files changed

+136
-23
lines changed

README.md

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,18 @@ A brief instruction how to clone, build, import and run the samples on your loca
1212

1313
Only one container profile and one profile for browser can be active at a given time otherwise there will be dependency conflicts.
1414

15-
There are 5 available container profiles:
15+
There are 8 available container profiles, for 5 different servers:
1616

1717
* ``wildfly-managed-arquillian``
1818

19-
The default profile and it will install a Wildfly server and start up the server per sample.
19+
This profile will install a Wildfly server and start up the server per sample.
2020
Useful for CI servers.
2121

2222
* ``wildfly-remote-arquillian``
2323

2424
This profile requires you to start up a Wildfly server outside of the build. Each sample will then
2525
reuse this instance to run the tests.
26-
Useful for development to avoid the server start up cost per sample.
26+
Useful for development to avoid the server start up cost per sample. This is the default profile.
2727

2828
* ``glassfish-embedded-arquillian``
2929

@@ -36,9 +36,39 @@ There are 5 available container profiles:
3636
reuse this instance to run the tests.
3737
Useful for development to avoid the server start up cost per sample.
3838

39+
* ``tomee-managed-arquillian``
40+
41+
This profile will install a TomEE server and start up that server per sample.
42+
Useful for CI servers. This profile cannot connect to a running server.
43+
44+
Note that the version of TomEE to be used has to be present in an
45+
available maven repository. The defaults in this profile assume that the arquillian adapter and
46+
the TomEE server have the same version. E.g both 7.0.0-SNAPSHOT.
47+
48+
To use a TomEE server that's not available in maven central, one way to use it for the samples is to
49+
install it in a local .m2 as follows:
50+
51+
Clone TomEE repo:
52+
53+
``git clone https://github.com/apache/tomee``
54+
``cd tomee``
55+
56+
Switch to the desired version if needed, then build and install in .m2:
57+
58+
``mvn clean install -pl tomee/apache-tomee -am -Dmaven.test.skip=true``
59+
60+
``mvn clean install -pl arquillian -amd -Dmaven.test.skip=true``
61+
62+
Make sure the version that's installed (see pom.xml in TomEE project) matches the ``tomee.version`` in the
63+
properties section in the root pom.xml of the samples project.
64+
65+
* ``tomee-embedded-arquillian``
66+
67+
This profile uses the TomEE embedded server and runs in the same JVM as the TestClass.
68+
3969
* ``liberty-managed-arquillian``
4070

41-
This profile will start up the server per sample, and optionally connects to a running server that you
71+
This profile will start up the Liberty server per sample, and optionally connects to a running server that you
4272
can start up outside of the build (with the restriction that this server has to run on the host as where
4373
the tests are run using the same user).
4474

jaspic/common/src/main/java/org/javaee7/jaspic/common/ArquillianBase.java

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -140,13 +140,19 @@ protected URL getBase() {
140140
* @return the raw content as a string as returned by the server
141141
*/
142142
protected String getFromServerPath(final String path) {
143-
try {
144-
response = null;
145-
response = webClient.getPage(base + path).getWebResponse().getContentAsString();
146-
return response;
147-
} catch (FailingHttpStatusCodeException | IOException e) {
148-
throw new IllegalStateException(e);
143+
response = null;
144+
for (int i=0; i<=3; i++) {
145+
try {
146+
response = webClient.getPage(base + path).getWebResponse().getContentAsString();
147+
if (!response.contains("The response wrapper must wrap the response obtained from getResponse()")) {
148+
return response;
149+
}
150+
} catch (FailingHttpStatusCodeException | IOException e) {
151+
throw new IllegalStateException(e);
152+
}
149153
}
154+
155+
return response;
150156
}
151157

152158
}

pom.xml

Lines changed: 90 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,15 @@
4040
<maven.test.skip>false</maven.test.skip>
4141
<hamcrest.version>1.3</hamcrest.version>
4242
<glassfish.version>4.0</glassfish.version>
43-
<tomee.version>7.0.0-M3</tomee.version>
43+
44+
<!--
45+
TomEE version that's installed and used when selecting the
46+
tomee-managed-arquillian profile. Has to be made available
47+
locally or version has to be changed to a version available in
48+
maven central.
49+
See README.md for details.
50+
-->
51+
<tomee.version>7.0.0-SNAPSHOT</tomee.version>
4452
</properties>
4553

4654
<modules>
@@ -706,15 +714,10 @@
706714
<artifactId>tomee-webservices</artifactId>
707715
<version>${tomee.version}</version>
708716
</dependency>
709-
<dependency>
710-
<groupId>org.apache.tomee</groupId>
711-
<artifactId>tomee-jaxrs</artifactId>
712-
<version>${tomee.version}</version>
713-
</dependency>
714717
<dependency>
715718
<groupId>org.apache.batchee</groupId>
716719
<artifactId>batchee-jbatch</artifactId>
717-
<version>0.2-incubating</version>
720+
<version>0.3-incubating</version>
718721
</dependency>
719722
<dependency>
720723
<groupId>org.apache.johnzon</groupId>
@@ -724,17 +727,17 @@
724727
<dependency>
725728
<groupId>org.apache.tomcat</groupId>
726729
<artifactId>tomcat-el-api</artifactId>
727-
<version>8.0.32</version>
730+
<version>8.5.0</version>
728731
</dependency>
729732
<dependency>
730733
<groupId>org.apache.tomcat</groupId>
731734
<artifactId>tomcat-jasper-el</artifactId>
732-
<version>8.0.32</version>
735+
<version>8.5.0</version>
733736
</dependency>
734737
<dependency>
735738
<groupId>org.apache.commons</groupId>
736739
<artifactId>commons-lang3</artifactId>
737-
<version>3.4</version>
740+
<version>3.3.2</version>
738741
</dependency>
739742
</dependencies>
740743
<build>
@@ -752,21 +755,95 @@
752755
</profile>
753756

754757
<profile>
755-
<id>tomee-remote-arquillian</id>
758+
<id>tomee-managed-arquillian</id>
759+
756760
<dependencies>
761+
762+
<!-- The arquillian "remote" adapter that installs and starts/stops TomEE and deploys/undeploys tests -->
757763
<dependency>
758764
<groupId>org.apache.tomee</groupId>
759765
<artifactId>arquillian-tomee-remote</artifactId>
760766
<version>${tomee.version}</version>
767+
<exclusions>
768+
<exclusion> <!-- let's use default (JTA) otherwise we need to setup the pom in a harder way -->
769+
<groupId>org.apache.tomee</groupId>
770+
<artifactId>arquillian-openejb-transaction-provider</artifactId>
771+
</exclusion>
772+
</exclusions>
761773
</dependency>
774+
775+
<!-- The version of TomEE that the "remote" adapter is going to install and use.
776+
Note that the adapter does *not* connect to an existing user installed TomEE
777+
instance.
778+
-->
762779
<dependency>
763780
<groupId>org.apache.tomee</groupId>
764781
<artifactId>apache-tomee</artifactId>
765782
<version>${tomee.version}</version>
766-
<classifier>plus</classifier>
767783
<type>zip</type>
784+
<classifier>plus</classifier>
785+
</dependency>
786+
787+
<dependency>
788+
<groupId>com.h2database</groupId>
789+
<artifactId>h2</artifactId>
790+
<version>1.4.191</version>
791+
<scope>test</scope>
792+
</dependency>
793+
<dependency>
794+
<groupId>org.apache.cxf</groupId>
795+
<artifactId>cxf-rt-rs-client</artifactId>
796+
<version>3.1.5</version>
797+
<scope>test</scope>
768798
</dependency>
769799
</dependencies>
800+
801+
<build>
802+
<plugins>
803+
<plugin>
804+
<artifactId>maven-surefire-plugin</artifactId>
805+
<configuration>
806+
<argLine>-DTOMEE_LOCK_FILE=${user.dir}/.tomee-ports.lock</argLine>
807+
<systemPropertyVariables>
808+
809+
<!--
810+
TomEE Remote Arquillian Adapter Configuration
811+
812+
The TomEE adapter can be directly configured via system properties
813+
without requiring to shuffle these to the arquillian.xml file.
814+
-->
815+
816+
<!-- Using random port to run in // tests -->
817+
<tomee.stopPort>-1</tomee.stopPort>
818+
<tomee.httpPort>-1</tomee.httpPort>
819+
<tomee.httpsPort>-1</tomee.httpsPort>
820+
<tomee.ajpPort>-1</tomee.ajpPort>
821+
822+
<!-- Configure arquillian adapter here to do it once without any other module -->
823+
<tomee.dir>target/tomee/server</tomee.dir>
824+
<tomee.appWorkingDir>target/tomee/arquillian</tomee.appWorkingDir>
825+
<tomee.cleanOnStartUp>true</tomee.cleanOnStartUp>
826+
<tomee.classifier>plus</tomee.classifier>
827+
<tomee.properties>
828+
# default resources are not on by default cause it can need ports etc (JMS)
829+
openejb.environment.default=true
830+
831+
# see additionalLibs
832+
javax.persistence.provider = org.eclipse.persistence.jpa.PersistenceProvider
833+
</tomee.properties>
834+
<tomee.additionalLibs>
835+
# OpenJPA is not yet JPA 2.1 and a lot of test - not only JPA - rely on javax.persistence properties
836+
remove:openjpa
837+
mvn:org.eclipse.persistence:eclipselink:2.5.2
838+
mvn:org.eclipse.persistence:commonj.sdo:2.1.1
839+
# some tests rely on h2 presence so ensure it is there even if tomee default is hsqldb
840+
mvn:com.h2database:h2:1.4.191
841+
</tomee.additionalLibs>
842+
</systemPropertyVariables>
843+
</configuration>
844+
</plugin>
845+
</plugins>
846+
</build>
770847
</profile>
771848

772849
<profile>
@@ -946,4 +1023,4 @@
9461023
</profile>
9471024
</profiles>
9481025

949-
</project>
1026+
</project>

0 commit comments

Comments
 (0)