From 7e27f038849fc3a39e14e0f83f640438ae67dd2b Mon Sep 17 00:00:00 2001 From: olivier lamy Date: Fri, 23 Jun 2017 15:51:38 +1000 Subject: [PATCH] add test with fragment for #1623 Signed-off-by: olivier lamy --- .../its/jetty_run_mojo_it/PingServlet.java | 41 +++++++++++++++++++ .../main/resources/META-INF/web-fragment.xml | 32 +++++++++++++++ .../jetty_run_mojo_it/TestHelloServlet.java | 6 +++ .../its/jetty_run_mojo_it/PingServlet.java | 41 +++++++++++++++++++ .../main/resources/META-INF/web-fragment.xml | 32 +++++++++++++++ .../jetty_run_mojo_it/TestHelloServlet.java | 6 +++ .../its/jetty_run_mojo_it/PingServlet.java | 41 +++++++++++++++++++ .../java/resources/META-INF/web-fragment.xml | 32 +++++++++++++++ .../jetty_run_mojo_it/TestHelloServlet.java | 6 +++ .../main/resources/META-INF/web-fragment.xml | 1 - 10 files changed, 237 insertions(+), 1 deletion(-) create mode 100644 jetty-maven-plugin/src/it/jetty-run-forked-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-forked-mojo-it/jetty-simple-base/src/main/resources/META-INF/web-fragment.xml create mode 100644 jetty-maven-plugin/src/it/jetty-run-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-mojo-it/jetty-simple-base/src/main/resources/META-INF/web-fragment.xml create mode 100644 jetty-maven-plugin/src/it/jetty-start-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-start-mojo-it/jetty-simple-base/src/main/java/resources/META-INF/web-fragment.xml diff --git a/jetty-maven-plugin/src/it/jetty-run-forked-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-forked-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-forked-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-forked-mojo-it/jetty-simple-base/src/main/resources/META-INF/web-fragment.xml b/jetty-maven-plugin/src/it/jetty-run-forked-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-forked-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-forked-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-forked-mojo-it/jetty-simple-webapp/src/test/java/com/webtide/jetty/its/jetty_run_mojo_it/TestHelloServlet.java index 27d9d55c787..f48eee38074 100644 --- a/jetty-maven-plugin/src/it/jetty-run-forked-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-forked-mojo-it/jetty-simple-webapp/src/test/java/com/webtide/jetty/its/jetty_run_mojo_it/TestHelloServlet.java @@ -43,6 +43,12 @@ public class TestHelloServlet 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 { diff --git a/jetty-maven-plugin/src/it/jetty-run-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-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-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-mojo-it/jetty-simple-base/src/main/resources/META-INF/web-fragment.xml b/jetty-maven-plugin/src/it/jetty-run-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-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-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-mojo-it/jetty-simple-webapp/src/test/java/com/webtide/jetty/its/jetty_run_mojo_it/TestHelloServlet.java index 1ec2da6ff78..4e3ced68d91 100644 --- a/jetty-maven-plugin/src/it/jetty-run-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-mojo-it/jetty-simple-webapp/src/test/java/com/webtide/jetty/its/jetty_run_mojo_it/TestHelloServlet.java @@ -44,6 +44,12 @@ public class TestHelloServlet 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 { diff --git a/jetty-maven-plugin/src/it/jetty-start-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-start-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-start-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-start-mojo-it/jetty-simple-base/src/main/java/resources/META-INF/web-fragment.xml b/jetty-maven-plugin/src/it/jetty-start-mojo-it/jetty-simple-base/src/main/java/resources/META-INF/web-fragment.xml new file mode 100644 index 00000000000..031012f7fed --- /dev/null +++ b/jetty-maven-plugin/src/it/jetty-start-mojo-it/jetty-simple-base/src/main/java/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-start-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-start-mojo-it/jetty-simple-webapp/src/test/java/com/webtide/jetty/its/jetty_run_mojo_it/TestHelloServlet.java index 1ec2da6ff78..4e3ced68d91 100644 --- a/jetty-maven-plugin/src/it/jetty-start-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-start-mojo-it/jetty-simple-webapp/src/test/java/com/webtide/jetty/its/jetty_run_mojo_it/TestHelloServlet.java @@ -44,6 +44,12 @@ public class TestHelloServlet 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 { diff --git a/tests/test-webapps/test-servlet-spec/test-web-fragment/src/main/resources/META-INF/web-fragment.xml b/tests/test-webapps/test-servlet-spec/test-web-fragment/src/main/resources/META-INF/web-fragment.xml index a85aea5f030..ae015f2712c 100644 --- a/tests/test-webapps/test-servlet-spec/test-web-fragment/src/main/resources/META-INF/web-fragment.xml +++ b/tests/test-webapps/test-servlet-spec/test-web-fragment/src/main/resources/META-INF/web-fragment.xml @@ -32,7 +32,6 @@ Fragment /fragment/* -