deltaspike-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rafab...@apache.org
Subject deltaspike git commit: DELTASPIKE-796 - test view-actions in combination with @ViewAccessScoped
Date Thu, 18 Dec 2014 14:50:07 GMT
Repository: deltaspike
Updated Branches:
  refs/heads/master a910828e9 -> c0f742872


DELTASPIKE-796 - test view-actions in combination with @ViewAccessScoped


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

Branch: refs/heads/master
Commit: c0f74287286f5e3fa395c244aa3ca8b40e143343
Parents: a910828
Author: Rafael Benevides <rafabene@gmail.com>
Authored: Thu Dec 18 12:49:44 2014 -0200
Committer: Rafael Benevides <rafabene@gmail.com>
Committed: Thu Dec 18 12:49:44 2014 -0200

----------------------------------------------------------------------
 .../viewaccess/beans/ViewAccessScopedBeanX.java | 84 +++++++++---------
 ...ewAccessScopedWithFViewActionWebAppTest.java | 92 ++++++++++++++++++++
 .../viewAccessScopedContextTest/index.xhtml     | 29 ++++++
 .../viewAccessScopedContextTest/next.xhtml      | 21 +++++
 4 files changed, 186 insertions(+), 40 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltaspike/blob/c0f74287/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/scope/viewaccess/beans/ViewAccessScopedBeanX.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/scope/viewaccess/beans/ViewAccessScopedBeanX.java
b/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/scope/viewaccess/beans/ViewAccessScopedBeanX.java
index 957eeef..695c61b 100644
--- a/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/scope/viewaccess/beans/ViewAccessScopedBeanX.java
+++ b/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/scope/viewaccess/beans/ViewAccessScopedBeanX.java
@@ -1,40 +1,44 @@
-/*
- * 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.beans;
-
-import java.io.Serializable;
-import javax.inject.Named;
-import org.apache.deltaspike.core.api.scope.ViewAccessScoped;
-
-@Named
-@ViewAccessScoped
-public class ViewAccessScopedBeanX implements Serializable
-{
-    private String value;
-
-    public String getValue()
-    {
-        return value;
-    }
-
-    public void setValue(String value)
-    {
-        this.value = value;
-    }
-}
+/*
+ * 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.beans;
+
+import java.io.Serializable;
+import javax.inject.Named;
+import org.apache.deltaspike.core.api.scope.ViewAccessScoped;
+
+@Named
+@ViewAccessScoped
+public class ViewAccessScopedBeanX implements Serializable
+{
+    private String value;
+
+    public String getValue()
+    {
+        return value;
+    }
+
+    public void setValue(String value)
+    {
+        this.value = value;
+    }
+
+    public void viewAction()
+    {
+    }
+}

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/c0f74287/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/scope/viewaccess/iewAccessScopedWithFViewActionWebAppTest.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/scope/viewaccess/iewAccessScopedWithFViewActionWebAppTest.java
b/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/scope/viewaccess/iewAccessScopedWithFViewActionWebAppTest.java
new file mode 100644
index 0000000..83ff901
--- /dev/null
+++ b/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/scope/viewaccess/iewAccessScopedWithFViewActionWebAppTest.java
@@ -0,0 +1,92 @@
+/*
+ * 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 iewAccessScopedWithFViewActionWebAppTest
+{
+    @Drone
+    private WebDriver driver;
+
+    @ArquillianResource
+    private URL contextPath;
+
+    @Deployment
+    public static WebArchive deploy()
+    {
+        String simpleName = iewAccessScopedWithFViewActionWebAppTest.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/index.xhtml", "index.xhtml")
+                .addAsWebResource("viewAccessScopedContextTest/next.xhtml", "next.xhtml")
+                .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml");
+    }
+
+    @Test
+    @RunAsClient
+    public void testForward() throws Exception
+    {
+        driver.get(new URL(contextPath, "index.xhtml").toString());
+
+        WebElement inputFieldX = driver.findElement(By.id("form:firstValue"));
+        inputFieldX.sendKeys("abc");
+        WebElement inputFieldY = driver.findElement(By.id("form:secondValue"));
+        inputFieldY.sendKeys("xyz");
+
+        WebElement button = driver.findElement(By.id("form:next"));
+        button.click();
+
+        Assert.assertTrue(ExpectedConditions.textToBePresentInElement(By.id("firstValue"),
"abc").apply(driver));
+        Assert.assertTrue(ExpectedConditions.textToBePresentInElement(By.id("secondValue"),
"xyz").apply(driver));
+
+    }
+}

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/c0f74287/deltaspike/modules/jsf/impl/src/test/resources/viewAccessScopedContextTest/index.xhtml
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jsf/impl/src/test/resources/viewAccessScopedContextTest/index.xhtml
b/deltaspike/modules/jsf/impl/src/test/resources/viewAccessScopedContextTest/index.xhtml
new file mode 100755
index 0000000..c8d3363
--- /dev/null
+++ b/deltaspike/modules/jsf/impl/src/test/resources/viewAccessScopedContextTest/index.xhtml
@@ -0,0 +1,29 @@
+<!DOCTYPE html>
+<html xmlns="http://www.w3.org/1999/xhtml"
+      xmlns:f="http://xmlns.jcp.org/jsf/core"
+      xmlns:h="http://xmlns.jcp.org/jsf/html"
+      xmlns:ds="http://deltaspike.apache.org/jsf">
+<f:view>
+  <f:metadata>
+    <f:viewAction action="#{viewAccessScopedBeanX.viewAction()}"/>
+  </f:metadata>
+
+  <h:head>
+  </h:head>
+
+  <h:body>
+    <ds:windowId/>
+
+    <h:form id="form">
+      <h:outputLabel for="firstValue" value="First value"/>
+      <h:inputText id="firstValue" value="#{viewAccessScopedBeanX.value}"/>
+      <p/>
+      <h:outputLabel for="secondValue" value="Second value"/>
+      <h:inputText id="secondValue" value="#{viewAccessScopedBeanY.value}"/>
+      <p/>
+      <h:commandButton id="next" action="next.xhtml" value="Next"/>
+    </h:form>
+  </h:body>
+</f:view>
+
+</html>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/c0f74287/deltaspike/modules/jsf/impl/src/test/resources/viewAccessScopedContextTest/next.xhtml
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jsf/impl/src/test/resources/viewAccessScopedContextTest/next.xhtml
b/deltaspike/modules/jsf/impl/src/test/resources/viewAccessScopedContextTest/next.xhtml
new file mode 100755
index 0000000..59aa3f7
--- /dev/null
+++ b/deltaspike/modules/jsf/impl/src/test/resources/viewAccessScopedContextTest/next.xhtml
@@ -0,0 +1,21 @@
+<!DOCTYPE html>
+<html
+xmlns="http://www.w3.org/1999/xhtml"
+xmlns:h="http://xmlns.jcp.org/jsf/html"
+xmlns:f="http://xmlns.jcp.org/jsf/core"
+xmlns:ds="http://deltaspike.apache.org/jsf">
+
+<f:view>
+  <h:head>
+  </h:head>
+
+  <h:body>
+    <ds:windowId/>
+    <h:outputText id="firstValue" value="#{viewAccessScopedBeanX.value}"/>
+    <p/>
+    <h:outputText id="secondValue" value="#{viewAccessScopedBeanY.value}"/>
+    <p/>
+  </h:body>
+</f:view>
+
+</html>
\ No newline at end of file


Mime
View raw message