- Added some tests for the FlexJSStore example

Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/34998d82
Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/34998d82
Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/34998d82

Branch: refs/heads/develop
Commit: 34998d828f850c0e422525a1d456fdbe76692c9c
Parents: 060352c
Author: Christofer Dutz <christofer.d...@codecentric.de>
Authored: Fri Jan 13 16:07:13 2017 +0100
Committer: Christofer Dutz <christofer.d...@codecentric.de>
Committed: Fri Jan 13 16:07:13 2017 +0100

----------------------------------------------------------------------
 examples/examples-integrationtests/pom.xml      |   5 +
 .../apache/flex/flexjs/examples/AbstractIT.java |  35 ++++++
 .../flex/flexjs/examples/HelloWorldIT.java      |  57 ----------
 .../examples/flexjsstore/FlexJSStoreIT.java     | 108 +++++++++++++++++++
 .../examples/helloworld/HelloWorldIT.java       |  44 ++++++++
 5 files changed, 192 insertions(+), 57 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/34998d82/examples/examples-integrationtests/pom.xml
----------------------------------------------------------------------
diff --git a/examples/examples-integrationtests/pom.xml 
b/examples/examples-integrationtests/pom.xml
index a774717..c4a62d8 100644
--- a/examples/examples-integrationtests/pom.xml
+++ b/examples/examples-integrationtests/pom.xml
@@ -56,6 +56,11 @@
                 </goals>
               </execution>
             </executions>
+            <configuration>
+              <excludes>
+                <exclude>**/Abstract*.java</exclude>
+              </excludes>
+            </configuration>
           </plugin>
 
           <plugin>

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/34998d82/examples/examples-integrationtests/src/test/java/org/apache/flex/flexjs/examples/AbstractIT.java
----------------------------------------------------------------------
diff --git 
a/examples/examples-integrationtests/src/test/java/org/apache/flex/flexjs/examples/AbstractIT.java
 
