[seam-commits] Seam SVN: r15079 - branches/community/Seam_2_3/seam-integration-tests/src/test/java/org/jboss/seam/test/integration/faces.

seam-commits at lists.jboss.org seam-commits at lists.jboss.org
Fri Aug 24 06:43:24 EDT 2012


Author: maschmid
Date: 2012-08-24 06:43:24 -0400 (Fri, 24 Aug 2012)
New Revision: 15079

Removed:
   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/src/test/java/org/jboss/seam/test/integration/faces/RestoreViewComponentAccessTest.java
Log:
JBSEAM-4976 fix RestoreViewComponentAccessTest


Modified: 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	2012-08-24 09:48:02 UTC (rev 15078)
+++ branches/community/Seam_2_3/seam-integration-tests/src/test/java/org/jboss/seam/test/integration/faces/RestoreViewComponentAccessTest.java	2012-08-24 10:43:24 UTC (rev 15079)
@@ -4,18 +4,23 @@
 import static org.junit.Assert.assertFalse;
 
 
+import java.io.Serializable;
 import java.net.URL;
+import java.util.Deque;
+import java.util.LinkedList;
 
 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.ScopeType;
+import org.jboss.seam.annotations.Create;
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.annotations.Scope;
 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.Ignore;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
@@ -23,13 +28,15 @@
 import com.gargoylesoftware.htmlunit.html.HtmlPage;
 import com.gargoylesoftware.htmlunit.html.HtmlTextInput;
 
+/**
+ * Test accessing conversation scoped component from a restore view phase (by a JSF validator attribute)
+ * Related to JBSEAM-4976
+ */
 @RunWith(Arquillian.class)
 @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;
@@ -38,7 +45,6 @@
    @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);
@@ -46,37 +52,7 @@
       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(
+      war.addAsWebResource(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\"" +
@@ -86,19 +62,29 @@
             "<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:outputText id='output' value='Sequence: #{sequence.output}'/>" +
+                  "<h:inputText id='input' value='#{sequence.input}'>" +
+                  "<f:validateLongRange minimum='#{sequence.minimum}' />" +
                   "</h:inputText>" +
-                  "<h:commandButton id='append' value='Append' action='#{" + cname + ".append}'/>" +
+                  "<h:commandButton id='append' value='Append' action='#{sequence.append}'/>" +
                "</h:form>" +
             "</h:body>" + 
-            "</html>");
+            "</html>"), "test.xhtml");
+
+      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.xhtml'>" +
+            "<begin-conversation join='true'/>" +
+            "<navigation><redirect view-id='/test.xhtml'/></navigation>" +
+            "</page></pages>"), "pages.xml");
+      
+      return war;
    }
    
-   
-   public void testBase(String scope) throws Exception {
-      HtmlPage page = client.getPage(contextPath + "test_" + scope + ".seam");
+   @Test
+   public void testJBSEAM4976() throws Exception {
+      HtmlPage page = client.getPage(contextPath + "test.seam");
       assertTrue(page.getBody().getTextContent().contains("Sequence: "));
       
       ((HtmlTextInput)page.getElementById("form:input")).setText("1");
@@ -118,27 +104,49 @@
       assertTrue(page.getBody().getTextContent().contains("value must be greater than or equal to 2"));
    }
    
-   @Test
-   @Ignore
-   public void testPage() throws Exception {
-      testBase("page");
+   @Name("sequence")
+   @Scope(ScopeType.CONVERSATION)
+   public static class SequenceAction implements Serializable {
+      private static final long serialVersionUID = 1L;
+      
+      private Deque<Long> sequence;
+      private Long input;
+      
+      @Create
+      public void 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();
+      }
    }
-   
-   @Test
-   @Ignore
-   public void testConversation() throws Exception {
-      testBase("conversation");
-   }
-   
-   @Test
-   @Ignore
-   public void testSession() throws Exception {
-      testBase("session");
-   }
-   
-   @Test
-   @Ignore
-   public void testApplication() throws Exception {
-      testBase("application");
-   }
 }

Deleted: 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	2012-08-24 09:48:02 UTC (rev 15078)
+++ branches/community/Seam_2_3/seam-integration-tests/src/test/java/org/jboss/seam/test/integration/faces/SequenceAction.java	2012-08-24 10:43:24 UTC (rev 15079)
@@ -1,51 +0,0 @@
-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() {
-      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