Skip to content

Commit

Permalink
Fix test to allow Git origin URLs starting with git@ (#4152)
Browse files Browse the repository at this point in the history
This occurred when using the SSH option to clone the repository.
  • Loading branch information
ky0n authored Nov 23, 2024
1 parent c96feb2 commit 3d73144
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.net.URISyntaxException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.regex.Pattern;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
Expand Down Expand Up @@ -75,9 +76,9 @@ void writesValidXmlReport() throws Exception {
<java:javaVersion>${xmlunit.ignore}</java:javaVersion>
<java:fileEncoding>${xmlunit.ignore}</java:fileEncoding>
<java:heapSize max="${xmlunit.isNumber}"/>
<git:repository originUrl="${xmlunit.matchesRegex(https://.+)}"/>
<git:repository originUrl="${xmlunit.matchesRegex#(git@|https://).+#}"/>
<git:branch>${xmlunit.ignore}</git:branch>
<git:commit>${xmlunit.matchesRegex([0-9a-f]{40})}</git:commit>
<git:commit>${xmlunit.matchesRegex#[0-9a-f]{40}#}</git:commit>
<git:status clean="${xmlunit.ignore}">${xmlunit.ignore}</git:status>
</infrastructure>
<e:started id="1" name="dummy" time="${xmlunit.isDateTime}">
Expand All @@ -104,7 +105,7 @@ void writesValidXmlReport() throws Exception {
<e:finished id="2" time="${xmlunit.isDateTime}">
<result status="FAILED">
<java:throwable assertionError="true" type="org.opentest4j.AssertionFailedError">
${xmlunit.matchesRegex(org\\.opentest4j\\.AssertionFailedError: failure message)}
${xmlunit.matchesRegex#org\\.opentest4j\\.AssertionFailedError: failure message#}
</java:throwable>
</result>
</e:finished>
Expand All @@ -115,7 +116,8 @@ void writesValidXmlReport() throws Exception {
""";

XmlAssert.assertThat(xmlFile).and(expected) //
.withDifferenceEvaluator(new PlaceholderDifferenceEvaluator()) //
.withDifferenceEvaluator(new PlaceholderDifferenceEvaluator(Pattern.quote("${"), Pattern.quote("}"),
Pattern.quote("#"), Pattern.quote("#"), ",")) //
.ignoreWhitespace() //
.areIdentical();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import java.io.UncheckedIOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.regex.Pattern;

import org.xmlunit.assertj3.XmlAssert;
import org.xmlunit.placeholder.PlaceholderDifferenceEvaluator;
Expand Down Expand Up @@ -46,9 +47,9 @@ private static void verifyContent(Path xmlFile) {
<java:javaVersion>${xmlunit.ignore}</java:javaVersion>
<java:fileEncoding>${xmlunit.ignore}</java:fileEncoding>
<java:heapSize max="${xmlunit.isNumber}"/>
<git:repository originUrl="${xmlunit.matchesRegex(https://.+)}"/>
<git:repository originUrl="${xmlunit.matchesRegex#(git@|https://).+#}"/>
<git:branch>${xmlunit.ignore}</git:branch>
<git:commit>${xmlunit.matchesRegex([0-9a-f]{40})}</git:commit>
<git:commit>${xmlunit.matchesRegex#[0-9a-f]{40}#}</git:commit>
<git:status clean="${xmlunit.ignore}">${xmlunit.ignore}</git:status>
</infrastructure>
<e:started id="1" name="JUnit Jupiter" time="${xmlunit.isDateTime}">
Expand Down Expand Up @@ -156,7 +157,8 @@ private static void verifyContent(Path xmlFile) {
""";

XmlAssert.assertThat(xmlFile).and(expected) //
.withDifferenceEvaluator(new PlaceholderDifferenceEvaluator()) //
.withDifferenceEvaluator(new PlaceholderDifferenceEvaluator(Pattern.quote("${"), Pattern.quote("}"),
Pattern.quote("#"), Pattern.quote("#"), ",")) //
.ignoreWhitespace() //
.areIdentical();
}
Expand Down

0 comments on commit 3d73144

Please sign in to comment.