You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lo...@apache.org on 2016/05/20 21:00:01 UTC

svn commit: r1744794 - in /myfaces/tobago/trunk/tobago-example/tobago-example-demo: pom.xml src/test/java/org/apache/myfaces/tobago/example/demo/ArquillianTest.java src/test/resources/arquillian.xml

Author: lofwyr
Date: Fri May 20 21:00:01 2016
New Revision: 1744794

URL: http://svn.apache.org/viewvc?rev=1744794&view=rev
Log:
TOBAGO-1473: draft for Arquillian test case
* complete the first test case

Modified:
    myfaces/tobago/trunk/tobago-example/tobago-example-demo/pom.xml
    myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/test/java/org/apache/myfaces/tobago/example/demo/ArquillianTest.java
    myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/test/resources/arquillian.xml

Modified: myfaces/tobago/trunk/tobago-example/tobago-example-demo/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-demo/pom.xml?rev=1744794&r1=1744793&r2=1744794&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-demo/pom.xml (original)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-demo/pom.xml Fri May 20 21:00:01 2016
@@ -30,7 +30,9 @@
   <properties>
     <openwebbeans.version>1.1.7</openwebbeans.version>
     <deltaspike.version>1.2.1</deltaspike.version>
-    <arquillian.browser>phantomjs</arquillian.browser>
+    <arquillian.browser>firefox</arquillian.browser>
+    <!-- phantomjs works not with CSP (report-only) -->
+    <!--<arquillian.browser>phantomjs</arquillian.browser>-->
   </properties>
   <build>
     <finalName>tobago-example-demo</finalName>

Modified: myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/test/java/org/apache/myfaces/tobago/example/demo/ArquillianTest.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/test/java/org/apache/myfaces/tobago/example/demo/ArquillianTest.java?rev=1744794&r1=1744793&r2=1744794&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/test/java/org/apache/myfaces/tobago/example/demo/ArquillianTest.java (original)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/test/java/org/apache/myfaces/tobago/example/demo/ArquillianTest.java Fri May 20 21:00:01 2016
@@ -19,11 +19,10 @@
 
 package org.apache.myfaces.tobago.example.demo;
 
-import java.net.URL;
-
 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.graphene.findby.FindByJQuery;
 import org.jboss.arquillian.junit.Arquillian;
 import org.jboss.arquillian.test.api.ArquillianResource;
 import org.jboss.shrinkwrap.api.ShrinkWrap;
@@ -36,41 +35,68 @@ import org.openqa.selenium.WebDriver;
 import org.openqa.selenium.WebElement;
 import org.openqa.selenium.support.FindBy;
 
