diff options
author | Julien HENRY <julien.henry@sonarsource.com> | 2017-03-02 13:10:07 +0100 |
---|---|---|
committer | Julien HENRY <henryju@yahoo.fr> | 2017-03-02 16:24:43 +0100 |
commit | ea8d74d2617e334ffbf827ec29a6accb8a7c1cfc (patch) | |
tree | f606efb068dafe590df4209d3de47dbc5e5df250 /it | |
parent | bec1de9fc1f6c8bdd9a463dd3c514703f8b7f273 (diff) | |
download | sonarqube-ea8d74d2617e334ffbf827ec29a6accb8a7c1cfc.tar.gz sonarqube-ea8d74d2617e334ffbf827ec29a6accb8a7c1cfc.zip |
SONAR-8883 Fix Server::getVersion() on scanner side, and reenable IssueJsonReportTest IT
Diffstat (limited to 'it')
-rw-r--r-- | it/it-tests/src/test/java/it/analysis/IssueJsonReportTest.java | 29 |
1 files changed, 11 insertions, 18 deletions
diff --git a/it/it-tests/src/test/java/it/analysis/IssueJsonReportTest.java b/it/it-tests/src/test/java/it/analysis/IssueJsonReportTest.java index 8a2b94e50e8..b0f5afbe49e 100644 --- a/it/it-tests/src/test/java/it/analysis/IssueJsonReportTest.java +++ b/it/it-tests/src/test/java/it/analysis/IssueJsonReportTest.java @@ -31,13 +31,13 @@ import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; import java.util.List; +import java.util.regex.Pattern; import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; import org.json.simple.JSONArray; import org.json.simple.JSONObject; import org.junit.Before; import org.junit.ClassRule; -import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; import org.junit.rules.TemporaryFolder; @@ -46,9 +46,10 @@ import util.ItUtils; import static org.assertj.core.api.Assertions.assertThat; -@Ignore("Temporarily disabled as non-SNAPSHOT versions are not supported") public class IssueJsonReportTest { + private static final String SONAR_VERSION_PLACEHOLDER = "<SONAR_VERSION>"; + @ClassRule public static Orchestrator orchestrator = Category3Suite.ORCHESTRATOR; @@ -146,7 +147,7 @@ public class IssueJsonReportTest { assertThat(report).isFile().exists(); String json = sanitize(FileUtils.readFileToString(report)); - String expectedJson = sanitize(IOUtils.toString(getResourceInputStream("no-server-analysis.json"))); + String expectedJson = expected("no-server-analysis.json"); JSONAssert.assertEquals(expectedJson, json, false); } @@ -173,7 +174,7 @@ public class IssueJsonReportTest { assertThat(report).isFile().exists(); String json = sanitize(FileUtils.readFileToString(report)); - String expectedJson = sanitize(IOUtils.toString(getResourceInputStream("report-on-single-module.json"))); + String expectedJson = expected("report-on-single-module.json"); JSONAssert.assertEquals(expectedJson, json, false); } @@ -204,7 +205,7 @@ public class IssueJsonReportTest { assertThat(report).isFile().exists(); String json = sanitize(FileUtils.readFileToString(report)); - String expectedJson = sanitize(IOUtils.toString(getResourceInputStream("report-on-single-module-branch.json"))); + String expectedJson = expected("report-on-single-module-branch.json"); JSONAssert.assertEquals(expectedJson, json, false); } @@ -241,7 +242,7 @@ public class IssueJsonReportTest { String json = sanitize(FileUtils.readFileToString(report)); // SONAR-5218 All issues are updated as their root project id has changed (it's now the sub module) - String expectedJson = sanitize(IOUtils.toString(getResourceInputStream("report-on-sub-module.json"))); + String expectedJson = expected("report-on-sub-module.json"); JSONAssert.assertEquals(expectedJson, json, false); } @@ -271,17 +272,13 @@ public class IssueJsonReportTest { assertThat(report).isFile().exists(); String json = sanitize(FileUtils.readFileToString(report)); - String expectedJson = sanitize(IOUtils.toString(getResourceInputStream("report-on-root-module.json"))); + String expectedJson = expected("report-on-root-module.json"); JSONAssert.assertEquals(expectedJson, json, false); } - @Test - public void sanityCheck() { - assertThat(sanitize("5.0-SNAPSHOT")).isEqualTo("<SONAR_VERSION>"); - assertThat(sanitize("5.0.0-5868-SNAPSHOT")).isEqualTo("<SONAR_VERSION>"); - assertThat(sanitize("5.0-build1234")).isEqualTo("<SONAR_VERSION>"); - assertThat(sanitize("5.0.1-build1234")).isEqualTo("<SONAR_VERSION>"); - assertThat(sanitize("\"5.0.1-build1234\"")).isEqualTo("\"<SONAR_VERSION>\""); + private String expected(String path) throws IOException, FileNotFoundException { + return sanitize(IOUtils.toString(getResourceInputStream(path))) + .replaceAll(Pattern.quote(SONAR_VERSION_PLACEHOLDER), orchestrator.getServer().version().toString()); } @Test @@ -290,10 +287,6 @@ public class IssueJsonReportTest { } private static String sanitize(String s) { - // sanitize sonarqube version: "5.4-SNAPSHOT" or "5.4-build1234" - s = s.replaceAll("\\d\\.\\d(.\\d)?(\\-.*)?\\-SNAPSHOT", "<SONAR_VERSION>"); - s = s.replaceAll("\\d\\.\\d(.\\d)?(\\-.*)?\\-build(\\d)+", "<SONAR_VERSION>"); - // sanitize issue uuid keys s = s.replaceAll("\"[a-zA-Z_0-9\\-]{15,20}\"", "<ISSUE_KEY>"); |