From e0d4f21e737e34bb3557bda8bc9c44898b512f7d Mon Sep 17 00:00:00 2001 From: Anton Nashatyrev Date: Fri, 7 Dec 2018 11:05:24 +0300 Subject: [PATCH] Fix pantheon.cli.PantheonCommandTest test on Windows (#380) --- gradle/versions.gradle | 1 + pantheon/build.gradle | 1 + .../tech/pegasys/pantheon/cli/PantheonCommandTest.java | 8 +++++++- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/gradle/versions.gradle b/gradle/versions.gradle index 2afd886aa9..621ef4913f 100644 --- a/gradle/versions.gradle +++ b/gradle/versions.gradle @@ -73,5 +73,6 @@ dependencyManagement { dependency 'org.web3j:crypto:4.0.1' dependency 'org.xerial.snappy:snappy-java:1.1.7.2' + dependency 'org.apache.commons:commons-text:1.6' } } \ No newline at end of file diff --git a/pantheon/build.gradle b/pantheon/build.gradle index f63b7bfa35..93a0bcacbf 100644 --- a/pantheon/build.gradle +++ b/pantheon/build.gradle @@ -58,6 +58,7 @@ dependencies { testImplementation 'org.assertj:assertj-core' testImplementation 'org.awaitility:awaitility' testImplementation 'org.mockito:mockito-core' + testImplementation 'org.apache.commons:commons-text' } task writeInfoFile(type: ProjectPropertiesFile) { diff --git a/pantheon/src/test/java/tech/pegasys/pantheon/cli/PantheonCommandTest.java b/pantheon/src/test/java/tech/pegasys/pantheon/cli/PantheonCommandTest.java index 1ec444ce4d..b00e5a8481 100644 --- a/pantheon/src/test/java/tech/pegasys/pantheon/cli/PantheonCommandTest.java +++ b/pantheon/src/test/java/tech/pegasys/pantheon/cli/PantheonCommandTest.java @@ -54,6 +54,7 @@ import java.util.Optional; import com.google.common.collect.Lists; import com.google.common.io.Resources; +import org.apache.commons.text.StringEscapeUtils; import org.junit.Before; import org.junit.Ignore; import org.junit.Rule; @@ -251,7 +252,8 @@ public class PantheonCommandTest extends CommandTestAbstract { final URL configFile = Resources.getResource("complete_config.toml"); final Path genesisFile = createFakeGenesisFile(); final String updatedConfig = - Resources.toString(configFile, UTF_8).replaceAll("~/genesis.json", genesisFile.toString()); + Resources.toString(configFile, UTF_8) + .replace("~/genesis.json", escapeTomlString(genesisFile.toString())); final Path toml = Files.createTempFile("toml", ""); Files.write(toml, updatedConfig.getBytes(UTF_8)); @@ -1004,4 +1006,8 @@ public class PantheonCommandTest extends CommandTestAbstract { private boolean isFullInstantiation() { return !Boolean.getBoolean("pantheon.docker"); } + + private static String escapeTomlString(final String s) { + return StringEscapeUtils.escapeJava(s); + } }