deltaspike-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tandrasc...@apache.org
Subject git commit: DELTASPIKE-487 fixed JSF forward + added unit test
Date Sun, 02 Mar 2014 01:41:09 GMT
Repository: deltaspike
Updated Branches:
  refs/heads/master 457e20da5 -> 140afd31c


DELTASPIKE-487 fixed JSF forward + added unit test

Project: http://git-wip-us.apache.org/repos/asf/deltaspike/repo
Commit: http://git-wip-us.apache.org/repos/asf/deltaspike/commit/140afd31
Tree: http://git-wip-us.apache.org/repos/asf/deltaspike/tree/140afd31
Diff: http://git-wip-us.apache.org/repos/asf/deltaspike/diff/140afd31

Branch: refs/heads/master
Commit: 140afd31c3df3a5c372fc3334c0e81ef1d57d8a3
Parents: 457e20d
Author: tandraschko <tandraschko@apache.org>
Authored: Sun Mar 2 02:40:54 2014 +0100
Committer: tandraschko <tandraschko@apache.org>
Committed: Sun Mar 2 02:40:54 2014 +0100

----------------------------------------------------------------------
 .../scope/viewaccess/ViewAccessContext.java     |  2 +-
 .../scope/viewaccess/ViewAccessScopedTest.java  | 44 ++++-----
 .../request/DeltaSpikeLifecycleWrapper.java     |  2 +-
 .../navigation/DeltaSpikeNavigationHandler.java | 37 ++++++++
 .../scope/viewaccess/ViewAccessScopedTest.java  | 93 -------------------
 .../viewaccess/ViewAccessScopedWebAppTest.java  | 96 ++++++++++++++++++++
 .../viewAccessScopedContextTest/page1.xhtml     | 49 ++++++++++
 .../viewAccessScopedContextTest/page2.xhtml     | 45 +++++++++
 8 files changed, 251 insertions(+), 117 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltaspike/blob/140afd31/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/scope/viewaccess/ViewAccessContext.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/scope/viewaccess/ViewAccessContext.java
b/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/scope/viewaccess/ViewAccessContext.java
index 553d01d..3b358ea 100644
--- a/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/scope/viewaccess/ViewAccessContext.java
+++ b/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/scope/viewaccess/ViewAccessContext.java
@@ -107,7 +107,7 @@ public class ViewAccessContext extends AbstractContext
         return this.windowContext.isActive(); //autom. active once a window is active
     }
 
