tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jgallim...@apache.org
Subject [tomee] 02/04: Basic Selenium happy-path test
Date Thu, 03 Jan 2019 16:51:37 GMT
This is an automated email from the ASF dual-hosted git repository.

jgallimore pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tomee.git

commit 573272e4412484d30cee88b1306df9926e7e3fd9
Author: Jonathan Gallimore <jon@jrg.me.uk>
AuthorDate: Thu Jan 3 14:58:13 2019 +0000

    Basic Selenium happy-path test
---
 examples/mvc-cxf/pom.xml                           |  7 ++-
 .../src/test/java/org/superbiz/mvc/MVCTest.java    | 67 +++++++++++++---------
 2 files changed, 47 insertions(+), 27 deletions(-)

diff --git a/examples/mvc-cxf/pom.xml b/examples/mvc-cxf/pom.xml
index 6f1afb7..2653c67 100644
--- a/examples/mvc-cxf/pom.xml
+++ b/examples/mvc-cxf/pom.xml
@@ -162,7 +162,12 @@
         </exclusion>
       </exclusions>
     </dependency>
-
+    <dependency>
+      <groupId>org.apache.tomee</groupId>
+      <artifactId>ziplock</artifactId>
+      <version>8.0.0-SNAPSHOT</version>
+      <scope>test</scope>
+    </dependency>
   </dependencies>
 
   <!--
diff --git a/examples/mvc-cxf/src/test/java/org/superbiz/mvc/MVCTest.java b/examples/mvc-cxf/src/test/java/org/superbiz/mvc/MVCTest.java
index cd54922..ac51143 100644
--- a/examples/mvc-cxf/src/test/java/org/superbiz/mvc/MVCTest.java
+++ b/examples/mvc-cxf/src/test/java/org/superbiz/mvc/MVCTest.java
@@ -16,26 +16,26 @@
  */
 package org.superbiz.mvc;
 
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-import java.io.File;
-import java.net.URL;
-
+import org.apache.ziplock.maven.Mvn;
 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.shrinkwrap.api.ShrinkWrap;
-import org.jboss.shrinkwrap.api.asset.EmptyAsset;
+import org.jboss.shrinkwrap.api.Archive;
 import org.jboss.shrinkwrap.api.spec.WebArchive;
-import org.jboss.shrinkwrap.resolver.api.maven.Maven;
 import org.junit.Test;
 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.Select;
+
+import java.net.URL;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
 
 @RunWith(Arquillian.class)
 public class MVCTest {
@@ -48,27 +48,42 @@ public class MVCTest {
 
     @Deployment
     public static WebArchive createDeployment() {
-        File[] files = Maven.resolver()
-                            .loadPomFromFile("pom.xml")
-                            .importRuntimeDependencies()
-                            .resolve()
-                            .withTransitivity()
-                            .asFile();
 
-        return ShrinkWrap.create(WebArchive.class, "test.war")
-                         .addPackages(true, "org.superbiz.mvc")
-                         .addAsLibraries(files)
-                         .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml")
-                         .addAsWebInfResource(new File("src/main/webapp/WEB-INF/web.xml"),
"/web.xml")
-                         .addAsWebInfResource(new File("src/main/webapp/WEB-INF/views/hello.jsp"),
"/views/hello.jsp");
+        final Archive<?> war = Mvn.war();
+        System.out.println(war.toString(true));
+        return (WebArchive) war;
     }
 
     @Test
     @RunAsClient
-    public void test() {
-        webDriver.get(this.base.toExternalForm() + "app/hello?name=TomEE");
-        WebElement h1 = webDriver.findElement(By.tagName("h1"));
-        assertNotNull(h1);
-        assertTrue(h1.getText().contains("Welcome TomEE !"));
+    public void testAssertUserCanBeAdded() throws Exception {
+        webDriver.get(this.base.toExternalForm() + "app/home");
+        webDriver.findElement(By.linkText("Peoples")).click();
+        webDriver.findElement(By.linkText("Add Registres")).click();
+        webDriver.findElement(By.id("name")).click();
+        webDriver.findElement(By.id("name")).clear();
+        webDriver.findElement(By.id("name")).sendKeys("Joe Bloggs");
+        webDriver.findElement(By.id("age")).clear();
+        webDriver.findElement(By.id("age")).sendKeys("42");
+        webDriver.findElement(By.id("state")).clear();
+        webDriver.findElement(By.id("state")).sendKeys("California");
+        webDriver.findElement(By.name("server")).click();
+        webDriver.findElement(By.id("country")).click();
+        new Select(webDriver.findElement(By.id("country"))).selectByVisibleText("United States");
+        webDriver.findElement(By.id("description")).click();
+        webDriver.findElement(By.id("description")).clear();
+        webDriver.findElement(By.id("description")).sendKeys("This is a test");
+        webDriver.findElement(By.xpath("(.//*[normalize-space(text()) and normalize-space(.)='Description:'])[1]/following::button[1]")).click();
+
+        final WebElement element = webDriver.findElement(By.id("success-alert"));
+        assertNotNull(element);
+        assertTrue(element.getText().contains("Joe Bloggs was successfully registered"));
+
+        assertEquals("Joe Bloggs", webDriver.findElement(By.xpath("//*[@id=\"tableData\"]/tbody/tr[1]/td[1]")).getText());
+        assertEquals("42", webDriver.findElement(By.xpath("//*[@id=\"tableData\"]/tbody/tr[1]/td[2]")).getText());
+        assertEquals("United States", webDriver.findElement(By.xpath("//*[@id=\"tableData\"]/tbody/tr[1]/td[3]")).getText());
+        assertEquals("California", webDriver.findElement(By.xpath("//*[@id=\"tableData\"]/tbody/tr[1]/td[4]")).getText());
+        assertEquals("TomEE", webDriver.findElement(By.xpath("//*[@id=\"tableData\"]/tbody/tr[1]/td[5]")).getText());
+        assertEquals("This is a test", webDriver.findElement(By.xpath("//*[@id=\"tableData\"]/tbody/tr[1]/td[6]")).getText());
     }
 }
\ No newline at end of file


Mime
View raw message