+import java.net.URL;
+
 @RunWith(Arquillian.class)
 @RunAsClient
 public class ArquillianTest {
 
-    @Drone
-    private WebDriver browser;
+  @Drone
+  private WebDriver browser;
 
-    @ArquillianResource
-    private URL contextPath;
+  @ArquillianResource
+  private URL contextPath;
 
-    @FindBy(id = "page:i8::field")
-    private WebElement inputField;
+  @FindBy(id = "page:i8::field")
+  private WebElement input;
 
-    @FindBy(id = "page:outputfield")
-    private WebElement outputField;
-
-    @Deployment
-    public static WebArchive createDeployment() {
-        WebArchive webArchive = ShrinkWrap.create(MavenImporter.class).
-                loadPomFromFile("pom.xml", "jsf-provided", "!myfaces-2.0").importBuildOutput()
-                .as(WebArchive.class);
-        webArchive.addClass(ArquillianTest.class);
-        // XXX there should be a proper profile in POM for that
-        webArchive.delete("/WEB-INF/lib/hibernate-validator-4.3.2.Final.jar");
-        return webArchive;
+  @FindBy(id = "page:outputfield")
+  private WebElement output;
+
+  @FindByJQuery("#page\\:outputfield > label")
+  private WebElement outputLabel;
+
+  @FindByJQuery("#page\\:outputfield > span")
+  private WebElement outputField;
+
+  @Deployment
+  public static WebArchive createDeployment() {
+    WebArchive webArchive = ShrinkWrap.create(MavenImporter.class).
+        loadPomFromFile("pom.xml", "jsf-provided", "!myfaces-2.0").importBuildOutput()
+        .as(WebArchive.class);
+    webArchive.addClass(ArquillianTest.class);
+    // XXX there should be a proper profile in POM for that
+    webArchive.delete("/WEB-INF/lib/hibernate-validator-4.3.2.Final.jar");
+    return webArchive;
+  }
+
+  @Test
+  public void ajaxOnChange() {
+    browser.get(contextPath + "/faces/content/20-component/010-input/10-in/in.xhtml");
+
+    Assert.assertEquals("On Server", outputLabel.getText());
+    // TODO results in "Refused to evaluate a string as JavaScript because 'unsafe-eval'
+    // is not an allowed source of script in the following Content Security Policy directive"
+
+    Assert.assertEquals("", outputField.getText());
+
+    final String text = "Testtext";
+    input.sendKeys(text);
+    output.click();
+//    Graphene.waitAjax();
+/*
+    try {
+      Thread.sleep(30000);
+    } catch (InterruptedException e) {
+      e.printStackTrace();
     }
+*/
 
-    @Test
-    public void shouldCreate() {
-        browser.get(contextPath + "/faces/content/20-component/010-input/10-in/in.xhtml");
-
-        Assert.assertEquals("On Server", outputField.getText());
-        // TODO results in "Refused to evaluate a string as JavaScript because 'unsafe-eval'
-        // is not an allowed source of script in the following Content Security Policy directive"
-//        Graphene.guardAjax(inputField).sendKeys("Testtext");
+    Assert.assertEquals(text, outputField.getText());
 
-    }
+
+//    JavascriptExecutor js = (JavascriptExecutor) browser;
+//    js.executeScript("$(Tobago.Utils.escapeClientId('{}')).blur();", output.getAttribute("id"));
+
+  }
 }

Modified: myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/test/resources/arquillian.xml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/test/resources/arquillian.xml?rev=1744794&r1=1744793&r2=1744794&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/test/resources/arquillian.xml (original)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/test/resources/arquillian.xml Fri May 20 21:00:01 2016
@@ -1 +1 @@
-<arquillian xmlns="http://jboss.org/schema/arquillian"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:schemaLocation="http://jboss.org/schema/arquillian http://jboss.org/schema/arquillian/arquillian_1_0.xsd">
   <defaultProtocol type="Servlet 3.0"/>
<!--   <container qualifier="tomee" default="true">
      <configuration>
         <property name="httpPort">-1</property>
         <property name="stopPort">-1</property>
         <property name="cleanOnStartUp">true</property>
         <property name="appWorkingDir">${project.build.directory}/tomee-test</property>
         <property name="dir">${project.build.directory}/tomee</property>
         <property name="debug">${arquillian.remote.debug}</property>
         <property name="debugPort">5005</property>
         <property name="catalina_opts">${argLine} -Djava.security.auth.login.config=${project.basedir}/src/main/tomee/conf/jaas.config</property>
      </configuration>
   </container>-->
   <extension qualifier="webdriver">
      <property name="browser">${arquillian.browser}</property>
<!--      <property name="dimensions">1280x1024</property>
      <property name="reuseCookies">false</property>-->
   </extension>
   <extension qualifier="screenshooter">
      <property name="rootDir">${project.build.directory}/screenshots</property>
   </extension>
</arquillian>
\ No newline at end of file
+<arquillian xmlns="http://jboss.org/schema/arquillian"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:schemaLocation="http://jboss.org/schema/arquillian http://jboss.org/schema/arquillian/arquillian_1_0.xsd">
   <defaultProtocol type="Servlet 3.0"/>
   <container qualifier="tomee" default="true">
      <configuration>
         <property name="httpPort">-1</property>
         <property name="stopPort">-1</property>
         <!--<property name="cleanOnStartUp">true</property>-->
         <!--<property name="appWorkingDir">${project.build.directory}/tomee-test</property>-->
         <!--<property name="dir">${project.build.directory}/tomee</property>-->
         <!--<property name="debug">${arquillian.remote.debug}</property>-->
         <!--<property name="debugPort">5005</property>-->
         <!--<property name="catalina_opts">${argLine} -Djava.security.auth.login.config=${project.basedir}/src/main/tomee/conf/jaas.config</property>-->
      </configuration>
   </container>
   <extension qualifier="webdriver">
      <property name="browser">${arquillian.browser}</property>
<!--      <property name="dimensions">1280x1024</property>
      <property name="reuseCookies">false</property>-->
   </extension>
   <extension qualifier="screenshooter">
      <property name="rootDir">${project.build.directory}/screenshots</property>
   </extension>
</arquillian>
\ No newline at end of file