Skip to content

Commit 41c735e

Browse files
committed
Merge pull request #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+
<basicRegistry id="basic">
70+
<user name="test" password="not needed"/>
71+
<group name="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
import org.javaee7.jaspic.common.ArquillianBase;
1010
import org.jboss.arquillian.container.test.api.Deployment;
1111
import org.jboss.arquillian.junit.Arquillian;
12+
import org.jboss.shrinkwrap.api.Archive;
1213
import org.jboss.shrinkwrap.api.spec.WebArchive;
1314
import org.junit.Test;
1415
import org.junit.runner.RunWith;
@@ -25,8 +26,9 @@
2526
public class RequestFromPolicyContextTest extends ArquillianBase {
2627

2728
@Deployment(testable = false)
28-
public static WebArchive createDeployment() {
29-
return defaultArchive().addPackages(true, "org.javaee7.jacc");
29+
public static Archive<?> 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
import org.javaee7.jaspic.common.ArquillianBase;
1212
import org.jboss.arquillian.container.test.api.Deployment;
1313
import org.jboss.arquillian.junit.Arquillian;
14+
import org.jboss.shrinkwrap.api.Archive;
1415
import org.jboss.shrinkwrap.api.spec.WebArchive;
1516
import org.junit.Test;
1617
import org.junit.runner.RunWith;
@@ -44,8 +45,9 @@
4445
public class SubjectFromPolicyContextTest extends ArquillianBase {
4546

4647
@Deployment(testable = false)
47-
public static WebArchive createDeployment() {
48-
return defaultArchive().addPackages(true, "org.javaee7.jacc");
48+
public static Archive<?> 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-bnd xmlns: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-role name="architect">
8+
<group name="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
import org.javaee7.jaspic.common.ArquillianBase;
88
import org.jboss.arquillian.container.test.api.Deployment;
99
import org.jboss.arquillian.junit.Arquillian;
10-
import org.jboss.shrinkwrap.api.spec.WebArchive;
10+
import org.jboss.shrinkwrap.api.Archive;
1111
import org.junit.Test;
1212
import org.junit.runner.RunWith;
1313
import org.xml.sax.SAXException;
@@ -22,7 +22,7 @@
2222
public class AsyncAuthenticationPublicTest extends ArquillianBase {
2323

2424
@Deployment(testable = false)
25-
public static WebArchive createDeployment() {
25+
public static Archive<?> createDeployment() {
2626
return defaultArchive();
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-bnd xmlns: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-role name="architect">
8+
<group name="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
import org.javaee7.jaspic.common.ArquillianBase;
99
import org.jboss.arquillian.container.test.api.Deployment;
1010
import org.jboss.arquillian.junit.Arquillian;
11-
import org.jboss.shrinkwrap.api.spec.WebArchive;
11+
import org.jboss.shrinkwrap.api.Archive;
1212
import org.junit.Test;
1313
import org.junit.runner.RunWith;
1414
import org.xml.sax.SAXException;
@@ -24,7 +24,7 @@
2424
public class BasicAuthenticationProtectedTest extends ArquillianBase {
2525

2626
@Deployment(testable = false)
27-
public static WebArchive createDeployment() {
27+
public static Archive<?> createDeployment() {
2828
return defaultArchive();
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
import org.javaee7.jaspic.common.ArquillianBase;
88
import org.jboss.arquillian.container.test.api.Deployment;
99
import org.jboss.arquillian.junit.Arquillian;
10-
import org.jboss.shrinkwrap.api.spec.WebArchive;
10+
import org.jboss.shrinkwrap.api.Archive;
1111
import org.junit.Test;
1212
import org.junit.runner.RunWith;
1313
import org.xml.sax.SAXException;
@@ -22,7 +22,7 @@
2222
public class BasicAuthenticationPublicTest extends ArquillianBase {
2323

2424
@Deployment(testable = false)
25-
public static WebArchive createDeployment() {
25+
public static Archive<?> createDeployment() {
2626
return defaultArchive();
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
import org.javaee7.jaspic.common.ArquillianBase;
99
import org.jboss.arquillian.container.test.api.Deployment;
1010
import org.jboss.arquillian.junit.Arquillian;
11-
import org.jboss.shrinkwrap.api.spec.WebArchive;
11+
import org.jboss.shrinkwrap.api.Archive;
1212
import org.junit.Test;
1313
import org.junit.runner.RunWith;
1414
import org.xml.sax.SAXException;
@@ -22,7 +22,7 @@
2222
public class BasicAuthenticationStatelessTest extends ArquillianBase {
2323

2424
@Deployment(testable = false)
25-
public static WebArchive createDeployment() {
25+
public static Archive<?> createDeployment() {
2626
return defaultArchive();
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
package org.javaee7.jaspic.common;
22

3+
import static java.lang.Boolean.getBoolean;
4+
import static org.jboss.shrinkwrap.api.ShrinkWrap.create;
5+
36
import java.io.File;
47
import java.io.IOException;
58
import java.net.URL;
69

710
import org.jboss.arquillian.test.api.ArquillianResource;
8-
import org.jboss.shrinkwrap.api.ShrinkWrap;
11+
import org.jboss.shrinkwrap.api.Archive;
12+
import org.jboss.shrinkwrap.api.spec.EnterpriseArchive;
913
import org.jboss.shrinkwrap.api.spec.WebArchive;
1014
import org.junit.After;
1115
import org.junit.Before;
@@ -23,12 +27,31 @@ public class ArquillianBase {
2327
private static final String WEBAPP_SRC = "src/main/webapp";
2428
private WebClient webClient;
2529

26-
public static WebArchive defaultArchive() {
27-
return ShrinkWrap.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+
public static Archive<?> defaultArchive() {
31+
32+
WebArchive webArchive =
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+
return webArchive;
54+
}
3255
}
3356

3457
private static File resource(String name) {

0 commit comments

Comments
 (0)