[seam-commits] Seam SVN: r15075 - 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
Thu Aug 23 11:57:08 EDT 2012


Author: maschmid
Date: 2012-08-23 11:57:07 -0400 (Thu, 23 Aug 2012)
New Revision: 15075

Added:
   branches/community/Seam_2_3/seam-integration-tests/src/test/java/org/jboss/seam/test/integration/faces/SessionScopedOutjectionOverwriteTest.java
Log:
JBSEAM-4966 test


Added: branches/community/Seam_2_3/seam-integration-tests/src/test/java/org/jboss/seam/test/integration/faces/SessionScopedOutjectionOverwriteTest.java
===================================================================
--- branches/community/Seam_2_3/seam-integration-tests/src/test/java/org/jboss/seam/test/integration/faces/SessionScopedOutjectionOverwriteTest.java	                        (rev 0)
+++ branches/community/Seam_2_3/seam-integration-tests/src/test/java/org/jboss/seam/test/integration/faces/SessionScopedOutjectionOverwriteTest.java	2012-08-23 15:57:07 UTC (rev 15075)
@@ -0,0 +1,102 @@
+package org.jboss.seam.test.integration.faces;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+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.ScopeType;
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.annotations.Out;
+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.StringAsset;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import com.gargoylesoftware.htmlunit.WebClient;
+import com.gargoylesoftware.htmlunit.html.HtmlPage;
+
+/**
+ * Test for JBSEAM-4966
+ */
+ at RunWith(Arquillian.class)
+ at RunAsClient
+public class SessionScopedOutjectionOverwriteTest
+{
+   private final WebClient client = new WebClient();
+   
+   @ArquillianResource
+   URL contextPath;
+   
+   @Deployment(name="SessionScopedIdlingTest", testable=false)
+   @OverProtocol("Servlet 3.0") 
+   public static Archive<?> createDeployment()
+   {
+      // This is a client test, use a real (non-mocked) Seam deployment
+      return Deployments.realSeamDeployment()
+            .addClasses(Foo.class, Bar.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='form'>" +
+                     "<h:outputText value='Output: #{output}.'/>" +
+                     "<h:commandButton id='foo' action='#{foo.foo}' value='foo' />" +
+                     "<h:commandButton id='bar' action='#{bar.bar}' value='bar' />" +
+                     "<h:commandButton id='nop' action='test' value='nop' />" +
+                     "</h:form>" +
+                   "</h:body>" + 
+                  "</html>"), "test.xhtml");
+   }
+   
+   @Test
+   public void testJBSEAM4966() throws Exception {
+      HtmlPage page = client.getPage(contextPath + "test.seam");
+
+      page = page.getElementById("form:foo").click();
+      assertTrue(page.getBody().getTextContent().contains("Output: foo"));
+      
+      page = page.getElementById("form:bar").click();
+      assertTrue(page.getBody().getTextContent().contains("Output: bar"));
+      
+      page = page.getElementById("form:nop").click();
+      assertFalse("Output should stay 'bar' after a 'nop' operation.", page.getBody().getTextContent().contains("Output: foo"));
+      assertTrue(page.getBody().getTextContent().contains("Output: bar"));
+   }
+
+   @Scope(ScopeType.SESSION)
+   @Name("foo")
+   public static class Foo
+   {
+      @Out(scope=ScopeType.SESSION)
+      private String output;
+      
+      public void foo()
+      {
+         output = "foo";
+      }
+   }
+   
+   @Scope(ScopeType.EVENT)
+   @Name("bar")
+   public static class Bar
+   {
+      @Out(scope=ScopeType.SESSION)
+      private String output;
+      
+      public void bar()
+      {
+         output = "bar";
+      }
+   }
+}



More information about the seam-commits mailing list