SLIDER-1147 Dynamically build tomcat test WAR at runtime

We build the test-war as a separate maven module and then
do a copy-resources to get at the artifact. Everything else
is the same for the groovy IT.
diff --git a/app-packages/pom.xml b/app-packages/pom.xml
index 013481e..f7b17eb 100644
--- a/app-packages/pom.xml
+++ b/app-packages/pom.xml
@@ -54,6 +54,7 @@
           <module>hbase</module>
           <module>kafka</module>
           <module>storm</module>
+          <module>tomcat-test-war</module>
           <module>tomcat</module>
         </modules>
       </profile>
@@ -88,6 +89,7 @@
           <module>storm</module>
           <module>hbase-win</module>
           <module>storm-win</module>
+          <module>tomcat-test-war</module>
           <module>tomcat</module>
         </modules>
       </profile>
diff --git a/app-packages/tomcat-test-war/pom.xml b/app-packages/tomcat-test-war/pom.xml
new file mode 100644
index 0000000..9ad2b6e
--- /dev/null
+++ b/app-packages/tomcat-test-war/pom.xml
@@ -0,0 +1,68 @@
+<?xml version="1.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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <parent>
+    <groupId>org.apache.slider.packages</groupId>
+    <artifactId>slider-app-packages</artifactId>
+    <version>0.91.0-incubating</version>
+    <relativePath>../pom.xml</relativePath>
+  </parent>
+  <modelVersion>4.0.0</modelVersion>
+  <artifactId>slider-tomcat-app-package-test-war</artifactId>
+  <packaging>war</packaging>
+  <name>Slider Tomcat App Package Testing WAR file</name>
+  <description>A WAR file that can be used to test the Tomcat app package.</description>
+  <build>
+    <plugins>
+      <plugin>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <version>${maven-compiler-plugin.version}</version>
+        <dependencies>
+          <dependency>
+            <groupId>org.codehaus.groovy</groupId>
+            <artifactId>groovy-eclipse-compiler</artifactId>
+            <version>${groovy-eclipse-compiler.version}</version>
+          </dependency>
+          <dependency>
+            <groupId>org.codehaus.groovy</groupId>
+            <artifactId>groovy-eclipse-batch</artifactId>
+            <version>${groovy-eclipse-batch.version}</version>
+          </dependency>
+        </dependencies>
+      </plugin>
+      <plugin>
+        <artifactId>maven-war-plugin</artifactId>
+        <configuration>
+          <classifier>test</classifier>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+  <dependencies>
+    <dependency>
+      <groupId>javax.ws.rs</groupId>
+      <artifactId>javax.ws.rs-api</artifactId>
+      <version>2.0.1</version>
+    </dependency>
+    <dependency>
+      <groupId>org.glassfish.jersey.containers</groupId>
+      <artifactId>jersey-container-servlet-core</artifactId>
+      <version>2.13</version>
+    </dependency>
+  </dependencies>
+</project>
diff --git a/app-packages/tomcat-test-war/src/main/java/org/apache/slider/war/RootResource.java b/app-packages/tomcat-test-war/src/main/java/org/apache/slider/war/RootResource.java
new file mode 100644
index 0000000..fe098c8
--- /dev/null
+++ b/app-packages/tomcat-test-war/src/main/java/org/apache/slider/war/RootResource.java
@@ -0,0 +1,41 @@
+/*
+ * 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.slider.packages.tomcat.war;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+
+/**
+ * Root resource
+ */
+@Path("/")
+public class RootResource {
+
+    /**
+     * Method handling HTTP GET requests. The returned object will be sent
+     * to the client as "text/plain" media type.
+     *
+     * @return String that will be returned as a text/plain response.
+     */
+    @GET
+    @Produces(MediaType.TEXT_PLAIN)
+    public String getIt() {
+        return "Success";
+    }
+}
diff --git a/app-packages/tomcat-test-war/src/main/webapp/WEB-INF/web.xml b/app-packages/tomcat-test-war/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000..3c0b696
--- /dev/null
+++ b/app-packages/tomcat-test-war/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+     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.
+     -->
+<!-- This web.xml file is not required when using Servlet 3.0 container,
+     see implementation details http://jersey.java.net/nonav/documentation/latest/jax-rs.html -->
+<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
+    <display-name>Apache Slider (incubating) Test WAR</display-name>
+    <servlet>
+        <servlet-name>Jersey Web Application</servlet-name>
+        <servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
+        <init-param>
+            <param-name>jersey.config.server.provider.packages</param-name>
+            <param-value>org.apache.slider.packages.tomcat.war</param-value>
+        </init-param>
+        <load-on-startup>1</load-on-startup>
+    </servlet>
+    <servlet-mapping>
+        <servlet-name>Jersey Web Application</servlet-name>
+        <url-pattern>/*</url-pattern>
+    </servlet-mapping>
+</web-app>
diff --git a/app-packages/tomcat/README.md b/app-packages/tomcat/README.md
index ff77c80..bfabc07 100644
--- a/app-packages/tomcat/README.md
+++ b/app-packages/tomcat/README.md
@@ -57,8 +57,3 @@
 Check the Slider Application Master page on the Hadoop YARN status page. You should see
 the application running and without failures. The address of the Tomcat servers will be listed
 as exports on the AppMaster's web UI.
-
-# Slider Automated Testing
-
-The provided slider-test.war is built using https://github.com/joshelser/simple-rest-war. Modifications
-of that WAR file can be made using that codebase and including the binary test resource here.
diff --git a/app-packages/tomcat/appConfig-default.json b/app-packages/tomcat/appConfig-default.json
index 84183ca..5004b68 100644
--- a/app-packages/tomcat/appConfig-default.json
+++ b/app-packages/tomcat/appConfig-default.json
@@ -13,7 +13,8 @@
     "site.server-xml.http.port":"${TOMCAT.ALLOCATED_PORT}{PER_CONTAINER}",
     "site.server-xml.connection.timeout":"20000",
     "site.tomcat-users-xml.ui_user": "tomcat",
-    "site.tomcat-users-xml.ui_password": "password"
+    "site.tomcat-users-xml.ui_password": "password",
+    "agent.python.exec.path": "/usr/local/bin/python"
   },
   "components": {
     "slider-appmaster": {
diff --git a/app-packages/tomcat/pom.xml b/app-packages/tomcat/pom.xml
index a94aa50..c2be868 100644
--- a/app-packages/tomcat/pom.xml
+++ b/app-packages/tomcat/pom.xml
@@ -112,6 +112,7 @@
               <systemPropertyVariables>
                 <java.net.preferIPv4Stack>true</java.net.preferIPv4Stack>
                 <java.awt.headless>true</java.awt.headless>
+                <project.build.directory>${project.build.directory}</project.build.directory>
                 <!-- this property must be supplied-->
                 <slider.conf.dir>${slider.conf.dir}</slider.conf.dir>
                 <slider.bin.dir>${slider.bin.dir}</slider.bin.dir>
@@ -147,7 +148,6 @@
             <configuration>
               <excludes>
                 <exclude>**/*.json</exclude>
