diff options
author | Duarte Meneses <duarte.meneses@sonarsource.com> | 2022-03-14 11:27:18 -0500 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2022-03-18 20:02:57 +0000 |
commit | 1269984e8e09338c057d068d715ade7df5a0c354 (patch) | |
tree | b483c992fd8c57b79188c936fb9bfb6ff7955ed8 /sonar-scanner-protocol/src/test | |
parent | e987de516356fe37ee8eb35793d5fd709e2a099b (diff) | |
download | sonarqube-1269984e8e09338c057d068d715ade7df5a0c354.tar.gz sonarqube-1269984e8e09338c057d068d715ade7df5a0c354.zip |
SONAR-16115 Store plugin's scanner cache in SonarQube
Diffstat (limited to 'sonar-scanner-protocol/src/test')
-rw-r--r-- | sonar-scanner-protocol/src/test/java/org/sonar/scanner/protocol/output/ScannerReportReaderTest.java | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/sonar-scanner-protocol/src/test/java/org/sonar/scanner/protocol/output/ScannerReportReaderTest.java b/sonar-scanner-protocol/src/test/java/org/sonar/scanner/protocol/output/ScannerReportReaderTest.java index 88ef3b84a52..58333d108cf 100644 --- a/sonar-scanner-protocol/src/test/java/org/sonar/scanner/protocol/output/ScannerReportReaderTest.java +++ b/sonar-scanner-protocol/src/test/java/org/sonar/scanner/protocol/output/ScannerReportReaderTest.java @@ -20,9 +20,13 @@ package org.sonar.scanner.protocol.output; import com.google.common.collect.Lists; +import com.google.protobuf.ByteString; import java.io.File; import java.io.FileOutputStream; +import java.io.IOException; import java.io.InputStream; +import java.util.AbstractMap; +import java.util.zip.GZIPInputStream; import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; import org.junit.Before; @@ -30,9 +34,12 @@ import org.junit.Rule; import org.junit.Test; import org.junit.rules.TemporaryFolder; import org.sonar.core.util.CloseableIterator; +import org.sonar.core.util.Protobuf; +import org.sonar.scanner.protocol.internal.ScannerInternal.PluginCacheMsg; import org.sonar.scanner.protocol.output.ScannerReport.Measure.StringValue; import org.sonar.scanner.protocol.output.ScannerReport.SyntaxHighlightingRule.HighlightingType; +import static java.nio.charset.StandardCharsets.UTF_8; import static java.util.Arrays.asList; import static java.util.Collections.singletonList; import static org.assertj.core.api.Assertions.assertThat; @@ -205,6 +212,19 @@ public class ScannerReportReaderTest { } @Test + public void read_plugin_cache() throws IOException { + ScannerReportWriter writer = new ScannerReportWriter(dir); + writer.writePluginCache(PluginCacheMsg.newBuilder() + .putMap("key", ByteString.copyFrom("data", UTF_8)) + .build()); + + ScannerReportReader reader = new ScannerReportReader(dir); + + PluginCacheMsg cache = Protobuf.read(new GZIPInputStream(reader.getPluginCache()), PluginCacheMsg.parser()); + assertThat(cache.getMapMap()).containsOnly(new AbstractMap.SimpleEntry<>("key", ByteString.copyFrom("data", UTF_8))); + } + + @Test public void empty_list_if_no_duplication_block_found() { assertThat(underTest.readComponentDuplications(UNKNOWN_COMPONENT_REF)).toIterable().isEmpty(); } |