b/examples/examples-integrationtests/src/test/java/org/apache/flex/flexjs/examples/AbstractIT.java
new file mode 100644
index 0000000..e9c5b89
--- /dev/null
+++ 
b/examples/examples-integrationtests/src/test/java/org/apache/flex/flexjs/examples/AbstractIT.java
@@ -0,0 +1,35 @@
+package org.apache.flex.flexjs.examples;
+
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.openqa.selenium.firefox.FirefoxDriver;
+
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Created by christoferdutz on 13.01.17.
+ */
+public abstract class AbstractIT {
+
+    protected static FirefoxDriver driver;
+
+    @BeforeClass
+    public static void openBrowser() {
+        driver = new FirefoxDriver();
+        driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
+    }
+
+    @AfterClass
+    public static void closeBrowser() {
+        if(driver != null) {
+            driver.quit();
+        }
+    }
+
+    protected void initTest() {
+        driver.get("http://localhost:8082/"+ getContext() +"/index.html");
+    }
+
+    protected abstract String getContext();
+
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/34998d82/examples/examples-integrationtests/src/test/java/org/apache/flex/flexjs/examples/HelloWorldIT.java
----------------------------------------------------------------------
diff --git 
a/examples/examples-integrationtests/src/test/java/org/apache/flex/flexjs/examples/HelloWorldIT.java
 
b/examples/examples-integrationtests/src/test/java/org/apache/flex/flexjs/examples/HelloWorldIT.java
deleted file mode 100644
index be43d25..0000000
--- 
a/examples/examples-integrationtests/src/test/java/org/apache/flex/flexjs/examples/HelloWorldIT.java
+++ /dev/null
@@ -1,57 +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.flex.flexjs.examples;
-
-import org.junit.AfterClass;
-import org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.openqa.selenium.By;
-import org.openqa.selenium.WebElement;
-import org.openqa.selenium.firefox.FirefoxDriver;
-
-import java.util.concurrent.TimeUnit;
-
-public class HelloWorldIT {
-
-    private static FirefoxDriver driver;
-
-    @BeforeClass
-    public static void openBrowser() {
-        //System.setProperty("webdriver.gecko.driver", 
"/Users/christoferdutz/Devtools/geckodriver");
-        driver = new FirefoxDriver();
-        driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
-    }
-
-    @AfterClass
-    public static void closeBrowser() {
-        driver.quit();
-    }
-
-    @Test
-    public void testApplication() {
-        driver.get("http://localhost:8082/HelloWorld/index.html";);
-        WebElement element = 
driver.findElement(By.xpath(".//span[@class='Label']"));
-        Assert.assertNotNull(element);
-        String content = element.getText();
-        Assert.assertEquals("Hello World!", content);
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/34998d82/examples/examples-integrationtests/src/test/java/org/apache/flex/flexjs/examples/flexjsstore/FlexJSStoreIT.java
----------------------------------------------------------------------
diff --git 
a/examples/examples-integrationtests/src/test/java/org/apache/flex/flexjs/examples/flexjsstore/FlexJSStoreIT.java
 
b/examples/examples-integrationtests/src/test/java/org/apache/flex/flexjs/examples/flexjsstore/FlexJSStoreIT.java
new file mode 100644
index 0000000..50eef73
--- /dev/null
+++ 
b/examples/examples-integrationtests/src/test/java/org/apache/flex/flexjs/examples/flexjsstore/FlexJSStoreIT.java
@@ -0,0 +1,108 @@
+package org.apache.flex.flexjs.examples.flexjsstore;
+
+import org.apache.flex.flexjs.examples.AbstractIT;
+import org.junit.Assert;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.openqa.selenium.Alert;
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebElement;
+
+/**
+ * Created by christoferdutz on 13.01.17.
+ */
+public class FlexJSStoreIT extends AbstractIT {
+
+    @Override
+    protected String getContext() {
+        return "FlexJSStore";
+    }
+
+    @Test
+    public void testDeveloperSearch() {
+        initTest();
+
+        // Get the developerSearch input field.
+        WebElement developerSearchInput = 
driver.findElement(By.id("developerSearchInput"));
+        Assert.assertNotNull(developerSearchInput);
+        Assert.assertEquals(developerSearchInput.getTagName(), "input");
+
+        // Enter "Test" into the input field.
+        developerSearchInput.sendKeys("Test");
+
+        // Get the "Go" button.
+        WebElement developerSearchButton = 
driver.findElement(By.id("developerSearchButton"));
+        Assert.assertNotNull(developerSearchButton);
+        Assert.assertEquals(developerSearchButton.getTagName(), "button");
+
+        // Click on the "Go" button.
+        developerSearchButton.click();
+
+        // Unfortunately this feature is not yet implemented, so we have to 
close the popup again.
+        Alert alert = driver.switchTo().alert();
+        Assert.assertNotNull(alert);
+        Assert.assertEquals("This feature is not implemented in this sample", 
alert.getText());
+        alert.accept();
+    }
+
+    @Test
+    @Ignore("Commented out till FLEX-35243 is fixed")
+    public void testNavigation() {
+        initTest();
+
+        // Get the "Home" button.
+        WebElement homeButton = driver.findElement(By.id("homeButton"));
+        Assert.assertNotNull(homeButton);
+        Assert.assertEquals(homeButton.getTagName(), "button");
+
+        // Get the "Products" button.
+        WebElement productsButton = 
driver.findElement(By.id("productsButton"));
+        Assert.assertNotNull(productsButton);
+        Assert.assertEquals(productsButton.getTagName(), "button");
+
+        // Get the "Support" button.
+        WebElement supportButton = driver.findElement(By.id("supportButton"));
+        Assert.assertNotNull(supportButton);
+        Assert.assertEquals(supportButton.getTagName(), "button");
+
+        // Click on the "products" button.
+        productsButton.click();
+        // Wait for the transition to be finished.
+        String classes = homeButton.getAttribute("class");
+        Assert.assertNotNull(classes);
+        Assert.assertFalse(classes.contains("toggleTextButton_Selected"));
+        classes = productsButton.getAttribute("class");
+        Assert.assertNotNull(classes);
+        Assert.assertTrue(classes.contains("toggleTextButton_Selected"));
+        classes = supportButton.getAttribute("class");
+        Assert.assertNotNull(classes);
+        Assert.assertFalse(classes.contains("toggleTextButton_Selected"));
+
+        // Click on the "support" button.
+        supportButton.click();
+        // Wait for the transition to be finished.
+        classes = homeButton.getAttribute("class");
+        Assert.assertNotNull(classes);
+        Assert.assertFalse(classes.contains("toggleTextButton_Selected"));
+        classes = productsButton.getAttribute("class");
+        Assert.assertNotNull(classes);
+        Assert.assertFalse(classes.contains("toggleTextButton_Selected"));
+        classes = supportButton.getAttribute("class");
+        Assert.assertNotNull(classes);
+        Assert.assertTrue(classes.contains("toggleTextButton_Selected"));
+
+        // Click on the "home" button.
+        homeButton.click();
+        // Wait for the transition to be finished.
+        classes = homeButton.getAttribute("class");
+        Assert.assertNotNull(classes);
+        Assert.assertTrue(classes.contains("toggleTextButton_Selected"));
+        classes = productsButton.getAttribute("class");
+        Assert.assertNotNull(classes);
+        Assert.assertFalse(classes.contains("toggleTextButton_Selected"));
+        classes = supportButton.getAttribute("class");
+        Assert.assertNotNull(classes);
+        Assert.assertFalse(classes.contains("toggleTextButton_Selected"));
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/34998d82/examples/examples-integrationtests/src/test/java/org/apache/flex/flexjs/examples/helloworld/HelloWorldIT.java
----------------------------------------------------------------------
diff --git 
a/examples/examples-integrationtests/src/test/java/org/apache/flex/flexjs/examples/helloworld/HelloWorldIT.java
 
b/examples/examples-integrationtests/src/test/java/org/apache/flex/flexjs/examples/helloworld/HelloWorldIT.java
new file mode 100644
index 0000000..0bd1e50
--- /dev/null
+++ 
b/examples/examples-integrationtests/src/test/java/org/apache/flex/flexjs/examples/helloworld/HelloWorldIT.java
@@ -0,0 +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.flex.flexjs.examples.helloworld;
+
+import org.apache.flex.flexjs.examples.AbstractIT;
+import org.junit.Assert;
+import org.junit.Test;
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebElement;
+
+public class HelloWorldIT extends AbstractIT {
+
+    @Override
+    protected String getContext() {
+        return "HelloWorld";
+    }
+
+    @Test
+    public void testApplication() {
+        initTest();
+        WebElement element = 
driver.findElement(By.xpath(".//span[@class='Label']"));
+        Assert.assertNotNull(element);
+        String content = element.getText();
+        Assert.assertEquals("Hello World!", content);
+    }
+
+}

Reply via email to