diff --git a/.config/pmd/java/ruleset.xml b/.config/pmd/java/ruleset.xml index b6d43e51..8dde42bc 100644 --- a/.config/pmd/java/ruleset.xml +++ b/.config/pmd/java/ruleset.xml @@ -141,6 +141,7 @@ + diff --git a/.github/workflows/broken-links.yml b/.github/workflows/broken-links.yml index fbe05e74..8aeed096 100644 --- a/.github/workflows/broken-links.yml +++ b/.github/workflows/broken-links.yml @@ -19,7 +19,7 @@ jobs: - name: Link Checker id: lychee - uses: lycheeverse/lychee-action@8646ba30535128ac92d33dfc9133794bfdd9b411 # v2 + uses: lycheeverse/lychee-action@e7477775783ea5526144ba13e8db5eec57747ce8 # v2 with: args: "--verbose --no-progress './**/*.md'" fail: false # Don't fail on broken links, create an issue instead diff --git a/.idea/checkstyle-idea.xml b/.idea/checkstyle-idea.xml index 3dbbcc7a..b8b753e6 100644 --- a/.idea/checkstyle-idea.xml +++ b/.idea/checkstyle-idea.xml @@ -1,7 +1,7 @@ - 13.5.0 + latest JavaOnlyWithTests true true diff --git a/CHANGELOG.md b/CHANGELOG.md index b970572c..05ef5537 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# 2.52.0 +* Testcontainers: Extract wait strategy constants +* Updated dependencies + # 2.51.0 * Updated dependencies * Code cleanup and improved error reporting diff --git a/client/pom.xml b/client/pom.xml index dfaf9699..5fa383d7 100644 --- a/client/pom.xml +++ b/client/pom.xml @@ -223,7 +223,7 @@ com.puppycrawl.tools checkstyle - 13.6.0 + 13.8.0 @@ -261,12 +261,12 @@ net.sourceforge.pmd pmd-core - 7.25.0 + 7.26.0 net.sourceforge.pmd pmd-java - 7.25.0 + 7.26.0 diff --git a/core/pom.xml b/core/pom.xml index eaed2fec..338a4588 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -54,7 +54,7 @@ io.netty netty-bom - 4.2.15.Final + 4.2.16.Final pom import @@ -65,7 +65,7 @@ tools.jackson.core jackson-databind - 3.2.0 + 3.2.1 @@ -271,7 +271,7 @@ com.puppycrawl.tools checkstyle - 13.6.0 + 13.8.0 @@ -309,12 +309,12 @@ net.sourceforge.pmd pmd-core - 7.25.0 + 7.26.0 net.sourceforge.pmd pmd-java - 7.25.0 + 7.26.0 diff --git a/pom.xml b/pom.xml index ded9be3f..8a06e265 100644 --- a/pom.xml +++ b/pom.xml @@ -69,7 +69,7 @@ com.puppycrawl.tools checkstyle - 13.6.0 + 13.8.0 @@ -107,12 +107,12 @@ net.sourceforge.pmd pmd-core - 7.25.0 + 7.26.0 net.sourceforge.pmd pmd-java - 7.25.0 + 7.26.0 diff --git a/server/pom.xml b/server/pom.xml index 8d331971..359dc47c 100644 --- a/server/pom.xml +++ b/server/pom.xml @@ -56,7 +56,7 @@ io.netty netty-bom - 4.2.15.Final + 4.2.16.Final pom import @@ -290,7 +290,7 @@ com.puppycrawl.tools checkstyle - 13.6.0 + 13.8.0 @@ -328,12 +328,12 @@ net.sourceforge.pmd pmd-core - 7.25.0 + 7.26.0 net.sourceforge.pmd pmd-java - 7.25.0 + 7.26.0 diff --git a/server/src/main/java/software/xdev/mockserver/matchers/RegexStringMatcher.java b/server/src/main/java/software/xdev/mockserver/matchers/RegexStringMatcher.java index bd5ab976..4bce0b1c 100644 --- a/server/src/main/java/software/xdev/mockserver/matchers/RegexStringMatcher.java +++ b/server/src/main/java/software/xdev/mockserver/matchers/RegexStringMatcher.java @@ -71,11 +71,9 @@ private boolean matchesByNottedStrings( // mutual notted control plane match return this.matchesByStrings(context, matcher, matched); } - else - { - // data plane & control plan match - return (matcher.isNot() || matched.isNot()) ^ this.matchesByStrings(context, matcher, matched); - } + + // data plane & control plan match + return (matcher.isNot() || matched.isNot()) ^ this.matchesByStrings(context, matcher, matched); } @SuppressWarnings({"PMD.CognitiveComplexity"}) @@ -93,56 +91,54 @@ private boolean matchesByStrings( { return true; } - else + + if(matched != null) { - if(matched != null) + final String matchedValue = matched.getValue(); + if(matchedValue != null) { - final String matchedValue = matched.getValue(); - if(matchedValue != null) + // match as exact string + if(matchedValue.equals(matcherValue) || matchedValue.equalsIgnoreCase(matcherValue)) { - // match as exact string - if(matchedValue.equals(matcherValue) || matchedValue.equalsIgnoreCase(matcherValue)) + return true; + } + + // match as regex - matcher -> matched (data plane or control plane) + try + { + if(matcher.matches(matchedValue)) { return true; } - - // match as regex - matcher -> matched (data plane or control plane) - try + } + catch(final PatternSyntaxException pse) + { + if(LOG.isDebugEnabled()) { - if(matcher.matches(matchedValue)) - { - return true; - } + LOG.debug("Error while matching regex [{}] for string [{}]", matcher, matched, pse); } - catch(final PatternSyntaxException pse) + } + // match as regex - matched -> matcher (control plane only) + try + { + if(this.controlPlaneMatcher && matched.matches(matcherValue)) { - if(LOG.isDebugEnabled()) - { - LOG.debug("Error while matching regex [{}] for string [{}]", matcher, matched, pse); - } + return true; } - // match as regex - matched -> matcher (control plane only) - try + else if(LOG.isDebugEnabled() && matched.matches(matcherValue)) { - if(this.controlPlaneMatcher && matched.matches(matcherValue)) - { - return true; - } - else if(LOG.isDebugEnabled() && matched.matches(matcherValue)) - { - LOG.debug( - "Matcher {} would match {} if matcher was used for control plane", - matcher, - matched); - } + LOG.debug( + "Matcher {} would match {} if matcher was used for control plane", + matcher, + matched); } - catch(final PatternSyntaxException pse) + } + catch(final PatternSyntaxException pse) + { + if(this.controlPlaneMatcher + && LOG.isDebugEnabled()) { - if(this.controlPlaneMatcher - && LOG.isDebugEnabled()) - { - LOG.debug("Error while matching regex [{}] for string [{}]", matcher, matched, pse); - } + LOG.debug("Error while matching regex [{}] for string [{}]", matcher, matched, pse); } } } diff --git a/server/src/main/java/software/xdev/mockserver/mock/action/http/HttpActionHandler.java b/server/src/main/java/software/xdev/mockserver/mock/action/http/HttpActionHandler.java index 73e10fe3..70c1bb13 100644 --- a/server/src/main/java/software/xdev/mockserver/mock/action/http/HttpActionHandler.java +++ b/server/src/main/java/software/xdev/mockserver/mock/action/http/HttpActionHandler.java @@ -107,8 +107,8 @@ public HttpActionHandler( "checkstyle:MethodLength", "PMD.CognitiveComplexity", "PMD.CyclomaticComplexity", - "PMD.NPathComplexity" - }) + "PMD.NPathComplexity", + "PMD.AvoidDeeplyNestedIfStmts"}) public void processAction( final HttpRequest request, final ResponseWriter responseWriter, @@ -138,7 +138,6 @@ public void processAction( if(expectation != null && expectation.getAction() != null) { - final Action action = expectation.getAction(); switch(action.getType()) { @@ -292,7 +291,6 @@ public void processAction( else if(CORSHeaders.isPreflightRequest(this.configuration, request) && (this.configuration.enableCORSForAPI() || this.configuration.enableCORSForAllResponses())) { - responseWriter.writeResponse(request, OK); if(LOG.isInfoEnabled()) { @@ -301,13 +299,11 @@ else if(CORSHeaders.isPreflightRequest(this.configuration, request) && (this.con } else if(proxyingRequest || potentiallyHttpProxy) { - if(request.getHeaders() != null && request.getHeaders() .containsEntry( this.httpStateHandler.getUniqueLoopPreventionHeaderName(), this.httpStateHandler.getUniqueLoopPreventionHeaderValue())) { - if(LOG.isTraceEnabled()) { LOG.trace( @@ -347,7 +343,6 @@ else if(proxyingRequest || potentiallyHttpProxy) } else { - final InetSocketAddress remoteAddress = getRemoteAddress(ctx); final HttpRequest clonedRequest = this.hopByHopHeaderFilter.onRequest(request) .withHeader( @@ -451,7 +446,6 @@ else if(!connectionClosedException(ex)) } else { - this.returnNotFound(responseWriter, request, null); } } diff --git a/testcontainers/pom.xml b/testcontainers/pom.xml index eba59743..98554920 100644 --- a/testcontainers/pom.xml +++ b/testcontainers/pom.xml @@ -78,13 +78,13 @@ tools.jackson.core jackson-databind - 3.2.0 + 3.2.1 test org.junit.jupiter junit-jupiter - 6.1.0 + 6.1.2 test @@ -96,7 +96,7 @@ software.xdev testcontainers-advanced-imagebuilder - 2.5.0 + 4.1.2 test @@ -282,7 +282,7 @@ com.puppycrawl.tools checkstyle - 13.6.0 + 13.8.0 @@ -320,12 +320,12 @@ net.sourceforge.pmd pmd-core - 7.25.0 + 7.26.0 net.sourceforge.pmd pmd-java - 7.25.0 + 7.26.0 diff --git a/testcontainers/src/main/java/software/xdev/testcontainers/mockserver/containers/MockServerContainer.java b/testcontainers/src/main/java/software/xdev/testcontainers/mockserver/containers/MockServerContainer.java index 491a7c94..902e13e0 100644 --- a/testcontainers/src/main/java/software/xdev/testcontainers/mockserver/containers/MockServerContainer.java +++ b/testcontainers/src/main/java/software/xdev/testcontainers/mockserver/containers/MockServerContainer.java @@ -28,12 +28,13 @@ public class MockServerContainer extends GenericContainer public static final String DEFAULT_IMAGE = "xdevsoftware/mockserver"; public static final String DEFAULT_TAG = MockServerUtils.DEFAULT_VERSION; public static final int PORT = 1080; + public static final String LOG_MSG_WAIT_STRATEGY_REGEX = ".*started on port: " + PORT + ".*"; public MockServerContainer(final RemoteDockerImage image) { super(image); - this.waitingFor(Wait.forLogMessage(".*started on port: " + PORT + ".*", 1)); + this.waitingFor(Wait.forLogMessage(LOG_MSG_WAIT_STRATEGY_REGEX, 1)); this.addExposedPort(PORT); } @@ -41,7 +42,7 @@ public MockServerContainer(final DockerImageName dockerImageName) { super(dockerImageName); - this.waitingFor(Wait.forLogMessage(".*started on port: " + PORT + ".*", 1)); + this.waitingFor(Wait.forLogMessage(LOG_MSG_WAIT_STRATEGY_REGEX, 1)); this.addExposedPort(PORT); } diff --git a/testcontainers/src/test/java/software/xdev/testcontainers/mockserver/containers/MockServerContainerTest.java b/testcontainers/src/test/java/software/xdev/testcontainers/mockserver/containers/MockServerContainerTest.java index 6c9c3cc7..c5db4e88 100644 --- a/testcontainers/src/test/java/software/xdev/testcontainers/mockserver/containers/MockServerContainerTest.java +++ b/testcontainers/src/test/java/software/xdev/testcontainers/mockserver/containers/MockServerContainerTest.java @@ -27,8 +27,6 @@ import java.net.http.HttpResponse; import java.nio.file.Paths; import java.time.Duration; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; @@ -51,12 +49,12 @@ class MockServerContainerTest static DockerImageName image; @BeforeAll - static void buildImage() throws TimeoutException + static void buildImage() { image = DockerImageName.parse(getOrBuildImage()); } - static String getOrBuildImage() throws TimeoutException + static String getOrBuildImage() { final String imageName = System.getProperty("mockserver-image"); if(imageName != null) @@ -66,25 +64,27 @@ static String getOrBuildImage() throws TimeoutException return new AdvancedImageFromDockerFile("mockserver") .withLoggerForBuild(LoggerFactory.getLogger("container.build.mockserver")) - .withPostGitIgnoreLines( - // Ignore files that aren't related to the built code - ".git/**", - ".config/**", - ".github/**", - ".idea/**", - ".run/**", - "assets/**", - "docs/**", - "Dockerfile", - "*.md", - "*.cmd", - "/renovate.json5", - "/client/src/**", - "/testcontainers/src/**") .withDockerFilePath(Paths.get("../testcontainers/Standalone.Dockerfile")) .withBaseDir(Paths.get("../")) - .withDockerFileLinesModifier(new DockerfileCOPYParentsEmulator()) - .get(5, TimeUnit.MINUTES); + .configureFilesToTransferHandler(h -> h + .withPostGitIgnoreLines( + // Ignore files that aren't related to the built code + ".git/**", + ".config/**", + ".github/**", + ".idea/**", + ".run/**", + "assets/**", + "docs/**", + "Dockerfile", + "*.md", + "*.cmd", + "/renovate.json5", + "/client/src/**", + "/testcontainers/src/**") + .withDockerFileLinesModifier(new DockerfileCOPYParentsEmulator()) + ) + .build(Duration.ofMinutes(5)); } @Test