|
| 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.outbound; |
| 17 | + |
| 18 | +import static org.junit.Assert.assertEquals; |
| 19 | + |
| 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.Ignore; |
| 24 | +import org.junit.Test; |
| 25 | +import org.junit.runner.RunWith; |
| 26 | +import org.ocpsoft.rewrite.faces.annotation.RewriteFacesAnnotationsTest; |
| 27 | +import org.ocpsoft.rewrite.test.RewriteTest; |
| 28 | +import org.ocpsoft.rewrite.test.RewriteTestBase; |
| 29 | + |
| 30 | +import com.gargoylesoftware.htmlunit.html.DomElement; |
| 31 | +import com.gargoylesoftware.htmlunit.html.HtmlPage; |
| 32 | + |
| 33 | +@RunWith(Arquillian.class) |
| 34 | +public class OutboundSpecialCasesTest extends RewriteTestBase |
| 35 | +{ |
| 36 | + |
| 37 | + @Deployment(testable = false) |
| 38 | + public static WebArchive getDeployment() |
| 39 | + { |
| 40 | + return RewriteTest.getDeployment() |
| 41 | + .addAsLibrary(RewriteFacesAnnotationsTest.getRewriteFacesArchive()) |
| 42 | + .addAsWebInfResource("faces-config.xml") |
| 43 | + .addAsWebResource("outbound-special-cases.xhtml", "outbound.xhtml"); |
| 44 | + } |
| 45 | + |
| 46 | + @Test |
| 47 | + public void testJavaScriptNotRewritten() throws Exception |
| 48 | + { |
| 49 | + HtmlPage page = getWebClient("/faces/outbound.xhtml").getPage(); |
| 50 | + DomElement link = page.getElementById("javascript"); |
| 51 | + assertEquals("javascript:void(0)", link.getAttribute("href")); |
| 52 | + } |
| 53 | + |
| 54 | + @Test |
| 55 | + public void testAnchorNotRewritten() throws Exception |
| 56 | + { |
| 57 | + HtmlPage page = getWebClient("/faces/outbound.xhtml").getPage(); |
| 58 | + DomElement link = page.getElementById("anchor"); |
| 59 | + assertEquals("#foobar", link.getAttribute("href")); |
| 60 | + } |
| 61 | + |
| 62 | + @Test |
| 63 | + @Ignore // issue #139 |
| 64 | + public void testEmptyAnchorNotRewritten() throws Exception |
| 65 | + { |
| 66 | + HtmlPage page = getWebClient("/faces/outbound.xhtml").getPage(); |
| 67 | + DomElement link = page.getElementById("emptyAnchor"); |
| 68 | + assertEquals("#", link.getAttribute("href")); |
| 69 | + } |
| 70 | + |
| 71 | +} |
0 commit comments