Skip to content

Commit 41c735e

Browse files
committed
Merge pull request javaee-samples#299 from arjantijms/master
Added profile for Liberty
2 parents b89f18f + 6607515 commit 41c735e

File tree

22 files changed

+206
-34
lines changed

22 files changed

+206
-34
lines changed

‎README.md‎

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ 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 4 available container profiles:
15+
There are 5 available container profiles:
1616

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

@@ -35,8 +35,45 @@ There are 4 available container profiles:
3535
This profile requires you to start up a GlassFish server outside of the build. Each sample will then
3636
reuse this instance to run the tests.
3737
Useful for development to avoid the server start up cost per sample.
38+
39+
*``liberty-managed-arquillian``
3840

39-
Each of the containers allow you to override the version used
41+
This profile will start up the server per sample, and optionally connects to a running server that you
42+
can start up outside of the build (with the restriction that this server has to run on the host as where
43+
the tests are run using the same user).
44+
45+
To connect to a running server the ``org.jboss.arquillian.container.was.wlp_managed_8_5.allowConnectingToRunningServer``
46+
system property has to be set to true. E.g.
47+
48+
``-Dorg.jboss.arquillian.container.was.wlp_managed_8_5.allowConnectingToRunningServer=true``
49+
50+
This profile requires you to set the location where Liberty is installed via the ``libertyManagedArquillian_wlpHome``
51+
system property. E.g.
52+
53+
``-DlibertyManagedArquillian_wlpHome=/opt/wlp``
54+
55+
This profile also requires the localConnector feature to be configured in server.xml, and if all tests are to be run at least the
56+
javaee-7.0 feature and jaspic-1.1 (even though this is part of Java EE 7 already). E.g.
57+
58+
```xml
59+
<featureManager>
60+
<feature>javaee-7.0</feature>
61+
<feature>jaspic-1.1</feature>
62+
<feature>localConnector-1.0</feature>
63+
</featureManager>
64+
```
65+
66+
For the JASPIC tests to even be attempted to be executed a cheat is needed that creates a user in Liberty's internal user registry:
67+
68+
```xml
69+
<basicRegistryid="basic">
70+
<username="test"password="not needed"/>
71+
<groupname="architect"/>
72+
</basicRegistry>
73+
```
74+
75+
76+
Some of the containers allow you to override the version used
4077

4178
* `-Dorg.wildfly=8.1.0.Final`
4279

