1+ /*
2+ * Copyright 2011 <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a>
3+ *
4+ * Licensed under the Apache License, Version 2.0 (the "License");
5+ * you may not use this file except in compliance with the License.
6+ * You may obtain a copy of the License at
7+ *
8+ * http://www.apache.org/licenses/LICENSE-2.0
9+ *
10+ * Unless required by applicable law or agreed to in writing, software
11+ * distributed under the License is distributed on an "AS IS" BASIS,
12+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ * See the License for the specific language governing permissions and
14+ * limitations under the License.
15+ */
16+ package org .ocpsoft .rewrite .faces .outcome ;
17+
18+ import static org .hamcrest .Matchers .endsWith ;
19+ import static org .junit .Assert .assertThat ;
20+
21+ import org .jboss .arquillian .container .test .api .Deployment ;
22+ import org .jboss .arquillian .junit .Arquillian ;
23+ import org .jboss .shrinkwrap .api .spec .WebArchive ;
24+ import org .junit .Ignore ;
25+ import org .junit .Test ;
26+ import org .junit .runner .RunWith ;
27+ import org .ocpsoft .rewrite .config .ConfigurationProvider ;
28+ import org .ocpsoft .rewrite .faces .test .FacesBase ;
29+ import org .ocpsoft .rewrite .test .RewriteTestBase ;
30+
31+ import com .gargoylesoftware .htmlunit .html .HtmlPage ;
32+
33+ @ RunWith (Arquillian .class )
34+ public class OutcomeEncodingTest extends RewriteTestBase
35+ {
36+
37+ @ Deployment (testable = false )
38+ public static WebArchive getDeployment ()
39+ {
40+ return FacesBase .getDeployment ()
41+ .addClass (OutcomeEncodingBean .class )
42+ .addAsServiceProviderAndClasses (ConfigurationProvider .class , OutcomeEncodingConfig .class )
43+ .addAsWebResource ("outcome-encoding-start.xhtml" , "start.xhtml" )
44+ .addAsWebResource ("outcome-encoding-page.xhtml" , "page.xhtml" );
45+ }
46+
47+ @ Test
48+ public void testOutcomeRedirectSimple () throws Exception
49+ {
50+
51+ HtmlPage startPage = getWebClient ("/start" ).getPage ();
52+ HtmlPage secondPage = startPage .getElementById ("form:redirectSimple" ).click ();
53+
54+ assertThat (secondPage .getUrl ().toString (), endsWith ("/page/foo?query=foo" ));
55+
56+ }
57+
58+ @ Test
59+ // TODO: Fix this
60+ @ Ignore
61+ public void testOutcomeRedirectWithSpace () throws Exception
62+ {
63+
64+ HtmlPage startPage = getWebClient ("/start" ).getPage ();
65+ HtmlPage secondPage = startPage .getElementById ("form:redirectWithSpace" ).click ();
66+
67+ assertThat (secondPage .getUrl ().toString (), endsWith ("/page/foo%20bar?query=foo+bar" ));
68+
69+ }
70+
71+ @ Test
72+ // TODO: Fix this
73+ @ Ignore
74+ public void testOutcomeRedirectWithEqual () throws Exception
75+ {
76+
77+ HtmlPage startPage = getWebClient ("/start" ).getPage ();
78+ HtmlPage secondPage = startPage .getElementById ("form:redirectWithEqual" ).click ();
79+
80+ assertThat (secondPage .getUrl ().toString (), endsWith ("/page/foo%3Dbar&query=foo%3Dbar" ));
81+
82+ }
83+
84+ @ Test
85+ // TODO: Fix this
86+ @ Ignore
87+ public void testOutcomeRedirectWithAmpersand () throws Exception
88+ {
89+
90+ HtmlPage startPage = getWebClient ("/start" ).getPage ();
91+ HtmlPage secondPage = startPage .getElementById ("form:redirectWithAmpersand" ).click ();
92+
93+ assertThat (secondPage .getUrl ().toString (), endsWith ("/page/foo%26bar&query=foo%26bar" ));
94+
95+ }
96+
97+ }
0 commit comments