Author: maschmid
Date: 2012-07-20 10:21:50 -0400 (Fri, 20 Jul 2012)
New Revision: 14993

Added:
   
branches/community/Seam_2_3/seam-integration-tests/src/test/java/org/jboss/seam/test/integration/faces/
   
branches/community/Seam_2_3/seam-integration-tests/src/test/java/org/jboss/seam/test/integration/faces/PageScopedUIIncludeTest.java
Modified:
   branches/community/Seam_2_3/pom.xml
   branches/community/Seam_2_3/seam-integration-tests/pom.xml
Log:
Add a test for JBSEAM-5002


Modified: branches/community/Seam_2_3/pom.xml
===================================================================
--- branches/community/Seam_2_3/pom.xml 2012-07-20 13:29:40 UTC (rev 14992)
+++ branches/community/Seam_2_3/pom.xml 2012-07-20 14:21:50 UTC (rev 14993)
@@ -45,6 +45,7 @@
 
                <!-- Version string properties -->
                <version.arquillian_core>1.0.1.Final</version.arquillian_core>
+               <version.arquillian_drone>1.0.0.Final</version.arquillian_drone>
                <version.wicket>1.4.14</version.wicket>
                <version.drools>5.1.1</version.drools>
                <version.testng>5.14.10</version.testng>
@@ -103,6 +104,13 @@
                                <version>1.7.0</version>
                        </dependency>
 
+                       <dependency>
+                               
<groupId>org.jboss.arquillian.extension</groupId>
+                               <artifactId>arquillian-drone-bom</artifactId>
+                               <version>${version.arquillian_drone}</version>
+                               <type>pom</type>
+                               <scope>import</scope>
+                       </dependency>
 
                        <!-- You should adjust this in the initcore task in 
build.xml as well -->
                        <dependency>

Modified: branches/community/Seam_2_3/seam-integration-tests/pom.xml
===================================================================
--- branches/community/Seam_2_3/seam-integration-tests/pom.xml  2012-07-20 
13:29:40 UTC (rev 14992)
+++ branches/community/Seam_2_3/seam-integration-tests/pom.xml  2012-07-20 
14:21:50 UTC (rev 14993)
@@ -122,8 +122,23 @@
                        <artifactId>arquillian-protocol-servlet</artifactId>
                        <scope>test</scope>
                </dependency>
-       
+
                <dependency>
+                       <groupId>org.jboss.arquillian.extension</groupId>
+                       
<artifactId>arquillian-drone-webdriver-depchain</artifactId>
+                       <type>pom</type>
+                       <scope>test</scope>
+               </dependency>
+
+               <!-- Override for WebDriver -->
+               <dependency>
+                       <groupId>commons-lang</groupId>
+                       <artifactId>commons-lang</artifactId>
+                       <version>2.6</version>
+                       <scope>test</scope>
+               </dependency>
+
+               <dependency>
                        <groupId>org.jboss.seam</groupId>
                        <artifactId>jboss-seam</artifactId>
                        <type>ejb</type>

Added: 
branches/community/Seam_2_3/seam-integration-tests/src/test/java/org/jboss/seam/test/integration/faces/PageScopedUIIncludeTest.java
===================================================================
--- 
branches/community/Seam_2_3/seam-integration-tests/src/test/java/org/jboss/seam/test/integration/faces/PageScopedUIIncludeTest.java
                         (rev 0)
+++ 
branches/community/Seam_2_3/seam-integration-tests/src/test/java/org/jboss/seam/test/integration/faces/PageScopedUIIncludeTest.java
 2012-07-20 14:21:50 UTC (rev 14993)
