From 8146001093333df87296d2f96f8a32df16d737bf Mon Sep 17 00:00:00 2001 From: olivier lamy Date: Sat, 24 Jun 2017 21:27:24 +1000 Subject: [PATCH] add it test for run war exploded mojo Signed-off-by: olivier lamy --- .../invoker.properties | 2 + .../jetty-simple-base/pom.xml | 50 ++++++++ .../its/jetty_run_mojo_it/HelloServlet.java | 45 +++++++ .../its/jetty_run_mojo_it/PingServlet.java | 41 ++++++ .../main/resources/META-INF/web-fragment.xml | 32 +++++ .../jetty-simple-webapp/pom.xml | 121 ++++++++++++++++++ .../src/main/webapp/WEB-INF/web.xml | 7 + .../jetty_run_mojo_it/TestHelloServlet.java | 59 +++++++++ .../it/jetty-run-war-exploded-mojo-it/pom.xml | 90 +++++++++++++ 9 files changed, 447 insertions(+) create mode 100644 jetty-maven-plugin/src/it/jetty-run-war-exploded-mojo-it/invoker.properties create mode 100644 jetty-maven-plugin/src/it/jetty-run-war-exploded-mojo-it/jetty-simple-base/pom.xml create mode 100644 jetty-maven-plugin/src/it/jetty-run-war-exploded-mojo-it/jetty-simple-base/src/main/java/com/webtide/jetty/its/jetty_run_mojo_it/HelloServlet.java create mode 100644 jetty-maven-plugin/src/it/jetty-run-war-exploded-mojo-it/jetty-simple-base/src/main/java/com/webtide/jetty/its/jetty_run_mojo_it/PingServlet.java create mode 100644 jetty-maven-plugin/src/it/jetty-run-war-exploded-mojo-it/jetty-simple-base/src/main/resources/META-INF/web-fragment.xml create mode 100644 jetty-maven-plugin/src/it/jetty-run-war-exploded-mojo-it/jetty-simple-webapp/pom.xml create mode 100644 jetty-maven-plugin/src/it/jetty-run-war-exploded-mojo-it/jetty-simple-webapp/src/main/webapp/WEB-INF/web.xml create mode 100644 jetty-maven-plugin/src/it/jetty-run-war-exploded-mojo-it/jetty-simple-webapp/src/test/java/com/webtide/jetty/its/jetty_run_mojo_it/TestHelloServlet.java create mode 100644 jetty-maven-plugin/src/it/jetty-run-war-exploded-mojo-it/pom.xml diff --git a/jetty-maven-plugin/src/it/jetty-run-war-exploded-mojo-it/invoker.properties b/jetty-maven-plugin/src/it/jetty-run-war-exploded-mojo-it/invoker.properties new file mode 100644 index 00000000000..161dd58f0af --- /dev/null +++ b/jetty-maven-plugin/src/it/jetty-run-war-exploded-mojo-it/invoker.properties @@ -0,0 +1,2 @@ +invoker.goals = verify +#test-compile failsafe:integration-test \ No newline at end of file diff --git a/jetty-maven-plugin/src/it/jetty-run-war-exploded-mojo-it/jetty-simple-base/pom.xml b/jetty-maven-plugin/src/it/jetty-run-war-exploded-mojo-it/jetty-simple-base/pom.xml new file mode 100644 index 00000000000..4425c34f117 --- /dev/null +++ b/jetty-maven-plugin/src/it/jetty-run-war-exploded-mojo-it/jetty-simple-base/pom.xml @@ -0,0 +1,50 @@ + + + 4.0.0 + + + com.webtide.jetty.its.jetty-run-war-exploded-mojo-it + jetty-simple-project + 0.0.1-SNAPSHOT + + + jetty-simple-base + jar + + Jetty :: Simple :: Base + + + + + javax.servlet + javax.servlet-api + jar + provided + + + + org.slf4j + slf4j-api + + + + commons-io + commons-io + + + + org.eclipse.jetty.toolchain + jetty-perf-helper + 1.0.5 + + + + com.fasterxml.jackson.core + jackson-databind + 2.8.1 + + + + + diff --git a/jetty-maven-plugin/src/it/jetty-run-war-exploded-mojo-it/jetty-simple-base/src/main/java/com/webtide/jetty/its/jetty_run_mojo_it/HelloServlet.java b/jetty-maven-plugin/src/it/jetty-run-war-exploded-mojo-it/jetty-simple-base/src/main/java/com/webtide/jetty/its/jetty_run_mojo_it/HelloServlet.java new file mode 100644 index 00000000000..a6d2a3e256d --- /dev/null +++ b/jetty-maven-plugin/src/it/jetty-run-war-exploded-mojo-it/jetty-simple-base/src/main/java/com/webtide/jetty/its/jetty_run_mojo_it/HelloServlet.java @@ -0,0 +1,45 @@ +// +// ======================================================================== +// Copyright (c) 1995-2017 Mort Bay Consulting Pty. Ltd. +// ------------------------------------------------------------------------ +// All rights reserved. This program and the accompanying materials +// are made available under the terms of the Eclipse Public License v1.0 +// and Apache License v2.0 which accompanies this distribution. +// +// The Eclipse Public License is available at +// http://www.eclipse.org/legal/epl-v10.html +// +// The Apache License v2.0 is available at +// http://www.opensource.org/licenses/apache2.0.php +// +// You may elect to redistribute this code under either of these licenses. +// ======================================================================== +// + + +package com.webtide.jetty.its.jetty_run_mojo_it; + +import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; + +/** + * + */ +@WebServlet("/hello") +public class HelloServlet + extends HttpServlet +{ + + @Override + protected void doGet( HttpServletRequest req, HttpServletResponse resp ) + throws ServletException, IOException + { + String who = req.getParameter( "name" ); + + resp.getWriter().write( "hello " + (who == null ? "unknown" : who) ); + } +} diff --git a/jetty-maven-plugin/src/it/jetty-run-war-exploded-mojo-it/jetty-simple-base/src/main/java/com/webtide/jetty/its/jetty_run_mojo_it/PingServlet.java b/jetty-maven-plugin/src/it/jetty-run-war-exploded-mojo-it/jetty-simple-base/src/main/java/com/webtide/jetty/its/jetty_run_mojo_it/PingServlet.java new file mode 100644 index 00000000000..f5686592252 --- /dev/null +++ b/jetty-maven-plugin/src/it/jetty-run-war-exploded-mojo-it/jetty-simple-base/src/main/java/com/webtide/jetty/its/jetty_run_mojo_it/PingServlet.java @@ -0,0 +1,41 @@ +// +// ======================================================================== +// Copyright (c) 1995-2017 Mort Bay Consulting Pty. Ltd. +// ------------------------------------------------------------------------ +// All rights reserved. This program and the accompanying materials +// are made available under the terms of the Eclipse Public License v1.0 +// and Apache License v2.0 which accompanies this distribution. +// +// The Eclipse Public License is available at +// http://www.eclipse.org/legal/epl-v10.html +// +// The Apache License v2.0 is available at +// http://www.opensource.org/licenses/apache2.0.php +// +// You may elect to redistribute this code under either of these licenses. +// ======================================================================== +// + + +package com.webtide.jetty.its.jetty_run_mojo_it; + +import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; + +public class PingServlet + extends HttpServlet +{ + + @Override + protected void doGet( HttpServletRequest req, HttpServletResponse resp ) + throws ServletException, IOException + { + String who = req.getParameter( "name" ); + + resp.getWriter().write( "pong " + (who == null ? "unknown" : who) ); + } +} diff --git a/jetty-maven-plugin/src/it/jetty-run-war-exploded-mojo-it/jetty-simple-base/src/main/resources/META-INF/web-fragment.xml b/jetty-maven-plugin/src/it/jetty-run-war-exploded-mojo-it/jetty-simple-base/src/main/resources/META-INF/web-fragment.xml new file mode 100644 index 00000000000..031012f7fed --- /dev/null +++ b/jetty-maven-plugin/src/it/jetty-run-war-exploded-mojo-it/jetty-simple-base/src/main/resources/META-INF/web-fragment.xml @@ -0,0 +1,32 @@ + + + + + FragmentA + + + + + + + Ping + com.webtide.jetty.its.jetty_run_mojo_it.PingServlet + + extra1123 + + + extra2345 + + + + + Ping + /ping + + + + \ No newline at end of file diff --git a/jetty-maven-plugin/src/it/jetty-run-war-exploded-mojo-it/jetty-simple-webapp/pom.xml b/jetty-maven-plugin/src/it/jetty-run-war-exploded-mojo-it/jetty-simple-webapp/pom.xml new file mode 100644 index 00000000000..0489e0e1a2c --- /dev/null +++ b/jetty-maven-plugin/src/it/jetty-run-war-exploded-mojo-it/jetty-simple-webapp/pom.xml @@ -0,0 +1,121 @@ + + + 4.0.0 + + + com.webtide.jetty.its.jetty-run-war-exploded-mojo-it + jetty-simple-project + 0.0.1-SNAPSHOT + + + jetty-simple-webapp + war + + Jetty :: Simple :: Webapp + + + + + com.webtide.jetty.its.jetty-run-war-exploded-mojo-it + jetty-simple-base + + + + org.eclipse.jetty + jetty-servlet + provided + + + + org.eclipse.jetty + jetty-client + @project.version@ + test + + + + junit + junit + 4.12 + test + + + + + + + + + org.apache.maven.plugins + maven-war-plugin + ${maven-war-plugin-version} + + false + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.20 + + true + + @jetty.runPort@ + + + + + org.apache.maven.plugins + maven-failsafe-plugin + 2.20 + + + @jetty.runPort@ + + + **/*TestHelloServlet* + + + + + integration-test + + integration-test + + + + verify + + verify + + + + + + org.eclipse.jetty + jetty-maven-plugin + + + start-jetty + test-compile + + run-exploded + + + true + + @jetty.runPort@ + + + + + + + + + + diff --git a/jetty-maven-plugin/src/it/jetty-run-war-exploded-mojo-it/jetty-simple-webapp/src/main/webapp/WEB-INF/web.xml b/jetty-maven-plugin/src/it/jetty-run-war-exploded-mojo-it/jetty-simple-webapp/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 00000000000..2a5ac4b71bf --- /dev/null +++ b/jetty-maven-plugin/src/it/jetty-run-war-exploded-mojo-it/jetty-simple-webapp/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,7 @@ + + + Jetty Simple Webapp run-mojo-it + diff --git a/jetty-maven-plugin/src/it/jetty-run-war-exploded-mojo-it/jetty-simple-webapp/src/test/java/com/webtide/jetty/its/jetty_run_mojo_it/TestHelloServlet.java b/jetty-maven-plugin/src/it/jetty-run-war-exploded-mojo-it/jetty-simple-webapp/src/test/java/com/webtide/jetty/its/jetty_run_mojo_it/TestHelloServlet.java new file mode 100644 index 00000000000..4e3ced68d91 --- /dev/null +++ b/jetty-maven-plugin/src/it/jetty-run-war-exploded-mojo-it/jetty-simple-webapp/src/test/java/com/webtide/jetty/its/jetty_run_mojo_it/TestHelloServlet.java @@ -0,0 +1,59 @@ +// +// ======================================================================== +// Copyright (c) 1995-2017 Mort Bay Consulting Pty. Ltd. +// ------------------------------------------------------------------------ +// All rights reserved. This program and the accompanying materials +// are made available under the terms of the Eclipse Public License v1.0 +// and Apache License v2.0 which accompanies this distribution. +// +// The Eclipse Public License is available at +// http://www.eclipse.org/legal/epl-v10.html +// +// The Apache License v2.0 is available at +// http://www.opensource.org/licenses/apache2.0.php +// +// You may elect to redistribute this code under either of these licenses. +// ======================================================================== +// + + +package com.webtide.jetty.its.jetty_run_mojo_it; + +import org.eclipse.jetty.client.HttpClient; +import org.junit.Assert; +import org.junit.Test; + +/** + * + */ +public class TestHelloServlet +{ + @Test + public void hello_servlet() + throws Exception + { + int port = Integer.getInteger( "jetty.runPort" ); + System.out.println( "port used:" + port ); + HttpClient httpClient = new HttpClient(); + try + { + httpClient.start(); + + String response = httpClient.GET( "http://localhost:" + port + "/hello?name=beer" ).getContentAsString(); + + System.out.println( "httpResponse:" + response ); + + Assert.assertEquals( "hello beer", response.trim() ); + + response = httpClient.GET( "http://localhost:" + port + "/ping?name=beer" ).getContentAsString(); + + System.out.println( "httpResponse:" + response ); + + Assert.assertEquals( "pong beer", response.trim() ); + } + finally + { + httpClient.stop(); + } + } +} diff --git a/jetty-maven-plugin/src/it/jetty-run-war-exploded-mojo-it/pom.xml b/jetty-maven-plugin/src/it/jetty-run-war-exploded-mojo-it/pom.xml new file mode 100644 index 00000000000..5b88c8fd196 --- /dev/null +++ b/jetty-maven-plugin/src/it/jetty-run-war-exploded-mojo-it/pom.xml @@ -0,0 +1,90 @@ + + + 4.0.0 + + com.webtide.jetty.its.jetty-run-war-exploded-mojo-it + jetty-simple-project + 0.0.1-SNAPSHOT + pom + + Jetty :: Simple + + + UTF-8 + UTF-8 + 1.8 + 3.0.0 + @project.version@ + + + + jetty-simple-base + jetty-simple-webapp + + + + + + + com.webtide.jetty.its.jetty-run-war-exploded-mojo-it + jetty-simple-base + ${project.version} + + + + javax.servlet + javax.servlet-api + 3.1.0 + jar + provided + + + + org.slf4j + slf4j-api + 1.7.21 + + + + commons-io + commons-io + 2.5 + + + + org.eclipse.jetty + jetty-servlet + ${jetty.version} + + + + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.5.1 + + 1.8 + 1.8 + + + + org.apache.maven.plugins + maven-resources-plugin + 3.0.1 + + + org.eclipse.jetty + jetty-maven-plugin + ${jetty.version} + + + + + +