Skip to content

Commit dfb4892

Browse files
committed
Jetty tests pretty much working
1 parent 1e38b21 commit dfb4892

8 files changed

Lines changed: 133 additions & 71 deletions

File tree

‎impl-servlet/src/main/resources/META-INF/web-fragment.xml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
version="3.0">
77

88
<name id="prettyfaces">com_ocpsoft_rewrite</name>
9-
<distributable />
9+
<distributable />
1010

1111
<ordering>
1212
<before>

‎integration-cdi/pom.xml‎

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<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/xsd/maven-4.0.0.xsd">
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
34
<modelVersion>4.0.0</modelVersion>
45
<parent>
56
<groupId>org.ocpsoft.rewrite</groupId>
@@ -26,7 +27,7 @@
2627
<artifactId>cdi-api</artifactId>
2728
<scope>provided</scope>
2829
</dependency>
29-
30+
3031
<dependency>
3132
<groupId>org.jboss.spec.javax.servlet</groupId>
3233
<artifactId>jboss-servlet-api_3.0_spec</artifactId>
@@ -44,4 +45,20 @@
4445
</dependency>
4546
</dependencies>
4647

48+
<profiles>
49+
<profile>
50+
<id>JETTY_EMBEDDED_8.X</id>
51+
<build>
52+
<plugins>
53+
<plugin>
54+
<groupId>org.apache.maven.plugins</groupId>
55+
<artifactId>maven-surefire-plugin</artifactId>
56+
<configuration>
57+
<forkMode>always</forkMode>
58+
</configuration>
59+
</plugin>
60+
</plugins>
61+
</build>
62+
</profile>
63+
</profiles>
4764
</project>

‎integration-cdi/src/test/java/org/ocpsoft/rewrite/cdi/bridge/CdiMultipleFeaturesTest.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ public static WebArchive getDeployment()
4444
{
4545
return RewriteTest
4646
.getDeployment()
47+
.addAsWebInfResource(new StringAsset("<beans/>"), "beans.xml")
4748
.addClasses(BindingBean.class, ExpressionLanguageTestConfigurationProvider.class, MockBean.class,
48-
RewriteLifecycleEventObserver.class, ServiceEnricherTestConfigProvider.class)
49-
.addAsWebInfResource(new StringAsset("<beans/>"), "beans.xml");
49+
RewriteLifecycleEventObserver.class, ServiceEnricherTestConfigProvider.class);
5050
}
5151