@@ -0,0 +1,169 @@
+package org.jboss.seam.test.integration.faces;
+
+import static org.junit.Assert.assertTrue;
+
+import java.io.Serializable;
+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.drone.api.annotation.Drone;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.arquillian.test.api.ArquillianResource;
+import org.jboss.seam.ScopeType;
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.annotations.Scope;
+import org.jboss.seam.test.integration.Deployments;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.asset.Asset;
+import org.jboss.shrinkwrap.api.asset.StringAsset;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebDriver;
+
+// JBSEAM-5002
+@RunWith(Arquillian.class)
+@RunAsClient
+public class PageScopedUIIncludeTest
+{
+   @Drone
+   WebDriver driver;
+   
+   @ArquillianResource
+   URL contextPath;
+   
+   @Deployment(name="PageScopedUIIncludeTest")
+   @OverProtocol("Servlet 3.0") 
+   public static Archive<?> createDeployment()
+   {
+      // This is a client test, use a real (non-mocked) Seam deployment
+      return Deployments.realSeamDeployment()
+            .addClasses(Component.class, Component1.class, Component2.class)
+            .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\""; +
+                  " xmlns:ui=\"http://java.sun.com/jsf/facelets\";>" +
+                  "<h:head></h:head>" +
+                  "<h:body>" +
+                     "<h:form id='controller'>" +
+                        "<h:commandButton id='component1' 
action='#{viewController.component1}' value='Component 1' />" +
+                        "<h:commandButton id='component2' 
action='#{viewController.component2}' value='Component 2' />" +
+                     "</h:form>" +
+                     "<ui:include src='#{viewController.viewId}'/>" +
+                  "</h:body>" + 
+                  "</html>"), "test.xhtml")
+            .addAsWebResource(createComponentXhtmlAsset(1), "component1.xhtml")
+            .addAsWebResource(createComponentXhtmlAsset(2), 
"component2.xhtml");
+   }
+   
+   private static Asset createComponentXhtmlAsset(int i)
+   {
+      return new StringAsset("<ui:composition 
xmlns=\"http://www.w3.org/1999/xhtml\""; +
+            " xmlns:ui=\"http://java.sun.com/jsf/facelets\""; +
+            " xmlns:h=\"http://java.sun.com/jsf/html\";>" +
+            "<h3>Component " + i + "</h3>" +
+            "<h:form id='form" + i + "'>" +
+               "<h:inputText id='input' value='#{component" + i + ".input}' 
/>" +
+               "<h:commandButton id='save' value='Save' action='#{component" + 
i + ".save}' />" +
+               "<h:outputText value='#{component" + i + ".output}' />" + 
+            "</h:form>" +
+            "</ui:composition>"); // Yay for Java String syntax!
+   }
+   
+   @Test
+   public void testComponent1()
+   {
+      driver.navigate().to(contextPath + "test.seam");
+      assertTrue(driver.getPageSource().contains("Component 1"));
+      driver.findElement(By.id("form1:input")).clear();
+      driver.findElement(By.id("form1:input")).sendKeys("xyzzy");
+      driver.findElement(By.id("form1:save")).click();
+      assertTrue(driver.getPageSource().contains("Hello, xyzzy"));
+   }
+   
+   @Test
+   public void testComponent2()
+   {
+      driver.navigate().to(contextPath + "test.seam");
+      assertTrue(driver.getPageSource().contains("Component 1"));
+      driver.findElement(By.id("controller:component2")).click();
+      assertTrue(driver.getPageSource().contains("Component 2"));
+      driver.findElement(By.id("form2:input")).clear();
+      driver.findElement(By.id("form2:input")).sendKeys("foobar");
+      driver.findElement(By.id("form2:save")).click();
+      assertTrue(driver.getPageSource().contains("Hi, foobar"));
+   }
+   
+   public abstract static class Component
+   {
+      protected String input;
+      protected String output;
+
+      public String getInput()
+      {
+         return input;
+      }
+
+      public void setInput(String input)
+      {
+         this.input = input;
+      }
+      
+      public String getOutput()
+      {
+         return output;
+      }
+      
+      abstract public void save();
+   }
+   
+   @Scope(ScopeType.CONVERSATION)
+   @Name("component1")
+   public static class Component1 extends Component
+   {
+      public void save()
+      {
+         output = "Hello, " + input;
+      }
+   }
+   
+   @Scope(ScopeType.CONVERSATION)
+   @Name("component2")
+   public static class Component2 extends Component
+   {
+      public void save()
+      {
+         output = "Hi, " + input;
+      }
+   }
+   
+   @Scope(ScopeType.PAGE)
+   @Name("viewController")
+   public static class ViewController implements Serializable
+   {
+      private String viewId = "/component1.xhtml";
+      
+      public void setViewId(String viewId)
+      {
+         this.viewId = viewId;
+      }
+      
+      public String getViewId()
+      {
+         return viewId;
+      }
+      
+      public void component1()
+      {
+         setViewId("/component1.xhtml");
+      }
+      
+      public void component2()
+      {
+         setViewId("/component2.xhtml");
+      }
+   }
+}

_______________________________________________
seam-commits mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/seam-commits

Reply via email to