-                <exclude>src/test/resources/slider-test.war</exclude>
                 <exclude>**/*.iml</exclude>
               </excludes>
             </configuration>
@@ -192,6 +192,31 @@
           </dependency>
         </dependencies>
       </plugin>
+      <plugin>
+        <artifactId>maven-dependency-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>copy-test-war</id>
+            <phase>pre-integration-test</phase>
+            <goals>
+              <goal>copy</goal>
+            </goals>
+            <configuration>
+              <artifactItems>
+                <artifactItem>
+                  <groupId>org.apache.slider.packages</groupId>
+                  <artifactId>slider-tomcat-app-package-test-war</artifactId>
+                  <version>${project.version}</version>
+                  <classifier>test</classifier>
+                  <type>war</type>
+                  <destFileName>slider-test.war</destFileName>
+                </artifactItem>
+              </artifactItems>
+              <outputDirectory>${project.build.directory}</outputDirectory>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
     </plugins>
   </build>
   <dependencies>
@@ -237,5 +262,12 @@
       <artifactId>slf4j-api</artifactId>
       <scope>test</scope>
     </dependency>
+    <dependency>
+      <groupId>org.apache.slider.packages</groupId>
+      <artifactId>slider-tomcat-app-package-test-war</artifactId>
+      <version>${project.version}</version>
+      <type>war</type>
+      <scope>test</scope>
+    </dependency>
   </dependencies>
 </project>
diff --git a/app-packages/tomcat/src/test/groovy/org/apache/slider/funtest/tomcat/TomcatBasicIT.groovy b/app-packages/tomcat/src/test/groovy/org/apache/slider/funtest/tomcat/TomcatBasicIT.groovy
index d77897f..369c96f 100644
--- a/app-packages/tomcat/src/test/groovy/org/apache/slider/funtest/tomcat/TomcatBasicIT.groovy
+++ b/app-packages/tomcat/src/test/groovy/org/apache/slider/funtest/tomcat/TomcatBasicIT.groovy
@@ -74,7 +74,7 @@
     Configuration conf = new Configuration()
     FileSystem fs = FileSystem.getLocal(conf)
     // The path from the local filesystem of the war (copied to target/test-classes from src/test/resources)
-    Path sourcePath = fs.makeQualified(new Path(sysprop("test-classes.dir") + "/slider-test.war"))
+    Path sourcePath = fs.makeQualified(new Path(sysprop("project.build.directory"), "slider-test.war"))
     // Path in HDFS we'll put the WAR
     Path targetPath = clusterFS.makeQualified(new Path("/tmp/slider-test.war"))
     if (clusterFS.exists(targetPath)) {
@@ -185,7 +185,7 @@
         return httpAddress
       } catch (Exception e) {
         caught = e;
-        log.info("Got exception trying to read quicklinks")
+        log.info("Got exception trying to read quicklinks", e)
         if (tries-- == 0) {
           break
         }
diff --git a/app-packages/tomcat/src/test/resources/appConfig-default.json b/app-packages/tomcat/src/test/resources/appConfig-default.json
deleted file mode 100644
index 009838c..0000000
--- a/app-packages/tomcat/src/test/resources/appConfig-default.json
+++ /dev/null
@@ -1,23 +0,0 @@
-{
-  "schema": "http://example.org/specification/v2.0.0",
-  "metadata": {
-  },
-  "global": {
-    "application.def": ".slider/package/tomcat/slider-tomcat-app-package.zip",
-    "java_home": "/usr/jdk64/jdk1.7.0_67",
-    "application.resources": "hdfs://localhost:8020/user/jelser/my_application.war",
-
-    "site.global.xmx_val": "1g",
-    "site.global.xms_val": "128m",
-    "site.global.memory_val": "200M",
-    "site.server-xml.http.port":"${TOMCAT.ALLOCATED_PORT}",
-    "site.server-xml.connection.timeout":"20000",
-    "site.tomcat-users-xml.ui.user": "tomcat",
-    "site.tomcat-users-xml.ui.password": "password"
-  },
-  "components": {
-    "slider-appmaster": {
-      "jvm.heapsize": "128M"
-    }
-  }
-}
diff --git a/app-packages/tomcat/src/test/resources/slider-test.war b/app-packages/tomcat/src/test/resources/slider-test.war
deleted file mode 100644
index 7410435..0000000
--- a/app-packages/tomcat/src/test/resources/slider-test.war
+++ /dev/null
Binary files differ