5252
/*

‎integration-faces/pom.xml‎

Lines changed: 62 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,69 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<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/xsd/maven-4.0.0.xsd">
3-
<modelVersion>4.0.0</modelVersion>
4-
<parent>
5-
<artifactId>rewrite-parent</artifactId>
6-
<groupId>org.ocpsoft.rewrite</groupId>
7-
<version>1.0.6-SNAPSHOT</version>
8-
<relativePath>../</relativePath>
9-
</parent>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
<parent>
6+
<artifactId>rewrite-parent</artifactId>
7+
<groupId>org.ocpsoft.rewrite</groupId>
8+
<version>1.0.6-SNAPSHOT</version>
9+
<relativePath>../</relativePath>
10+
</parent>
1011

11-
<artifactId>rewrite-integration-faces</artifactId>
12+
<artifactId>rewrite-integration-faces</artifactId>
1213

13-
<dependencies>
14-
<dependency>
15-
<groupId>org.ocpsoft.rewrite</groupId>
16-
<artifactId>rewrite-impl-servlet</artifactId>
17-
<scope>provided</scope>
18-
</dependency>
19-
<dependency>
20-
<groupId>org.ocpsoft.rewrite</groupId>
21-
<artifactId>rewrite-api-servlet</artifactId>
22-
<scope>provided</scope>
23-
</dependency>
14+
<dependencies>
15+
<dependency>
16+
<groupId>org.ocpsoft.rewrite</groupId>
17+
<artifactId>rewrite-impl-servlet</artifactId>
18+
<scope>provided</scope>
19+
</dependency>
20+
<dependency>
21+
<groupId>org.ocpsoft.rewrite</groupId>
22+
<artifactId>rewrite-api-servlet</artifactId>
23+
<scope>provided</scope>
24+
</dependency>
2425

25-
<dependency>
26-
<groupId>org.jboss.spec.javax.servlet</groupId>
27-
<artifactId>jboss-servlet-api_3.0_spec</artifactId>
28-
<scope>provided</scope>
29-
</dependency>
26+
<dependency>
27+
<groupId>org.jboss.spec.javax.servlet</groupId>
28+
<artifactId>jboss-servlet-api_3.0_spec</artifactId>
29+
<scope>provided</scope>
30+
</dependency>
3031

31-
<dependency>
32-
<groupId>org.jboss.spec.javax.faces</groupId>
33-
<artifactId>jboss-jsf-api_2.1_spec</artifactId>
34-
<version>2.0.0.Beta1</version>
35-
<scope>provided</scope>
36-
</dependency>
37-
<dependency>
38-
<groupId>org.jboss.spec.javax.el</groupId>
39-
<artifactId>jboss-el-api_2.2_spec</artifactId>
40-
<scope>provided</scope>
41-
</dependency>
42-
<dependency>
43-
<groupId>org.glassfish</groupId>
44-
<artifactId>javax.faces</artifactId>
45-
<version>2.1.7</version>
46-
</dependency>
47-
<dependency>
48-
<groupId>javax.servlet</groupId>
49-
<artifactId>jstl</artifactId>
50-
<version>1.1.2</version>
51-
</dependency>
52-
<dependency>
53-
<groupId>org.ocpsoft.rewrite</groupId>
54-
<artifactId>rewrite-test-harness</artifactId>
55-
</dependency>
56-
</dependencies>
32+
<dependency>
33+
<groupId>org.jboss.spec.javax.faces</groupId>
34+
<artifactId>jboss-jsf-api_2.1_spec</artifactId>
35+
<scope>provided</scope>
36+
</dependency>
37+
<dependency>
38+
<groupId>org.jboss.spec.javax.el</groupId>
39+
<artifactId>jboss-el-api_2.2_spec</artifactId>
40+
<scope>provided</scope>
41+
</dependency>
42+
<dependency>
43+
<groupId>javax.servlet</groupId>
44+
<artifactId>jstl</artifactId>
45+
<version>1.1.2</version>
46+
</dependency>
47+
<dependency>
48+
<groupId>org.ocpsoft.rewrite</groupId>
49+
<artifactId>rewrite-test-harness</artifactId>
50+
</dependency>
51+
</dependencies>
5752

53+
<profiles>
54+
<profile>
55+
<id>JETTY_EMBEDDED_8.X</id>
56+
<build>
57+
<plugins>
58+
<plugin>
59+
<groupId>org.apache.maven.plugins</groupId>
60+
<artifactId>maven-surefire-plugin</artifactId>
61+
<configuration>
62+
<forkMode>always</forkMode>
63+
</configuration>
64+
</plugin>
65+
</plugins>
66+
</build>
67+
</profile>
68+
</profiles>
5869
</project>

‎integration-faces/src/test/java/org/ocpsoft/rewrite/faces/el/ExpressionLanguageTest.java‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import org.junit.Test;
2424
import org.junit.runner.RunWith;
2525
import org.ocpsoft.rewrite.config.ConfigurationProvider;
26+
import org.ocpsoft.rewrite.faces.resolver.FacesBeanNameResolverBean;
2627
import org.ocpsoft.rewrite.faces.test.FacesBase;
2728
import org.ocpsoft.rewrite.test.HttpAction;
2829
import org.ocpsoft.rewrite.test.RewriteTest;
@@ -40,7 +41,8 @@ public static WebArchive getDeployment()
4041
return FacesBase
4142
.getDeployment()
4243
.addAsWebResource("expression-language.xhtml")
43-
.addClasses(ExpressionLanguageBean.class, ExpressionLanguageConfigProvider.class)
44+
.addClasses(FacesBeanNameResolverBean.class, ExpressionLanguageBean.class,
45+
ExpressionLanguageConfigProvider.class)
4446
.addAsServiceProvider(ConfigurationProvider.class, ExpressionLanguageConfigProvider.class);
4547
}
4648

‎test-harness/src/main/java/org/ocpsoft/rewrite/test/RewriteTest.java‎

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,6 @@ public static WebArchive getDeployment()
4242
public static WebArchive getDeployment(String name)
4343
{
4444
WebArchive archive = getDeploymentNoWebXml(name);
45-
if (isJetty()) {
46-
archive.setWebXML("jetty-web.xml");
47-
}
4845
return archive;
4946
}
5047

@@ -55,12 +52,15 @@ public static WebArchive getDeploymentNoWebXml()
5552

5653
public static WebArchive getDeploymentNoWebXml(String name)
5754
{
58-
55+
if(isJetty() && "ROOT.war".equals(name))
56+
name = ".war";
57+
5958
WebArchive archive = ShrinkWrap
6059
.create(WebArchive.class, name)
6160
.addPackages(true, MockBinding.class.getPackage())
6261
.addAsLibraries(resolveDependencies("org.ocpsoft.logging:logging-api:1.0.1.Final"))
6362
.addAsLibraries(getRewriteArchive())
63+
.addAsLibraries(getContainerArchive())
6464
.addAsLibraries(getCurrentArchive());
6565

6666
// Jetty specific stuff
@@ -75,6 +75,11 @@ public static WebArchive getDeploymentNoWebXml(String name)
7575
archive.add(new StringAsset("com.sun.el.ExpressionFactoryImpl"),
7676
"/WEB-INF/classes/META-INF/services/javax.el.ExpressionFactory");
7777

78+
/*
79+
* Set the JSF implementation
80+
*/
81+
archive.addAsLibraries(resolveDependencies("org.glassfish:javax.faces:jar:2.1.7"));
82+
7883
/*
7984
* Set up container configuration
8085
*/
@@ -99,17 +104,33 @@ protected static boolean isJetty()
99104
}
100105
}
101106

