Skip to content

Commit

Permalink
Merge pull request #248 from paultuckey/feature/test-containers
Browse files Browse the repository at this point in the history
DRAFT test containers v2
  • Loading branch information
paultuckey committed Jul 2, 2023
2 parents 6dad8dc + 0d45dfb commit 5798aa8
Show file tree
Hide file tree
Showing 91 changed files with 4,426 additions and 3,914 deletions.
11 changes: 11 additions & 0 deletions .github/workflows/maven.yml
Expand Up @@ -23,6 +23,17 @@ jobs:
- name: Build with Maven
run: mvn --batch-mode --update-snapshots package

- name: Locally install filter
run: mvn install --batch-mode

- name: Locally install example
working-directory: container-test/example-webapp
run: mvn install --batch-mode

- name: Run container tests
working-directory: container-test/test-with-testcontainers
run: mvn test --batch-mode

# - uses: actions/upload-artifact@v3
# with:
# name: Package
Expand Down
Expand Up @@ -34,10 +34,10 @@
*/
package org.tuckey.web.filters.urlrewrite.annotation;

import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import jakarta.servlet.FilterChain;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.SQLException;

Expand Down
13 changes: 0 additions & 13 deletions container-test/README.md

This file was deleted.

78 changes: 78 additions & 0 deletions container-test/example-webapp/pom.xml
@@ -0,0 +1,78 @@
<project>

<modelVersion>4.0.0</modelVersion>
<groupId>org.tuckey</groupId>
<artifactId>example-webapp</artifactId>
<packaging>war</packaging>
<version>5.0.0-SNAPSHOT</version>
<name>Example Webapp</name>
<url>http://www.tuckey.org/urlrewrite/</url>
<inceptionYear>2001</inceptionYear>
<description>Example webapp for Integration tests for UrlRewriteFilter</description>
<organization>
<name>Paul Tuckey</name>
</organization>

<licenses>
<license>
<name>BSD</name>
<url>http://www.opensource.org/licenses/bsd-license.php</url>
<distribution>repo</distribution>
</license>
</licenses>

<developers>
<developer>
<name>Paul Tuckey</name>
</developer>
</developers>

<build>
<finalName>webapp</finalName>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.3.1</version>
<configuration>
<webResources>
<resource>
<targetPath>WEB-INF</targetPath>
<directory>target</directory>
<includes>
<include>urlrewrite-generated.xml</include>
</includes>
</resource>
</webResources>
</configuration>
</plugin>
</plugins>
</build>

<dependencies>
<dependency>
<!-- run `mvn install` locally root of project -->
<groupId>org.tuckey</groupId>
<artifactId>urlrewritefilter</artifactId>
<version>5.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
<version>6.0.0</version>
<scope>provided</scope>
</dependency>
</dependencies>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>

</project>
@@ -1,70 +1,70 @@
/**
* Copyright (c) 2005-2007, Paul Tuckey
* All rights reserved.
* ====================================================================
* Licensed under the BSD License. Text as follows.
*
* 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
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* - 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
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
* ====================================================================
*/
package org.tuckey.web.filters.urlrewriteviacontainer;

import org.tuckey.web.filters.urlrewrite.extend.RewriteMatch;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;


/**
* Mock RewriteMatch that can be used for testing. Included here and not in test folder as it needs to be deployed with
* the main library.
*
* @author Paul Tuckey
* @version $Revision: 33 $ $Date: 2006-09-12 16:41:56 +1200 (Tue, 12 Sep 2006) $
*/
public class MockRewriteMatch extends RewriteMatch {

private static long calledTime = 0;

public boolean execute(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
calledTime = System.currentTimeMillis();
try {
Thread.sleep(10);
} catch (InterruptedException e) {
// don't worry
}
return true;
}

public static long getCalledTime() {
return calledTime;
}
}
/**
* Copyright (c) 2005-2007, Paul Tuckey
* All rights reserved.
* ====================================================================
* Licensed under the BSD License. Text as follows.
*
* 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
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* - 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
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
* ====================================================================
*/
package org.tuckey.web.filters.urlrewriteviacontainer;

import org.tuckey.web.filters.urlrewrite.extend.RewriteMatch;

import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;


/**
* Mock RewriteMatch that can be used for testing. Included here and not in test folder as it needs to be deployed with
* the main library.
*
* @author Paul Tuckey
* @version $Revision: 33 $ $Date: 2006-09-12 16:41:56 +1200 (Tue, 12 Sep 2006) $
*/
public class MockRewriteMatch extends RewriteMatch {

private static long calledTime = 0;

public boolean execute(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
calledTime = System.currentTimeMillis();
try {
Thread.sleep(10);
} catch (InterruptedException e) {
// don't worry
}
return true;
}

public static long getCalledTime() {
return calledTime;
}
}

0 comments on commit 5798aa8

Please sign in to comment.