-    public void onRenderingFinished(String view)
+    public void onProcessingViewFinished(String view)
     {
         // destroy beans only if the view has been changed
         if (!view.equals(viewAccessScopedBeanHistory.getLastView()))

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/140afd31/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/scope/viewaccess/ViewAccessScopedTest.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/scope/viewaccess/ViewAccessScopedTest.java
b/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/scope/viewaccess/ViewAccessScopedTest.java
index 42e0e0a..c3ddde3 100644
--- a/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/scope/viewaccess/ViewAccessScopedTest.java
+++ b/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/scope/viewaccess/ViewAccessScopedTest.java
@@ -76,12 +76,12 @@ public class ViewAccessScopedTest
         viewAccessScopedBeanY.setValue("y1");
         Assert.assertEquals("x1", viewAccessScopedBeanX.getValue());
         Assert.assertEquals("y1", viewAccessScopedBeanY.getValue());
-        contextExtension.getViewAccessScopedContext().onRenderingFinished("viewA");
+        contextExtension.getViewAccessScopedContext().onProcessingViewFinished("viewA");
         Assert.assertEquals("x1", viewAccessScopedBeanX.getValue());
         Assert.assertEquals("y1", viewAccessScopedBeanY.getValue());
-        contextExtension.getViewAccessScopedContext().onRenderingFinished("viewA");
+        contextExtension.getViewAccessScopedContext().onProcessingViewFinished("viewA");
         //no access
-        contextExtension.getViewAccessScopedContext().onRenderingFinished("viewA");
+        contextExtension.getViewAccessScopedContext().onProcessingViewFinished("viewA");
 
         Assert.assertEquals("x1", viewAccessScopedBeanX.getValue());
         Assert.assertEquals("y1", viewAccessScopedBeanY.getValue());
@@ -103,12 +103,12 @@ public class ViewAccessScopedTest
         viewAccessScopedBeanY.setValue("y1");
         Assert.assertEquals("x1", viewAccessScopedBeanX.getValue());
         Assert.assertEquals("y1", viewAccessScopedBeanY.getValue());
-        contextExtension.getViewAccessScopedContext().onRenderingFinished("viewA");
+        contextExtension.getViewAccessScopedContext().onProcessingViewFinished("viewA");
         Assert.assertEquals("x1", viewAccessScopedBeanX.getValue());
         Assert.assertEquals("y1", viewAccessScopedBeanY.getValue());
-        contextExtension.getViewAccessScopedContext().onRenderingFinished("viewA");
+        contextExtension.getViewAccessScopedContext().onProcessingViewFinished("viewA");
 
-        contextExtension.getViewAccessScopedContext().onRenderingFinished("viewB");
+        contextExtension.getViewAccessScopedContext().onProcessingViewFinished("viewB");
 
         Assert.assertNull(viewAccessScopedBeanX.getValue());
         Assert.assertNull(viewAccessScopedBeanY.getValue());
@@ -125,14 +125,14 @@ public class ViewAccessScopedTest
         viewAccessScopedBeanY.setValue("y1");
         Assert.assertEquals("x1", viewAccessScopedBeanX.getValue());
         Assert.assertEquals("y1", viewAccessScopedBeanY.getValue());
-        contextExtension.getViewAccessScopedContext().onRenderingFinished("viewA");
+        contextExtension.getViewAccessScopedContext().onProcessingViewFinished("viewA");
         Assert.assertEquals("x1", viewAccessScopedBeanX.getValue());
         Assert.assertEquals("y1", viewAccessScopedBeanY.getValue());
-        contextExtension.getViewAccessScopedContext().onRenderingFinished("viewA");
+        contextExtension.getViewAccessScopedContext().onProcessingViewFinished("viewA");
 
         Assert.assertEquals("y1", viewAccessScopedBeanY.getValue());
 
-        contextExtension.getViewAccessScopedContext().onRenderingFinished("viewB");
+        contextExtension.getViewAccessScopedContext().onProcessingViewFinished("viewB");
 
         Assert.assertNull(viewAccessScopedBeanX.getValue());
         Assert.assertEquals("y1", viewAccessScopedBeanY.getValue());
@@ -154,14 +154,14 @@ public class ViewAccessScopedTest
         viewAccessScopedBeanY.setValue("y1");
         Assert.assertEquals("x1", viewAccessScopedBeanX.getValue());
         Assert.assertEquals("y1", viewAccessScopedBeanY.getValue());
-        contextExtension.getViewAccessScopedContext().onRenderingFinished("viewA");
+        contextExtension.getViewAccessScopedContext().onProcessingViewFinished("viewA");
         Assert.assertEquals("x1", viewAccessScopedBeanX.getValue());
         Assert.assertEquals("y1", viewAccessScopedBeanY.getValue());
-        contextExtension.getViewAccessScopedContext().onRenderingFinished("viewA");
+        contextExtension.getViewAccessScopedContext().onProcessingViewFinished("viewA");
 
         Assert.assertEquals("x1", viewAccessScopedBeanX.getValue());
 
-        contextExtension.getViewAccessScopedContext().onRenderingFinished("viewB");
+        contextExtension.getViewAccessScopedContext().onProcessingViewFinished("viewB");
 
         Assert.assertEquals("x1", viewAccessScopedBeanX.getValue());
         Assert.assertNull(viewAccessScopedBeanY.getValue());
@@ -180,17 +180,17 @@ public class ViewAccessScopedTest
         windowContext.activateWindow("w1");
 
         viewAccessScopedBeanX.setValue("x1");
-        contextExtension.getViewAccessScopedContext().onRenderingFinished("viewA");
+        contextExtension.getViewAccessScopedContext().onProcessingViewFinished("viewA");
         Assert.assertEquals("x1", viewAccessScopedBeanX.getValue());
 
         viewAccessScopedBeanY.setValue("y1");
-        contextExtension.getViewAccessScopedContext().onRenderingFinished("viewA");
+        contextExtension.getViewAccessScopedContext().onProcessingViewFinished("viewA");
         Assert.assertEquals("x1", viewAccessScopedBeanX.getValue());
         Assert.assertEquals("y1", viewAccessScopedBeanY.getValue());
 
-        contextExtension.getViewAccessScopedContext().onRenderingFinished("viewA");
+        contextExtension.getViewAccessScopedContext().onProcessingViewFinished("viewA");
         //no access
-        contextExtension.getViewAccessScopedContext().onRenderingFinished("viewA");
+        contextExtension.getViewAccessScopedContext().onProcessingViewFinished("viewA");
         Assert.assertEquals("x1", viewAccessScopedBeanX.getValue());
         Assert.assertEquals("y1", viewAccessScopedBeanY.getValue());
 
@@ -208,14 +208,14 @@ public class ViewAccessScopedTest
         windowContext.activateWindow("w1");
 
         viewAccessScopedBeanX.setValue("x1");
-        contextExtension.getViewAccessScopedContext().onRenderingFinished("viewA");
+        contextExtension.getViewAccessScopedContext().onProcessingViewFinished("viewA");
         Assert.assertEquals("x1", viewAccessScopedBeanX.getValue());
 
         viewAccessScopedBeanY.setValue("y1");
-        contextExtension.getViewAccessScopedContext().onRenderingFinished("viewA");
+        contextExtension.getViewAccessScopedContext().onProcessingViewFinished("viewA");
         Assert.assertEquals("x1", viewAccessScopedBeanX.getValue());
 
-        contextExtension.getViewAccessScopedContext().onRenderingFinished("viewB");
+        contextExtension.getViewAccessScopedContext().onProcessingViewFinished("viewB");
         Assert.assertEquals("x1", viewAccessScopedBeanX.getValue());
         Assert.assertNull(viewAccessScopedBeanY.getValue());
 
@@ -233,14 +233,14 @@ public class ViewAccessScopedTest
         windowContext.activateWindow("w1");
 
         viewAccessScopedBeanX.setValue("x1");
-        contextExtension.getViewAccessScopedContext().onRenderingFinished("viewA");
+        contextExtension.getViewAccessScopedContext().onProcessingViewFinished("viewA");
         Assert.assertEquals("x1", viewAccessScopedBeanX.getValue());
 
         viewAccessScopedBeanY.setValue("y1");
-        contextExtension.getViewAccessScopedContext().onRenderingFinished("viewA");
+        contextExtension.getViewAccessScopedContext().onProcessingViewFinished("viewA");
         Assert.assertEquals("y1", viewAccessScopedBeanY.getValue());
 
-        contextExtension.getViewAccessScopedContext().onRenderingFinished("viewB");
+        contextExtension.getViewAccessScopedContext().onProcessingViewFinished("viewB");
         Assert.assertNull(viewAccessScopedBeanX.getValue());
         Assert.assertEquals("y1", viewAccessScopedBeanY.getValue());
 

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/140afd31/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/listener/request/DeltaSpikeLifecycleWrapper.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/listener/request/DeltaSpikeLifecycleWrapper.java
b/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/listener/request/DeltaSpikeLifecycleWrapper.java
index 36b4342..0acc818 100644
--- a/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/listener/request/DeltaSpikeLifecycleWrapper.java
+++ b/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/listener/request/DeltaSpikeLifecycleWrapper.java
@@ -115,7 +115,7 @@ class DeltaSpikeLifecycleWrapper extends Lifecycle
             ViewAccessContext viewAccessContext = contextExtension.getViewAccessScopedContext();
             if (viewAccessContext != null)
             {
-                viewAccessContext.onRenderingFinished(facesContext.getViewRoot().getViewId());
+                viewAccessContext.onProcessingViewFinished(facesContext.getViewRoot().getViewId());
             }
         }
     }

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/140afd31/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/navigation/DeltaSpikeNavigationHandler.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/navigation/DeltaSpikeNavigationHandler.java
b/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/navigation/DeltaSpikeNavigationHandler.java
index 1293cfe..8ddaa29 100644
--- a/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/navigation/DeltaSpikeNavigationHandler.java
+++ b/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/navigation/DeltaSpikeNavigationHandler.java
@@ -39,6 +39,9 @@ import java.util.Map;
 import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.CopyOnWriteArraySet;
