[seam-commits] Seam SVN: r15062 - in branches/community/Seam_2_3/seam-integration-tests: src/test/java/org/jboss/seam/test/integration and 1 other directories.
seam-commits at lists.jboss.org
seam-commits at lists.jboss.org
Tue Aug 21 13:31:57 EDT 2012
Author: maschmid
Date: 2012-08-21 13:31:57 -0400 (Tue, 21 Aug 2012)
New Revision: 15062
Added:
branches/community/Seam_2_3/seam-integration-tests/src/test/java/org/jboss/seam/test/integration/faces/RestoreViewComponentAccessTest.java
branches/community/Seam_2_3/seam-integration-tests/src/test/java/org/jboss/seam/test/integration/faces/SequenceAction.java
Modified:
branches/community/Seam_2_3/seam-integration-tests/pom.xml
branches/community/Seam_2_3/seam-integration-tests/src/test/java/org/jboss/seam/test/integration/Deployments.java
Log:
create RestoreViewComponentAccessTest to test issues accessing seam components from JSF validator attributes, related to JBSEAM-4976
Modified: branches/community/Seam_2_3/seam-integration-tests/pom.xml
===================================================================
--- branches/community/Seam_2_3/seam-integration-tests/pom.xml 2012-08-21 07:55:31 UTC (rev 15061)
+++ branches/community/Seam_2_3/seam-integration-tests/pom.xml 2012-08-21 17:31:57 UTC (rev 15062)
@@ -134,6 +134,17 @@
</exclusion>
</exclusions>
</dependency>
+
+ <dependency>
+ <groupId>org.jboss.seam</groupId>
+ <artifactId>jboss-seam-ui</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>org.jboss.seam</groupId>
+ <artifactId>jboss-seam-jul</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
<dependency>
<groupId>org.hibernate</groupId>
@@ -284,6 +295,7 @@
<dependency>
<groupId>org.jboss.as</groupId>
<artifactId>jboss-as-arquillian-container-managed</artifactId>
+ <scope>test</scope>
</dependency>
</dependencies>
<build>
@@ -339,6 +351,7 @@
<dependency>
<groupId>org.jboss.as</groupId>
<artifactId>jboss-as-arquillian-container-remote</artifactId>
+ <scope>test</scope>
</dependency>
</dependencies>
<build>
Modified: branches/community/Seam_2_3/seam-integration-tests/src/test/java/org/jboss/seam/test/integration/Deployments.java
===================================================================
--- branches/community/Seam_2_3/seam-integration-tests/src/test/java/org/jboss/seam/test/integration/Deployments.java 2012-08-21 07:55:31 UTC (rev 15061)
+++ branches/community/Seam_2_3/seam-integration-tests/src/test/java/org/jboss/seam/test/integration/Deployments.java 2012-08-21 17:31:57 UTC (rev 15062)
@@ -41,6 +41,7 @@
"<dependencies>" +
"<module name=\"org.javassist\"/>" +
"<module name=\"org.dom4j\"/>" +
+ "<module name=\"org.apache.commons.collections\"/>" +
"</dependencies>" +
"</deployment>" +
"</jboss-deployment-structure>"), "jboss-deployment-structure.xml")
Added: branches/community/Seam_2_3/seam-integration-tests/src/test/java/org/jboss/seam/test/integration/faces/RestoreViewComponentAccessTest.java
===================================================================
--- branches/community/Seam_2_3/seam-integration-tests/src/test/java/org/jboss/seam/test/integration/faces/RestoreViewComponentAccessTest.java (rev 0)
+++ branches/community/Seam_2_3/seam-integration-tests/src/test/java/org/jboss/seam/test/integration/faces/RestoreViewComponentAccessTest.java 2012-08-21 17:31:57 UTC (rev 15062)
@@ -0,0 +1,139 @@
+package org.jboss.seam.test.integration.faces;
+
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertFalse;
+
+
+import java.net.URL;
+
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.container.test.api.OverProtocol;
+import org.jboss.arquillian.container.test.api.RunAsClient;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.arquillian.test.api.ArquillianResource;
+import org.jboss.seam.test.integration.Deployments;
+import org.jboss.shrinkwrap.api.asset.Asset;
+import org.jboss.shrinkwrap.api.asset.StringAsset;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import com.gargoylesoftware.htmlunit.WebClient;
+import com.gargoylesoftware.htmlunit.html.HtmlPage;
+import com.gargoylesoftware.htmlunit.html.HtmlTextInput;
+
+ at RunWith(Arquillian.class)
+ at RunAsClient
+public class RestoreViewComponentAccessTest
+{
+ private final WebClient client = new WebClient();
+ private static final String[] testScopes = {"page", "conversation", "session", "application"};
+ private static final String componentNamePrefix = "sequence_";
+
+ @ArquillianResource
+ URL contextPath;
+
+ @Deployment(name="RestoreViewComponentAccessTest")
+ @OverProtocol("Servlet 3.0")
+ public static WebArchive createDeployment()
+ {
+
+ // This is a client test, use a real (non-mocked) Seam deployment
+ WebArchive war = Deployments.realSeamDeployment()
+ .addClasses(SequenceAction.class);
+
+ war.delete("WEB-INF/pages.xml");
+ war.delete("WEB-INF/components.xml");
+
+ for (String scope : testScopes) {
+ war.addAsWebResource(createView(scope), "test_" + scope + ".xhtml");
+ }
+
+ StringBuilder componentsXmlBuilder = new StringBuilder();
+
+ componentsXmlBuilder.append("<components xmlns=\"http://jboss.org/schema/seam/components\">");
+
+ for (String scope : testScopes) {
+ String cname = componentNamePrefix + scope;
+ componentsXmlBuilder.append("<component name='" + cname + "' scope='" + scope + "' class='org.jboss.seam.test.integration.faces.SequenceAction' />");
+ }
+
+ componentsXmlBuilder.append("</components>");
+
+ war.addAsWebInfResource(new StringAsset(componentsXmlBuilder.toString()), "components.xml");
+
+ war.addAsWebInfResource(new StringAsset(
+ "<pages xmlns=\"http://jboss.org/schema/seam/pages\""+
+ " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">"+
+ "<page view-id='/test_conversation.xhtml'>" +
+ "<begin-conversation join='true'/>" +
+ "</page>" +
+ "</pages>"), "pages.xml");
+
+ return war;
+ }
+
+ private static Asset createView(String scope) {
+ String cname = componentNamePrefix + scope;
+ return new StringAsset(
+ "<html xmlns=\"http://www.w3.org/1999/xhtml\"" +
+ " xmlns:h=\"http://java.sun.com/jsf/html\"" +
+ " xmlns:f=\"http://java.sun.com/jsf/core\"" +
+ " xmlns:s=\"http://jboss.org/schema/seam/taglib\"" +
+ " xmlns:ui=\"http://java.sun.com/jsf/facelets\">" +
+ "<h:head></h:head>" +
+ "<h:body>" +
+ "<h:form id='form'>" +
+ "<h:messages/>" +
+ "<h:outputText id='output' value='Sequence: #{" + cname + ".output}'/>" +
+ "<h:inputText id='input' value='#{" + cname + ".input}'>" +
+ "<f:validateLongRange minimum='#{" + cname + ".minimum}' />" +
+ "</h:inputText>" +
+ "<h:commandButton id='append' value='Append' action='#{" + cname + ".append}'/>" +
+ "</h:form>" +
+ "</h:body>" +
+ "</html>");
+ }
+
+
+ public void testBase(String scope) throws Exception {
+ HtmlPage page = client.getPage(contextPath + "test_" + scope + ".seam");
+ assertTrue(page.getBody().getTextContent().contains("Sequence: "));
+
+ ((HtmlTextInput)page.getElementById("form:input")).setText("1");
+ page = page.getElementById("form:append").click();
+
+ assertTrue(page.getBody().getTextContent().contains("Sequence: 1"));
+
+ ((HtmlTextInput)page.getElementById("form:input")).setText("2");
+ page = page.getElementById("form:append").click();
+
+ assertTrue(page.getBody().getTextContent().contains("Sequence: 1, 2"));
+
+ ((HtmlTextInput)page.getElementById("form:input")).setText("1");
+ page = page.getElementById("form:append").click();
+
+ assertFalse(page.getBody().getTextContent().contains("Sequence: 1, 2, 1"));
+ assertTrue(page.getBody().getTextContent().contains("value must be greater than or equal to 2"));
+ }
+
+ @Test
+ public void testPage() throws Exception {
+ testBase("page");
+ }
+
+ @Test
+ public void testConversation() throws Exception {
+ testBase("conversation");
+ }
+
+ @Test
+ public void testSession() throws Exception {
+ testBase("session");
+ }
+
+ @Test
+ public void testApplication() throws Exception {
+ testBase("application");
+ }
+}
Added: branches/community/Seam_2_3/seam-integration-tests/src/test/java/org/jboss/seam/test/integration/faces/SequenceAction.java
===================================================================
--- branches/community/Seam_2_3/seam-integration-tests/src/test/java/org/jboss/seam/test/integration/faces/SequenceAction.java (rev 0)
+++ branches/community/Seam_2_3/seam-integration-tests/src/test/java/org/jboss/seam/test/integration/faces/SequenceAction.java 2012-08-21 17:31:57 UTC (rev 15062)
@@ -0,0 +1,52 @@
+package org.jboss.seam.test.integration.faces;
+
+import java.io.Serializable;
+import java.util.Deque;
+import java.util.LinkedList;
+
+import org.jboss.seam.annotations.Create;
+
+public class SequenceAction implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ private Deque<Long> sequence;
+ private Long input;
+
+ @Create
+ public void create() {
+ System.out.println("XXX: create");
+ sequence = new LinkedList<Long>();
+ }
+
+ public String getOutput() {
+ StringBuilder sb = new StringBuilder();
+ for (Long n : sequence) {
+ sb.append(n);
+ sb.append(", ");
+ }
+
+ return sb.toString();
+ }
+
+ public void append() {
+ sequence.add(input);
+ }
+
+ public Long getInput()
+ {
+ return input;
+ }
+
+ public void setInput(Long input)
+ {
+ this.input = input;
+ }
+
+ public Long getMinimum() {
+ if (sequence.isEmpty()) {
+ return 0L;
+ }
+
+ return sequence.getLast();
+ }
+}
\ No newline at end of file
More information about the seam-commits
mailing list