|
| 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 org.ocpsoft.rewrite.prettyfaces.context; |
| 18 | + |
| 19 | +import org.apache.http.client.methods.HttpGet; |
| 20 | +import org.jboss.arquillian.container.test.api.Deployment; |
| 21 | +import org.jboss.arquillian.junit.Arquillian; |
| 22 | +import org.jboss.shrinkwrap.api.spec.WebArchive; |
| 23 | +import org.junit.Assert; |
| 24 | +import org.junit.Test; |
| 25 | +import org.junit.runner.RunWith; |
| 26 | +import org.ocpsoft.rewrite.prettyfaces.PrettyFacesTestBase; |
| 27 | +import org.ocpsoft.rewrite.test.HttpAction; |
| 28 | +import org.ocpsoft.rewrite.test.RewriteTest; |
| 29 | + |
| 30 | +@RunWith(Arquillian.class) |
| 31 | +public class PrettyContextTest extends RewriteTest |
| 32 | +{ |
| 33 | + @Deployment(testable = false) |
| 34 | + public static WebArchive getDeployment() |
| 35 | + { |
| 36 | + WebArchive deployment = PrettyFacesTestBase.getDeployment() |
| 37 | + .addAsWebResource("context/index.xhtml", "index.xhtml") |
| 38 | + .addAsWebInfResource("context/pretty-config.xml", "pretty-config.xml"); |
| 39 | + |
| 40 | + System.out.println(deployment.toString(true)); |
| 41 | + |
| 42 | + return deployment; |
| 43 | + } |
| 44 | + |
| 45 | + @Test |
| 46 | + public void testIsPrettyRequest() throws Exception |
| 47 | + { |
| 48 | + HttpAction<HttpGet> action = get("/"); |
| 49 | + Assert.assertEquals(200, action.getStatusCode()); |
| 50 | + Assert.assertTrue(action.getResponseContent().contains("url=/")); |
| 51 | + Assert.assertTrue(action.getResponseContent().contains("prettyRequest=true")); |
| 52 | + } |
| 53 | + |
| 54 | + @Test |
| 55 | + public void testIsNotPrettyRequest() throws Exception |
| 56 | + { |
| 57 | + HttpAction<HttpGet> action = get("/index.jsf"); |
| 58 | + Assert.assertEquals(200, action.getStatusCode()); |
| 59 | + Assert.assertTrue(action.getResponseContent().contains("url=/index.jsf")); |
| 60 | + Assert.assertTrue(action.getResponseContent().contains("prettyRequest=false")); |
| 61 | + } |
| 62 | + |
| 63 | + @Test |
| 64 | + public void testJSessionIdRemovedAutomatically() throws Exception |
| 65 | + { |
| 66 | + HttpAction<HttpGet> action = get("/;jsessionid=F97KJHsf9876sdf?foo=bar"); |
| 67 | + Assert.assertEquals(200, action.getStatusCode()); |
| 68 | + Assert.assertTrue(action.getResponseContent().contains("url=/")); |
| 69 | + Assert.assertTrue(action.getResponseContent().contains("query=?foo=bar")); |
| 70 | + Assert.assertTrue(action.getResponseContent().contains("prettyRequest=true")); |
| 71 | + } |
| 72 | + |
| 73 | + @Test |
| 74 | + public void testJSessionIdRemovedAutomaticallyCluster() throws Exception |
| 75 | + { |
| 76 | + HttpAction<HttpGet> action = get("/;jsessionid=2437ae534134eeae.server1?foo=bar"); |
| 77 | + Assert.assertEquals(200, action.getStatusCode()); |
| 78 | + Assert.assertTrue(action.getResponseContent().contains("url=/")); |
| 79 | + Assert.assertTrue(action.getResponseContent().contains("query=?foo=bar")); |
| 80 | + Assert.assertTrue(action.getResponseContent().contains("prettyRequest=true")); |
| 81 | + } |
| 82 | + |
| 83 | + @Test |
| 84 | + public void testJSessionIdRemovedAutomaticallyGAE() throws Exception |
| 85 | + { |
| 86 | + HttpAction<HttpGet> action = get("/;jsessionid=1E-y6jzfx53ou9wymGmcfw?foo=bar"); |
| 87 | + Assert.assertEquals(200, action.getStatusCode()); |
| 88 | + Assert.assertTrue(action.getResponseContent().contains("url=/")); |
| 89 | + Assert.assertTrue(action.getResponseContent().contains("query=?foo=bar")); |
| 90 | + Assert.assertTrue(action.getResponseContent().contains("prettyRequest=true")); |
| 91 | + } |
| 92 | + |
| 93 | +} |
0 commit comments