+import org.apache.deltaspike.core.api.provider.BeanProvider;
+import org.apache.deltaspike.core.impl.scope.DeltaSpikeContextExtension;
+import org.apache.deltaspike.core.impl.scope.viewaccess.ViewAccessContext;
 
 public class DeltaSpikeNavigationHandler extends ConfigurableNavigationHandler implements
Deactivatable
 {
@@ -50,6 +53,10 @@ public class DeltaSpikeNavigationHandler extends ConfigurableNavigationHandler
i
     private final NavigationHandler wrapped;
     private final boolean activated;
 
+    private volatile Boolean initialized;
+    
+    private DeltaSpikeContextExtension contextExtension;
+    
     /**
      * Constructor for wrapping the given {@link NavigationHandler}
      *
@@ -64,6 +71,17 @@ public class DeltaSpikeNavigationHandler extends ConfigurableNavigationHandler
i
     @Override
     public void handleNavigation(FacesContext context, String fromAction, String outcome)
     {
+        lazyInit();
+        
+        if (context.getViewRoot() != null && context.getViewRoot().getViewId() !=
null)
+        {
+            ViewAccessContext viewAccessContext = contextExtension.getViewAccessScopedContext();
+            if (viewAccessContext != null)
+            {
+                viewAccessContext.onProcessingViewFinished(context.getViewRoot().getViewId());
+            }
+        }
+        
         if (!this.activated || isUnhandledExceptionQueued(context))
         {
             this.wrapped.handleNavigation(context, fromAction, outcome);
@@ -170,4 +188,23 @@ public class DeltaSpikeNavigationHandler extends ConfigurableNavigationHandler
i
 
         return new NavigationCaseMapWrapper(result, this.wrapped);
     }
+    
+    private void lazyInit()
+    {
+        if (this.initialized == null)
+        {
+            init();
+        }
+    }
+
+    private synchronized void init()
+    {
+        // switch into paranoia mode
+        if (this.initialized == null)
+        {
+            contextExtension = BeanProvider.getContextualReference(DeltaSpikeContextExtension.class,
true);
+            
+            this.initialized = true;
+        }
+    }
 }

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/140afd31/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/scope/viewaccess/ViewAccessScopedTest.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/scope/viewaccess/ViewAccessScopedTest.java
b/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/scope/viewaccess/ViewAccessScopedTest.java
deleted file mode 100644
index 8cda848..0000000
--- a/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/scope/viewaccess/ViewAccessScopedTest.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.deltaspike.test.jsf.impl.scope.viewaccess;
-
-import javax.inject.Inject;
-import org.apache.deltaspike.core.impl.scope.DeltaSpikeContextExtension;
-import org.apache.deltaspike.core.spi.scope.window.WindowContext;
-import org.apache.deltaspike.test.category.SeCategory;
-import org.apache.deltaspike.test.jsf.impl.scope.viewaccess.beans.ViewAccessScopedBeanX;
-import org.apache.deltaspike.test.jsf.impl.scope.viewaccess.beans.ViewAccessScopedBeanY;
-import org.apache.deltaspike.test.jsf.impl.util.ArchiveUtils;
-import org.jboss.arquillian.container.test.api.Deployment;
-import org.jboss.arquillian.junit.Arquillian;
-import org.jboss.shrinkwrap.api.ShrinkWrap;
-import org.jboss.shrinkwrap.api.asset.EmptyAsset;
-import org.jboss.shrinkwrap.api.spec.JavaArchive;
-import org.jboss.shrinkwrap.api.spec.WebArchive;
-import org.junit.Assert;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.junit.runner.RunWith;
-
-@RunWith(Arquillian.class)
-@Category(SeCategory.class)
-public class ViewAccessScopedTest
-{
-    @Deployment
-    public static WebArchive deploy()
-    {
-        String simpleName = ViewAccessScopedTest.class.getSimpleName();
-        String archiveName = simpleName.substring(0, 1).toLowerCase() + simpleName.substring(1);
-
-        JavaArchive testJar = ShrinkWrap.create(JavaArchive.class, archiveName + ".jar")
-                .addPackage(ViewAccessScopedTest.class.getPackage().getName())
-                .addPackage(ViewAccessScopedBeanX.class.getPackage().getName())
-                .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
-
-        return ShrinkWrap.create(WebArchive.class, archiveName + ".war")
-                .addAsLibraries(ArchiveUtils.getDeltaSpikeCoreAndJsfArchive())
-                .addAsLibraries(testJar)
-                .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml");
-    }
-
-    @Inject
-    private WindowContext windowContext;
-
-    @Inject
-    private ViewAccessScopedBeanX viewAccessScopedBeanX;
-
-    @Inject
-    private ViewAccessScopedBeanY viewAccessScopedBeanY;
-
-    @Inject
-    private DeltaSpikeContextExtension contextExtension;
-
-    @Test
-    public void usageOnOnePageTest()
-    {
-        windowContext.activateWindow("w1");
-
-        viewAccessScopedBeanX.setValue("x1");
-        viewAccessScopedBeanY.setValue("y1");
-        Assert.assertEquals("x1", viewAccessScopedBeanX.getValue());
-        Assert.assertEquals("y1", viewAccessScopedBeanY.getValue());
-        contextExtension.getViewAccessScopedContext().onRenderingFinished("viewA");
-        Assert.assertEquals("x1", viewAccessScopedBeanX.getValue());
-        Assert.assertEquals("y1", viewAccessScopedBeanY.getValue());
-        contextExtension.getViewAccessScopedContext().onRenderingFinished("viewA");
-
-        //no access
-        contextExtension.getViewAccessScopedContext().onRenderingFinished("viewB");
-
-        //fails:
-        Assert.assertNull(viewAccessScopedBeanX.getValue());
-        Assert.assertNull(viewAccessScopedBeanY.getValue());
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/140afd31/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/scope/viewaccess/ViewAccessScopedWebAppTest.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/scope/viewaccess/ViewAccessScopedWebAppTest.java
b/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/scope/viewaccess/ViewAccessScopedWebAppTest.java
new file mode 100644
index 0000000..cc03d49
--- /dev/null
+++ b/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/scope/viewaccess/ViewAccessScopedWebAppTest.java
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.deltaspike.test.jsf.impl.scope.viewaccess;
+
+import org.apache.deltaspike.test.category.WebProfileCategory;
+import org.apache.deltaspike.test.jsf.impl.scope.viewaccess.beans.ViewAccessScopedBeanX;
+import org.apache.deltaspike.test.jsf.impl.scope.viewaccess.beans.ViewAccessScopedBeanY;
+import org.apache.deltaspike.test.jsf.impl.util.ArchiveUtils;
+import org.jboss.arquillian.container.test.api.Deployment;
+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.arquillian.warp.WarpTest;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.EmptyAsset;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.support.ui.ExpectedConditions;
+
+import java.net.URL;
+
+@WarpTest
+@RunWith(Arquillian.class)
+@Category(WebProfileCategory.class)
+public class ViewAccessScopedWebAppTest
+{
+    @Drone
+    private WebDriver driver;
+
+    @ArquillianResource
+    private URL contextPath;
+
+    @Deployment
+    public static WebArchive deploy()
+    {
+        String simpleName = ViewAccessScopedWebAppTest.class.getSimpleName();
+        String archiveName = simpleName.substring(0, 1).toLowerCase() + simpleName.substring(1);
+
+        return ShrinkWrap
+                .create(WebArchive.class, archiveName + ".war")
+                .addClass(ViewAccessScopedBeanX.class)
+                .addClass(ViewAccessScopedBeanY.class)
+                .addAsLibraries(ArchiveUtils.getDeltaSpikeCoreAndJsfArchive())
+                .addAsLibraries(ArchiveUtils.getDeltaSpikeSecurityArchive())
+                .addAsWebInfResource("default/WEB-INF/web.xml", "web.xml")
+                .addAsWebResource("viewAccessScopedContextTest/page1.xhtml", "page1.xhtml")
+                .addAsWebResource("viewAccessScopedContextTest/page2.xhtml", "page2.xhtml")
+                .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml");
+    }
+
+    @Test
+    @RunAsClient
+    public void testForward() throws Exception
+    {
+        driver.get(new URL(contextPath, "page1.xhtml").toString());
+
+        WebElement inputFieldX = driver.findElement(By.id("testForm1:valueInputX"));
+        inputFieldX.sendKeys("abc");
+        WebElement inputFieldY = driver.findElement(By.id("testForm1:valueInputY"));
+        inputFieldY.sendKeys("xyz");
+
+        WebElement button = driver.findElement(By.id("testForm1:next"));
+        button.click();
+
+        Assert.assertTrue(ExpectedConditions.textToBePresentInElement(By.id("valueX"), "abc").apply(driver));
+
+        button = driver.findElement(By.id("testForm2:back"));
+        button.click();
+
+        Assert.assertTrue(ExpectedConditions.textToBePresentInElement(By.id("valueOutputX"),
"abc").apply(driver));
+        Assert.assertFalse(ExpectedConditions.textToBePresentInElement(By.id("valueOutputY"),
"xyz").apply(driver));
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/140afd31/deltaspike/modules/jsf/impl/src/test/resources/viewAccessScopedContextTest/page1.xhtml
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jsf/impl/src/test/resources/viewAccessScopedContextTest/page1.xhtml
b/deltaspike/modules/jsf/impl/src/test/resources/viewAccessScopedContextTest/page1.xhtml
new file mode 100644
index 0000000..2d601b3
--- /dev/null
+++ b/deltaspike/modules/jsf/impl/src/test/resources/viewAccessScopedContextTest/page1.xhtml
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+-->
+
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<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"
+      xmlns:c="http://java.sun.com/jsp/jstl/core"
+      xmlns:ds="http://deltaspike.apache.org/jsf">
+
+<h:head>
+
+</h:head>
+
+<h:body>
+    <ds:windowId/>
+    <div>
+        <h:form id="testForm1">
+            <h:outputLabel for="valueInputX" value="x:"/>
+            <h:inputText id="valueInputX" value="#{viewAccessScopedBeanX.value}"/>
+            <br/>
+            <h:outputLabel for="valueInputY" value="y:"/>
+            <h:inputText id="valueInputY" value="#{viewAccessScopedBeanY.value}"/>
+            <br/>
+            <h:commandButton id="next" action="page2.xhtml" value="next"/>
+        </h:form>
+        <h:outputText id="valueOutputX" value="#{viewAccessScopedBeanX.value}"/>
+        <h:outputText id="valueOutputY" value="#{viewAccessScopedBeanY.value}"/>
+    </div>
+</h:body>
+</html>

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/140afd31/deltaspike/modules/jsf/impl/src/test/resources/viewAccessScopedContextTest/page2.xhtml
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jsf/impl/src/test/resources/viewAccessScopedContextTest/page2.xhtml
b/deltaspike/modules/jsf/impl/src/test/resources/viewAccessScopedContextTest/page2.xhtml
new file mode 100644
index 0000000..7ef0160
--- /dev/null
+++ b/deltaspike/modules/jsf/impl/src/test/resources/viewAccessScopedContextTest/page2.xhtml
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+-->
+
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<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"
+      xmlns:c="http://java.sun.com/jsp/jstl/core"
+      xmlns:ds="http://deltaspike.apache.org/jsf">
+
+<h:head>
+
+</h:head>
+
+<h:body>
+    <ds:windowId/>
+    <div>
+        <h:outputLabel for="valueX" value="x:"/>
+        <h:outputText id="valueX" value="#{viewAccessScopedBeanX.value}"/>
+        <br/>
+
+        <h:form id="testForm2">
+            <h:commandButton id="back" action="page1.xhtml" value="back"/>
+        </h:form>
+    </div>
+</h:body>
+</html>


Mime
View raw message