‎jacc/contexts/src/test/java/org/javaee7/jacc/contexts/RequestFromPolicyContextTest.java‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
importorg.javaee7.jaspic.common.ArquillianBase;
1010
importorg.jboss.arquillian.container.test.api.Deployment;
1111
importorg.jboss.arquillian.junit.Arquillian;
12+
importorg.jboss.shrinkwrap.api.Archive;
1213
importorg.jboss.shrinkwrap.api.spec.WebArchive;
1314
importorg.junit.Test;
1415
importorg.junit.runner.RunWith;
@@ -25,8 +26,9 @@
2526
publicclassRequestFromPolicyContextTestextendsArquillianBase{
2627

2728
@Deployment(testable = false)
28-
publicstaticWebArchivecreateDeployment(){
29-
returndefaultArchive().addPackages(true, "org.javaee7.jacc");
29+
publicstaticArchive<?> createDeployment(){
30+
// TODO: Fix for Liberty which requires EARs :(
31+
return ((WebArchive)defaultArchive()).addPackages(true, "org.javaee7.jacc");
3032
}
3133

3234
/**

‎jacc/contexts/src/test/java/org/javaee7/jacc/contexts/SubjectFromPolicyContextTest.java‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
importorg.javaee7.jaspic.common.ArquillianBase;
1212
importorg.jboss.arquillian.container.test.api.Deployment;
1313
importorg.jboss.arquillian.junit.Arquillian;
14+
importorg.jboss.shrinkwrap.api.Archive;
1415
importorg.jboss.shrinkwrap.api.spec.WebArchive;
1516
importorg.junit.Test;
1617
importorg.junit.runner.RunWith;
@@ -44,8 +45,9 @@
4445
publicclassSubjectFromPolicyContextTestextendsArquillianBase{
4546

4647
@Deployment(testable = false)
47-
publicstaticWebArchivecreateDeployment(){
48-
returndefaultArchive().addPackages(true, "org.javaee7.jacc");
48+
publicstaticArchive<?> createDeployment(){
49+
// TODO: Fix for Liberty which requires EARs :(
50+
return ((WebArchive)defaultArchive()).addPackages(true, "org.javaee7.jacc");
4951
}
5052

5153
/**
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<application-bndxmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://websphere.ibm.com/xml/ns/javaee http://websphere.ibm.com/xml/ns/javaee/ibm-application-bnd_1_2.xsd"
4+
xmlns="http://websphere.ibm.com/xml/ns/javaee"
5+
version="1.2">
6+
7+
<security-rolename="architect">
8+
<groupname="architect" />
9+
</security-role>
10+
11+
</application-bnd>

‎jaspic/async-authentication/src/test/java/org/javaee7/jaspic/asyncauthentication/AsyncAuthenticationPublicTest.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
importorg.javaee7.jaspic.common.ArquillianBase;
88
importorg.jboss.arquillian.container.test.api.Deployment;
99
importorg.jboss.arquillian.junit.Arquillian;
10-
importorg.jboss.shrinkwrap.api.spec.WebArchive;
10+
importorg.jboss.shrinkwrap.api.Archive;
1111
importorg.junit.Test;
1212
importorg.junit.runner.RunWith;
1313
importorg.xml.sax.SAXException;
@@ -22,7 +22,7 @@
2222
publicclassAsyncAuthenticationPublicTestextendsArquillianBase{
2323

2424
@Deployment(testable = false)
25-
publicstaticWebArchivecreateDeployment(){
25+
publicstaticArchive<?>createDeployment(){
2626
returndefaultArchive();
2727
}
2828

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<application-bndxmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://websphere.ibm.com/xml/ns/javaee http://websphere.ibm.com/xml/ns/javaee/ibm-application-bnd_1_2.xsd"
4+
xmlns="http://websphere.ibm.com/xml/ns/javaee"
5+
version="1.2">
6+
7+
<security-rolename="architect">
8+
<groupname="architect" />
9+
</security-role>
10+
11+
</application-bnd>

‎jaspic/basic-authentication/src/test/java/org/javaee7/jaspic/basicauthentication/BasicAuthenticationProtectedTest.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
importorg.javaee7.jaspic.common.ArquillianBase;
99
importorg.jboss.arquillian.container.test.api.Deployment;
1010
importorg.jboss.arquillian.junit.Arquillian;
11-
importorg.jboss.shrinkwrap.api.spec.WebArchive;
11+
importorg.jboss.shrinkwrap.api.Archive;
1212
importorg.junit.Test;
1313
importorg.junit.runner.RunWith;
1414
importorg.xml.sax.SAXException;
@@ -24,7 +24,7 @@
2424
publicclassBasicAuthenticationProtectedTestextendsArquillianBase{
2525

2626
@Deployment(testable = false)
27-
publicstaticWebArchivecreateDeployment(){
27+
publicstaticArchive<?>createDeployment(){
2828
returndefaultArchive();
2929
}
3030

‎jaspic/basic-authentication/src/test/java/org/javaee7/jaspic/basicauthentication/BasicAuthenticationPublicTest.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
importorg.javaee7.jaspic.common.ArquillianBase;
88
importorg.jboss.arquillian.container.test.api.Deployment;
99
importorg.jboss.arquillian.junit.Arquillian;
10-
importorg.jboss.shrinkwrap.api.spec.WebArchive;
10+
importorg.jboss.shrinkwrap.api.Archive;
1111
importorg.junit.Test;
1212
importorg.junit.runner.RunWith;
1313
importorg.xml.sax.SAXException;
@@ -22,7 +22,7 @@
2222
publicclassBasicAuthenticationPublicTestextendsArquillianBase{
2323

2424
@Deployment(testable = false)
25-
publicstaticWebArchivecreateDeployment(){
25+
publicstaticArchive<?>createDeployment(){
2626
returndefaultArchive();
2727
}
2828

‎jaspic/basic-authentication/src/test/java/org/javaee7/jaspic/basicauthentication/BasicAuthenticationStatelessTest.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
importorg.javaee7.jaspic.common.ArquillianBase;
99
importorg.jboss.arquillian.container.test.api.Deployment;
1010
importorg.jboss.arquillian.junit.Arquillian;
11-
importorg.jboss.shrinkwrap.api.spec.WebArchive;
11+
importorg.jboss.shrinkwrap.api.Archive;
1212
importorg.junit.Test;
1313
importorg.junit.runner.RunWith;
1414
importorg.xml.sax.SAXException;
@@ -22,7 +22,7 @@
2222
publicclassBasicAuthenticationStatelessTestextendsArquillianBase{
2323

2424
@Deployment(testable = false)
25-
publicstaticWebArchivecreateDeployment(){
25+
publicstaticArchive<?>createDeployment(){
2626
returndefaultArchive();
2727
}
2828

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

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
packageorg.javaee7.jaspic.common;
22

3+
importstaticjava.lang.Boolean.getBoolean;
4+
importstaticorg.jboss.shrinkwrap.api.ShrinkWrap.create;
5+
36
importjava.io.File;
47
importjava.io.IOException;
58
importjava.net.URL;
69

710
importorg.jboss.arquillian.test.api.ArquillianResource;
8-
importorg.jboss.shrinkwrap.api.ShrinkWrap;
11+
importorg.jboss.shrinkwrap.api.Archive;
12+
importorg.jboss.shrinkwrap.api.spec.EnterpriseArchive;
913
importorg.jboss.shrinkwrap.api.spec.WebArchive;
1014
importorg.junit.After;
1115
importorg.junit.Before;
@@ -23,12 +27,31 @@ public class ArquillianBase{
2327
privatestaticfinalStringWEBAPP_SRC = "src/main/webapp";
2428
privateWebClientwebClient;
2529

26-
publicstaticWebArchivedefaultArchive(){
27-
returnShrinkWrap.create(WebArchive.class)
28-
.addPackages(true, "org.javaee7.jaspic")
29-
.addAsWebInfResource(resource("web.xml"))
30-
.addAsWebInfResource(resource("jboss-web.xml"))
31-
.addAsWebInfResource(resource("glassfish-web.xml"));
30+
publicstaticArchive<?> defaultArchive(){
31+
32+
WebArchivewebArchive =
33+
create(WebArchive.class, "test.war")
34+
.addPackages(true, "org.javaee7.jaspic")
35+
.addAsWebInfResource(resource("web.xml"))
36+
.addAsWebInfResource(resource("jboss-web.xml"))
37+
.addAsWebInfResource(resource("glassfish-web.xml"));
38+
39+
if (getBoolean("useEarForJaspic")){
40+
return
41+
// EAR archive
42+
create(EnterpriseArchive.class, "test.ear")
43+
44+
// Liberty needs to have the binding file in an ear.
45+
.addAsManifestResource(resource("ibm-application-bnd.xml"))
46+
47+
// Web module
48+
// This is needed to prevent Arquillian generating an illegal application.xml
49+
.addAsModule(
50+
webArchive
51+
);
52+
} else{
53+
returnwebArchive;
54+
}
3255
}
3356

3457
privatestaticFileresource(Stringname){

0 commit comments

Comments
(0)