diff --git a/container-test/example-webapp/pom.xml b/container-test/example-webapp/pom.xml
index 24455639..348233d9 100644
--- a/container-test/example-webapp/pom.xml
+++ b/container-test/example-webapp/pom.xml
@@ -3,7 +3,7 @@
* Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + *
* - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above @@ -17,7 +17,7 @@ * - Neither the name tuckey.org nor the names of its contributors * may be used to endorse or promote products derived from this * software without specific prior written permission. - * + *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS @@ -34,13 +34,12 @@ */ package org.tuckey.web.filters.urlrewriteviacontainer; -import jakarta.servlet.ServletException; import org.apache.commons.httpclient.Header; import org.apache.commons.httpclient.methods.GetMethod; +import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.tuckey.web.filters.urlrewrite.utils.StringUtils; -import org.xml.sax.SAXException; import java.io.ByteArrayOutputStream; import java.io.IOException; @@ -68,8 +67,13 @@ public void beforeEach() throws Exception { super.recordRewriteStatus(); } + @AfterEach + public void afterEach() throws InterruptedException { + super.tearDown(); + } + @Test - public void testProduct() throws IOException, SAXException, InterruptedException { + public void testProduct() throws IOException { GetMethod method = new GetMethod(getBaseUrl() + "/products/987"); client.executeMethod(method); assertEquals("product 987", method.getResponseBodyAsString()); @@ -77,32 +81,32 @@ public void testProduct() throws IOException, SAXException, InterruptedException @Test - public void testSimpleDistEx() throws ServletException, IOException, SAXException { + public void testSimpleDistEx() throws IOException { GetMethod method = new GetMethod(getBaseUrl() + "/test/status/"); method.setFollowRedirects(false); client.executeMethod(method); - assertEquals(getBaseUrl() + "/rewrite-status", method.getResponseHeader("Location").getValue()); + assertEquals("/" + getApp() + "/rewrite-status", method.getResponseHeader("Location").getValue()); } @Test - public void testBasicSets() throws ServletException, IOException, SAXException { + public void testBasicSets() throws IOException { GetMethod method = new GetMethod(getBaseUrl() + "/settest/674"); client.executeMethod(method); assertNotNull(method.getResponseHeader("cache-control")); assertEquals("testsession: hello!, " + "param.settest1: 674, " + - "method: DELETE", method.getResponseBodyAsString()); + "method: GET", method.getResponseBodyAsString()); } @Test - public void testMultipleProduct() throws ServletException, IOException, SAXException { + public void testMultipleProduct() throws IOException { GetMethod method = new GetMethod(getBaseUrl() + "/multiple/products/987"); client.executeMethod(method); assertEquals("product 987", method.getResponseBodyAsString()); } @Test - public void testNullTo() throws ServletException, IOException { + public void testNullTo() throws IOException { GetMethod method = new GetMethod(getBaseUrl() + "/hideme/anb.jsp;dsaddd?asdasds#sdsfd"); client.executeMethod(method); assertEquals(403, method.getStatusCode()); // "should have status set", @@ -111,14 +115,14 @@ public void testNullTo() throws ServletException, IOException { } @Test - public void testYear() throws ServletException, IOException { + public void testYear() throws IOException { GetMethod method = new GetMethod(getBaseUrl() + "/time/year/current"); client.executeMethod(method); assertEquals("echo yearisbetween1970and3000", method.getResponseBodyAsString()); } @Test - public void testTestAxis() throws ServletException, IOException { + public void testTestAxis() throws IOException { GetMethod method = new GetMethod(getBaseUrl() + "/services/blah?qwerty"); method.setFollowRedirects(false); client.executeMethod(method); @@ -126,7 +130,7 @@ public void testTestAxis() throws ServletException, IOException { } @Test - public void testTestErik() throws ServletException, IOException { + public void testTestErik() throws IOException { GetMethod method = new GetMethod(getBaseUrl() + "/eriktest/hi.ho"); method.setFollowRedirects(false); method.addRequestHeader(new Header("host", "blah.com")); @@ -135,15 +139,15 @@ public void testTestErik() throws ServletException, IOException { } @Test - public void testTestEncode() throws ServletException, IOException { + public void testTestEncode() throws IOException { GetMethod method = new GetMethod(getBaseUrl() + "/went%20to%20bahamas/"); method.setFollowRedirects(false); client.executeMethod(method); - assertEquals(getBaseUrl() + "/jamaica/", method.getResponseHeader("Location").getValue()); + assertEquals("/" + getApp() + "/jamaica/", method.getResponseHeader("Location").getValue()); } @Test - public void testSimpleRun() throws ServletException, IOException { + public void testSimpleRun() throws IOException { GetMethod method = new GetMethod(getBaseUrl() + "/run/test/test1"); client.executeMethod(method); assertEquals("this is " + TestRunObj.class.getName(), method.getResponseBodyAsString()); @@ -181,11 +185,4 @@ private String inflateGzipToString(InputStream is) throws IOException { return os.toString(); } - @Test - public void testSampleAnnotation() throws IOException { - GetMethod method = new GetMethod(getBaseUrl() + "/do-something/7"); - client.executeMethod(method); - assertEquals(method.getResponseBodyAsString(), "AnnotatedClassSample id=7"); - } - } diff --git a/container-test/test-with-testcontainers/src/test/java/org/tuckey/web/filters/urlrewriteviacontainer/WebappModStyleHttpITTest.java b/container-test/test-with-testcontainers/src/test/java/org/tuckey/web/filters/urlrewriteviacontainer/WebappModStyleHttpITTest.java index 1c44bb29..c6a512aa 100644 --- a/container-test/test-with-testcontainers/src/test/java/org/tuckey/web/filters/urlrewriteviacontainer/WebappModStyleHttpITTest.java +++ b/container-test/test-with-testcontainers/src/test/java/org/tuckey/web/filters/urlrewriteviacontainer/WebappModStyleHttpITTest.java @@ -35,6 +35,7 @@ package org.tuckey.web.filters.urlrewriteviacontainer; import org.apache.commons.httpclient.methods.GetMethod; +import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.xml.sax.SAXException; @@ -51,7 +52,7 @@ public class WebappModStyleHttpITTest extends ContainerTestBase { protected String getApp() { - return "webapp/mod"; + return "webapp"; } @BeforeEach @@ -60,25 +61,30 @@ public void beforeEach() throws Exception { super.recordRewriteStatus(); } + @AfterEach + public void afterEach() throws InterruptedException { + super.tearDown(); + } + @Test - public void testSimpleTest() throws ServletException, IOException, SAXException { - GetMethod method = new GetMethod(getBaseUrl() + "/index.jsp"); + public void testSimpleTest() throws IOException { + GetMethod method = new GetMethod(getBaseUrl() + "/mod/index.jsp"); method.setFollowRedirects(false); client.executeMethod(method); assertEquals("this is index.jsp", method.getResponseBodyAsString()); } @Test - public void testSimpleTestRewrite() throws ServletException, IOException, SAXException { - GetMethod method = new GetMethod(getBaseUrl() + "/simple/test"); + public void testSimpleTestRewrite() throws IOException { + GetMethod method = new GetMethod(getBaseUrl() + "/mod/simple/test"); method.setFollowRedirects(false); client.executeMethod(method); assertEquals("this is index.jsp", method.getResponseBodyAsString()); } @Test - public void testStatus1() throws ServletException, IOException, SAXException { - GetMethod method = new GetMethod(getBaseUrl() + "/rewrite-status"); + public void testStatus1() throws IOException { + GetMethod method = new GetMethod(getBaseUrl() + "/mod/rewrite-status"); method.setFollowRedirects(false); client.executeMethod(method); assertTrue(method.getResponseBodyAsString().contains("Running Status"));