Skip to content

Commit 0bbfce6

Browse files
committed
updated docs for inbound rewriting options, added test for custom path parameter regexes to verify issue #83 (not an issue)
1 parent 36e0afa commit 0bbfce6

3 files changed

Lines changed: 91 additions & 1 deletion

File tree

‎docs/src/main/docbook/en-US/Rewriting_inbound.xml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@
115115
</row>
116116
<row>
117117
<entry>redirect</entry>
118-
<entry>301, 301, chain</entry>
118+
<entry>301, 302, chain</entry>
119119
<entry>
120120
(Default: 301) Specifies which type of redirect should be issued when this rule triggers.
121121
If 'chain' is specified, a Servlet forward will be issued to the new URL instead of a
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
/*
2+
* JBoss, Home of Professional Open Source
3+
* Copyright 2009, Red Hat Middleware LLC, and individual contributors
4+
* by the @authors tag. See the copyright.txt in the distribution for a
5+
* full listing of individual contributors.
6+
*
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
package com.ocpsoft.pretty.faces.test;
18+
19+
import static org.junit.Assert.assertEquals;
20+
21+
import javax.faces.context.FacesContext;
22+
23+
import org.jboss.arquillian.MavenArtifactResolver;
24+
import org.jboss.arquillian.api.Deployment;
25+
import org.jboss.arquillian.junit.Arquillian;
26+
import org.jboss.jsfunit.jsfsession.JSFServerSession;
27+
import org.jboss.jsfunit.jsfsession.JSFSession;
28+
import org.jboss.shrinkwrap.api.Archive;
29+
import org.jboss.shrinkwrap.api.ShrinkWrap;
30+
import org.jboss.shrinkwrap.api.spec.WebArchive;
31+
import org.junit.Test;
32+
import org.junit.runner.RunWith;
33+
34+
import com.ocpsoft.pretty.PrettyContext;
35+
36+
@RunWith(Arquillian.class)
37+
public class PathParametersTest
38+
{
39+
@Deployment
40+
public static Archive<?> createDeployment()
41+
{
42+
return ShrinkWrap.create(WebArchive.class, "test.war")
43+
.addResource("basic/index.xhtml", "index.xhtml")
44+
.addWebResource("faces-config.xml")
45+
.addWebResource("pretty-config.xml")
46+
.addLibrary(MavenArtifactResolver.resolve(
47+
"com.ocpsoft:prettyfaces-jsf2:3.1.1-SNAPSHOT"
48+
))
49+
.setWebXML("jsf-web.xml");
50+
}
51+
52+
@Test
53+
public void testNamedPathParameterWithDefaultRegex() throws Exception
54+
{
55+
String initialPage = "/default/1234";
56+
JSFSession jsfSession = new JSFSession(initialPage);
57+
JSFServerSession server = jsfSession.getJSFServerSession();
58+
FacesContext context = server.getFacesContext();
59+
60+
PrettyContext prettyContext = PrettyContext.getCurrentInstance(context);
61+
62+
assertEquals(initialPage, prettyContext.getRequestURL().toString());
63+
assertEquals("1234", context.getExternalContext().getRequestParameterMap().get("digits"));
64+
}
65+
66+
@Test
67+
public void testNamedPathParameterWithCustomRegex() throws Exception
68+
{
69+
String initialPage = "/digits/1234";
70+
JSFSession jsfSession = new JSFSession(initialPage);
71+
JSFServerSession server = jsfSession.getJSFServerSession();
72+
FacesContext context = server.getFacesContext();
73+
74+
PrettyContext prettyContext = PrettyContext.getCurrentInstance(context);
75+
76+
assertEquals(initialPage, prettyContext.getRequestURL().toString());
77+
assertEquals("1234", context.getExternalContext().getRequestParameterMap().get("digits"));
78+
}
79+
80+
}

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,16 @@
1313
<view-id>/form.jsf</view-id>
1414
</url-mapping>
1515

16+
<url-mapping id="index">
17+
<pattern value="/default/#{digits}"></pattern>
18+
<view-id>/index.jsf</view-id>
19+
</url-mapping>
20+
21+
<url-mapping id="index">
22+
<pattern value="/digits/#{/\\d+/ digits}"></pattern>
23+
<view-id>/index.jsf</view-id>
24+
</url-mapping>
25+
1626
<!-- Begin Encoding Mappings -->
1727
<url-mapping id="encoding">
1828
<pattern value="/encoding/#{encodingBean.pathText}" />

0 commit comments

Comments
 (0)