107+
protected static JavaArchive getContainerArchive()
108+
{
109+
110+
JavaArchive archive = ShrinkWrap.create(JavaArchive.class, "rewrite-current-module.jar");
111+
112+
if (isJetty())
113+
{
114+
archive.addAsManifestResource("jetty-web-fragment.xml", "web-fragment.xml");
115+
}
116+
117+
return archive.addAsResource(new StringAsset("placeholder"), "README");
118+
}
119+
102120
protected static JavaArchive getCurrentArchive()
103121
{
104122
File classes = new File("target/classes/org");
105123
File metaInf = new File("target/classes/META-INF");
106124

107125
JavaArchive archive = ShrinkWrap.create(JavaArchive.class, "rewrite-current-module.jar");
108126

109-
if (classes.exists())
110-
archive.addAsResource(classes);
111-
if (metaInf.exists())
112-
archive.addAsResource(metaInf);
127+
if (!classes.getAbsolutePath().contains("impl-servlet"))
128+
{
129+
if (classes.exists())
130+
archive.addAsResource(classes);
131+
if (metaInf.exists())
132+
archive.addAsResource(metaInf);
133+
}
113134

114135
return archive.addAsResource(new StringAsset("placeholder"), "README");
115136
}

‎test-harness/src/main/java/org/ocpsoft/rewrite/test/RewriteTestBase.java‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,10 @@ protected String getBaseURL()
122122

123123
protected String getContextPath()
124124
{
125-
return baseUrl.getPath().replaceAll("^(.*)/$", "$1").replaceAll("ROOT$", "");
125+
String contextPath = baseUrl.getPath();
126+
if (!"/".equals(contextPath))
127+
contextPath = contextPath.replaceAll("^(.*)/$", "$1").replaceAll("ROOT$", "");
128+
return contextPath;
126129
}
127130

128131
protected HtmlAction getWebClient(String path) throws FailingHttpStatusCodeException, IOException

test-harness/src/main/resources/jetty-web.xml renamed to test-harness/src/main/resources/jetty-web-fragment.xml

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
1-
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2-
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3-
version="3.0"
4-
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<web-fragment xmlns="http://java.sun.com/xml/ns/javaee"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
5+
http://java.sun.com/xml/ns/javaee/web-fragment_3_0.xsd"
6+
version="3.0">
7+
8+
<name id="jetty">jetty_activator</name>
9+
<distributable />
510

611
<env-entry>
712
<env-entry-name>name</env-entry-name>
@@ -19,5 +24,8 @@
1924
<listener>
2025
<listener-class>org.jboss.weld.environment.servlet.Listener</listener-class>
2126
</listener>
27+
<listener>
28+
<listener-class>com.sun.faces.config.ConfigureListener</listener-class>
29+
</listener>
2230

23-
</web-app>
31+
</web-fragment>

0 commit comments

Comments
 (0)