forked from ocpsoft/rewrite
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes Issue ocpsoft#110 - View IDs with hard-coded query parameters w…
…ere working in PF3.x, but no longer work in Rewrite
- Loading branch information
1 parent
92e67ee
commit 07fd4cc
Showing
5 changed files
with
223 additions
and
8 deletions.
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
...tests/src/test/java/org/ocpsoft/rewrite/prettyfaces/outbound/ViewHardcodedParamsBean.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package org.ocpsoft.rewrite.prettyfaces.outbound; | ||
|
||
import javax.enterprise.context.RequestScoped; | ||
import javax.inject.Named; | ||
|
||
@Named("outbound") | ||
@RequestScoped | ||
public class ViewHardcodedParamsBean | ||
{ | ||
|
||
public String hCommandLink() { | ||
return "view-hardcoded-params.jsf?faces-redirect=true¶m=value"; | ||
} | ||
|
||
public String hCommandLinkExtra() { | ||
return "view-hardcoded-params.jsf?faces-redirect=true¶m=value&extraParam=extraValue"; | ||
} | ||
} |
86 changes: 86 additions & 0 deletions
86
...c/test/java/org/ocpsoft/rewrite/prettyfaces/outbound/ViewHardcodedParamsOutboundTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
package org.ocpsoft.rewrite.prettyfaces.outbound; | ||
|
||
import org.jboss.arquillian.container.test.api.Deployment; | ||
import org.jboss.arquillian.drone.api.annotation.Drone; | ||
import org.jboss.arquillian.junit.Arquillian; | ||
import org.jboss.shrinkwrap.api.spec.WebArchive; | ||
import org.junit.Assert; | ||
import org.junit.Assume; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.ocpsoft.rewrite.prettyfaces.PrettyFacesTestBase; | ||
import org.ocpsoft.rewrite.test.RewriteTestBase; | ||
import org.openqa.selenium.By; | ||
import org.openqa.selenium.WebDriver; | ||
import org.openqa.selenium.htmlunit.HtmlUnitDriver; | ||
|
||
@RunWith(Arquillian.class) | ||
public class ViewHardcodedParamsOutboundTest extends RewriteTestBase | ||
{ | ||
|
||
@Deployment(testable = false) | ||
public static WebArchive createDeployment() | ||
{ | ||
return PrettyFacesTestBase.getDeployment() | ||
.addClass(ViewHardcodedParamsBean.class) | ||
.addAsWebResource("outbound/view-hardcoded-params.xhtml", "index.xhtml") | ||
.addAsWebResource("outbound/view-hardcoded-params.xhtml", "view-hardcoded-params.xhtml") | ||
.addAsWebInfResource("outbound/view-hardcoded-params-pretty-config.xml", "pretty-config.xml"); | ||
} | ||
|
||
@Drone | ||
WebDriver browser; | ||
|
||
@Test | ||
public void testHLink() throws Exception | ||
{ | ||
browser.get(getBaseURL() + getContextPath() + "/index"); | ||
String hlink = browser.findElement(By.id("hLink")).getAttribute("href"); | ||
Assert.assertTrue(hlink.endsWith("/view-hardcoded-params")); | ||
} | ||
|
||
@Test | ||
public void testHLinkExtraParams() throws Exception | ||
{ | ||
browser.get(getBaseURL() + getContextPath() + "/index"); | ||
String hlink = browser.findElement(By.id("hLink-extra")).getAttribute("href"); | ||
Assert.assertTrue(hlink.endsWith("/view-hardcoded-params?extraParam=extraValue")); | ||
} | ||
|
||
@Test | ||
public void testPLink() throws Exception | ||
{ | ||
browser.get(getBaseURL() + getContextPath() + "/index"); | ||
String url = browser.findElement(By.id("prettyLink")).getAttribute("href"); | ||
Assert.assertTrue(url.endsWith("/view-hardcoded-params")); | ||
} | ||
|
||
@Test | ||
public void testPLinkExtraParams() throws Exception | ||
{ | ||
browser.get(getBaseURL() + getContextPath() + "/index"); | ||
String url = browser.findElement(By.id("prettyLink-extra")).getAttribute("href"); | ||
Assert.assertTrue(url.endsWith("/view-hardcoded-params?extraParam=extraValue")); | ||
} | ||
|
||
@Test | ||
public void testHCommandLink() throws Exception | ||
{ | ||
Assume.assumeTrue(browser instanceof HtmlUnitDriver); | ||
((HtmlUnitDriver)browser).setJavascriptEnabled(true); | ||
browser.get(getBaseURL() + getContextPath() + "/index"); | ||
browser.findElement(By.id("hCommandLink")).click(); | ||
Assert.assertTrue(browser.getCurrentUrl().endsWith("/view-hardcoded-params")); | ||
} | ||
|
||
@Test | ||
public void testHCommandLinkExtraParams() throws Exception | ||
{ | ||
Assume.assumeTrue(browser instanceof HtmlUnitDriver); | ||
((HtmlUnitDriver)browser).setJavascriptEnabled(true); | ||
browser.get(getBaseURL() + getContextPath() + "/index"); | ||
browser.findElement(By.id("hCommandLink-extra")).click(); | ||
Assert.assertTrue(browser.getCurrentUrl().endsWith("/view-hardcoded-params?extraParam=extraValue")); | ||
} | ||
|
||
} |
13 changes: 13 additions & 0 deletions
13
config-prettyfaces-tests/src/test/resources/outbound/view-hardcoded-params-pretty-config.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<pretty-config xmlns="http://ocpsoft.com/prettyfaces/3.3.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
|
||
<url-mapping id="index"> | ||
<pattern value="/index" /> | ||
<view-id value="/index.jsf" /> | ||
</url-mapping> | ||
|
||
<url-mapping id="view-hardcoded-params"> | ||
<pattern value="/view-hardcoded-params" /> | ||
<view-id value="/view-hardcoded-params.jsf?param=value" /> | ||
</url-mapping> | ||
|
||
</pretty-config> |
44 changes: 44 additions & 0 deletions
44
config-prettyfaces-tests/src/test/resources/outbound/view-hardcoded-params.xhtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" | ||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | ||
<html xmlns="http://www.w3.org/1999/xhtml" | ||
xmlns:f="http://java.sun.com/jsf/core" | ||
xmlns:h="http://java.sun.com/jsf/html" | ||
xmlns:pretty="http://ocpsoft.com/prettyfaces" | ||
xmlns:ui="http://java.sun.com/jsf/facelets"> | ||
|
||
<head> | ||
<title>Outbound Page</title> | ||
</head> | ||
|
||
<body> | ||
|
||
<h:link id="hLink" value="hlink" outcome="view-hardcoded-params.jsf?param=value"/> | ||
<br/> | ||
|
||
<h:link id="hLink-extra" value="hlink-extra" outcome="view-hardcoded-params.jsf?param=value&extraParam=extraValue"/> | ||
<br/> | ||
|
||
<pretty:link id="prettyLink" mappingId="view-hardcoded-params"> | ||
prettylink | ||
</pretty:link> | ||
<br/> | ||
|
||
<pretty:link id="prettyLink-extra" mappingId="view-hardcoded-params"> | ||
<f:param name="extraParam" value="extraValue"/> | ||
prettylink-extra | ||
</pretty:link> | ||
<br/> | ||
|
||
<h:form prependId="false"> | ||
|
||
<h:commandLink id="hCommandLink" action="#{outbound.hCommandLink}" value="hCommandLink"/> | ||
<br/> | ||
|
||
<h:commandLink id="hCommandLink-extra" action="#{outbound.hCommandLinkExtra}" value="hCommandLink-extra"/> | ||
<br/> | ||
|
||
</h:form> | ||
|
||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters