You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by jg...@apache.org on 2019/01/03 16:51:36 UTC

[tomee] 01/04: WIP start setting up some tests for the MVC-CXF application

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 34315c9d450d1a47422dbb0b37f664be3762fe5f
Author: Jonathan Gallimore <jo...@jrg.me.uk>
AuthorDate: Thu Jan 3 09:37:38 2019 +0000

    WIP start setting up some tests for the MVC-CXF application
---
 examples/mvc-cxf/pom.xml                           | 43 ++++++++++++-
 .../src/test/java/org/superbiz/mvc/MVCTest.java    | 74 ++++++++++++++++++++++
 examples/mvc-cxf/src/test/resources/arquillian.xml | 31 +++++++++
 3 files changed, 147 insertions(+), 1 deletion(-)

diff --git a/examples/mvc-cxf/pom.xml b/examples/mvc-cxf/pom.xml
index c0f5bb2..6f1afb7 100644
--- a/examples/mvc-cxf/pom.xml
+++ b/examples/mvc-cxf/pom.xml
@@ -35,7 +35,9 @@
     <tomee.version>8.0.0-SNAPSHOT</tomee.version>
     <version.deltaspike>1.9.0</version.deltaspike>
     <version.ozark>1.0.0-m04</version.ozark>
-  </properties>
+    <version.arquillian>1.1.13.Final</version.arquillian>
+    <version.graphene.webdriver>2.3.1</version.graphene.webdriver>
+   </properties>
 
   <build>
     <finalName>mvc-cxf</finalName>
@@ -122,6 +124,45 @@
       <artifactId>eclipselink</artifactId>
       <version>2.6.3</version>     
     </dependency>
+
+     <!--  tests  -->
+     <dependency>
+      <groupId>org.jboss.arquillian.junit</groupId>
+      <artifactId>arquillian-junit-container</artifactId>
+      <version>${version.arquillian}</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.tomee</groupId>
+      <artifactId>arquillian-tomee-remote</artifactId>
+      <version>${tomee.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.jboss.arquillian.graphene</groupId>
+      <artifactId>graphene-webdriver</artifactId>
+      <version>${version.graphene.webdriver}</version>
+      <type>pom</type>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>4.11</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>com.github.cukespace</groupId>
+      <artifactId>cukespace-core</artifactId>
+      <version>1.6.7</version>
+      <scope>test</scope>
+      <exclusions>
+        <exclusion>
+          <groupId>org.jboss.shrinkwrap</groupId>
+          <artifactId>shrinkwrap-api</artifactId>
+        </exclusion>
+      </exclusions>
+    </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
new file mode 100644
index 0000000..cd54922
--- /dev/null
+++ b/examples/mvc-cxf/src/test/java/org/superbiz/mvc/MVCTest.java
@@ -0,0 +1,74 @@
+/**
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.superbiz.mvc;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+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.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.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;
+
+@RunWith(Arquillian.class)
+public class MVCTest {
+
+    @ArquillianResource
+    private URL base;
+
+    @Drone
+    private WebDriver webDriver;
+
+    @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");
+    }
+
+    @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 !"));
+    }
+}
\ No newline at end of file
diff --git a/examples/mvc-cxf/src/test/resources/arquillian.xml b/examples/mvc-cxf/src/test/resources/arquillian.xml
new file mode 100644
index 0000000..f792b09
--- /dev/null
+++ b/examples/mvc-cxf/src/test/resources/arquillian.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!--
+
+    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.
+-->
+<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">
+        <container qualifier="tomee" default="true">
+            <configuration>
+               <property name="httpPort">-1</property>
+               <property name="stopPort">-1</property>
+               <property name="ajpPort">-1</property>
+               <property name="dir">target/tomee</property>
+               <property name="appWorkingDir">target/arquillian-dump-dir</property>
+            </configuration>
+        </container>
+</arquillian>