Skip to content

Commit ab683a8

Browse files
committed
Added test to reproduce issue ocpsoft#139
1 parent 8d09392 commit ab683a8

3 files changed

Lines changed: 89 additions & 0 deletions

File tree

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
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+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0"?>
2+
<faces-config version="2.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xi="http://www.w3.org/2001/XInclude"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd">
4+
<!-- empty -->
5+
</faces-config>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2+
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html"
3+
xmlns:f="http://java.sun.com/jsf/core">
4+
<body>
5+
6+
<h:outputLink id="javascript" value="javascript:void(0)">click</h:outputLink>
7+
8+
<h:outputLink id="anchor" value="#foobar">click</h:outputLink>
9+
10+
<h:outputLink id="emptyAnchor" value="#">click</h:outputLink>
11+
12+
</body>
13+
</html>

0 commit comments

Comments
 (0)