Skip to content

Commit e632542

Browse files
committed
Some more tests for the interaction problems
1 parent 1f5aa7d commit e632542

3 files changed

Lines changed: 81 additions & 4 deletions

File tree

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package com.ocpsoft.pretty.faces.test.interaction;
2+
3+
import javax.faces.bean.ManagedBean;
4+
import javax.faces.bean.RequestScoped;
5+
6+
@ManagedBean
7+
@RequestScoped
8+
public class InteractionDynaViewBean
9+
{
10+
11+
private String value;
12+
13+
public String viewId()
14+
{
15+
return "/" + value + ".jsf";
16+
}
17+
18+
public String getValue()
19+
{
20+
return value;
21+
}
22+
23+
public void setValue(String value)
24+
{
25+
this.value = value;
26+
}
27+
28+
}

‎tests-jsf2/src/test/java/com/ocpsoft/pretty/faces/test/interaction/RewriteEngineUrlMappingInteractionTest.java‎

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ public class RewriteEngineUrlMappingInteractionTest extends PrettyFacesTestBase
3636
public static WebArchive createDeployment()
3737
{
3838
return PrettyFacesTestBase.createDeployment()
39+
.addClass(InteractionDynaViewBean.class)
3940
.addResource("interaction/interaction-page.xhtml", "page.xhtml")
4041
.addWebResource("interaction/interaction-pretty-config.xml", "pretty-config.xml");
4142
}
@@ -44,14 +45,26 @@ public static WebArchive createDeployment()
4445
* Accessing the page using the URL mapping
4546
*/
4647
@Test @Ignore
47-
public void testUrlMapping() throws Exception
48+
public void testSimpleUrlMapping() throws Exception
4849
{
4950
JSFSession jsfSession = new JSFSession("/page");
5051
JSFClientSession client = jsfSession.getJSFClientSession();
5152
assertTrue(client.getContentPage().getUrl().toString().endsWith("/page"));
5253
assertTrue(client.getPageAsText().contains("The page rendered fine!"));
5354
}
5455

56+
/**
57+
* Accessing the page using a dynaview
58+
*/
59+
@Test @Ignore
60+
public void testDynaViewUrlMapping() throws Exception
61+
{
62+
JSFSession jsfSession = new JSFSession("/dyna/page");
63+
JSFClientSession client = jsfSession.getJSFClientSession();
64+
assertTrue(client.getContentPage().getUrl().toString().endsWith("/dyna/page"));
65+
assertTrue(client.getPageAsText().contains("The page rendered fine!"));
66+
}
67+
5568
/**
5669
* Rewrite rule forwards to the URL mapping
5770
*/
@@ -76,6 +89,30 @@ public void testRewriteRedirectsToUrlMapping() throws Exception
7689
assertTrue(client.getPageAsText().contains("The page rendered fine!"));
7790
}
7891

92+
/**
93+
* Rewrite rule forwards to the dynaview
94+
*/
95+
@Test
96+
public void testRewriteForwardsToDynaviewMapping() throws Exception
97+
{
98+
JSFSession jsfSession = new JSFSession("/rewrite-forwards-to-dynaview");
99+
JSFClientSession client = jsfSession.getJSFClientSession();
100+
assertTrue(client.getContentPage().getUrl().toString().endsWith("/rewrite-forwards-to-dynaview"));
101+
assertTrue(client.getPageAsText().contains("The page rendered fine!"));
102+
}
103+
104+
/**
105+
* Rewrite rule redirects to the dynaview
106+
*/
107+
@Test @Ignore
108+
public void testRewriteRedirectsToDynaviewMapping() throws Exception
109+
{
110+
JSFSession jsfSession = new JSFSession("/rewrite-redirects-to-dynaview");
111+
JSFClientSession client = jsfSession.getJSFClientSession();
112+
assertTrue(client.getContentPage().getUrl().toString().endsWith("/dyna/page"));
113+
assertTrue(client.getPageAsText().contains("The page rendered fine!"));
114+
}
115+
79116
/**
80117
* Directly accessing the view-id should redirect to the pretty URL
81118
*/

‎tests-jsf2/src/test/resources/interaction/interaction-pretty-config.xml‎

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,25 @@
77
<view-id>/page.jsf</view-id>
88
</url-mapping>
99

10+
<!-- Dynaview URL mapping -->
11+
<url-mapping>
12+
<pattern value="/dyna/#{interactionDynaViewBean.value}"></pattern>
13+
<view-id>#{interactionDynaViewBean.viewId}</view-id>
14+
</url-mapping>
15+
16+
<!-- Directly accessing view-ids should redirect to the pretty URL -->
17+
<rewrite match="/(.*)\.jsf" substitute="/$1" redirect="302"/>
18+
1019
<!-- Some URL that forwards to the mapping -->
1120
<rewrite match="/rewrite-forwards-to-page-mapping" substitute="/page" redirect="chain" />
1221

1322
<!-- Some URL that redirects to the mapping -->
1423
<rewrite match="/rewrite-redirects-to-page-mapping" substitute="/page" redirect="302" />
15-
16-
<!-- Directly accessing view-ids should redirect to the pretty URL -->
17-
<rewrite match="(.*)\.jsf" substitute="/$1" redirect="302"/>
24+
25+
<!-- Some URL that forwards to the dynaview -->
26+
<rewrite match="/rewrite-forwards-to-dynaview" substitute="/dyna/page" redirect="chain" />
27+
28+
<!-- Some URL that redirects to the dynaview -->
29+
<rewrite match="/rewrite-redirects-to-dynaview" substitute="/dyna/page" redirect="302" />
1830

1931
</pretty-config>

0 commit comments

Comments
 (0)