diff options
author | Duarte Meneses <duarte.meneses@sonarsource.com> | 2023-01-06 17:42:28 -0600 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2023-01-12 20:02:51 +0000 |
commit | 8b2213ef7a6777709d981a83c4d875951f225cc5 (patch) | |
tree | f32d286387e7919c2721e259a2380754a9041040 /sonar-scanner-protocol | |
parent | 62bfeeb68576a0a81427e12d9168dad3cec18f5b (diff) | |
download | sonarqube-8b2213ef7a6777709d981a83c4d875951f225cc5.tar.gz sonarqube-8b2213ef7a6777709d981a83c4d875951f225cc5.zip |
SONAR-18174 Analyzer cache should be kept in the file system to decrease memory use
Diffstat (limited to 'sonar-scanner-protocol')
10 files changed, 186 insertions, 88 deletions
diff --git a/sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/internal/SensorCacheData.java b/sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/internal/SensorCacheData.java new file mode 100644 index 00000000000..3c73095a3dd --- /dev/null +++ b/sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/internal/SensorCacheData.java @@ -0,0 +1,39 @@ +/* + * SonarQube + * Copyright (C) 2009-2023 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.scanner.protocol.internal; + +import com.google.protobuf.ByteString; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; +import org.sonar.scanner.protocol.internal.ScannerInternal.SensorCacheEntry; + +public class SensorCacheData { + private final Map<String, ByteString> map; + + public SensorCacheData(List<SensorCacheEntry> entries) { + this.map = Collections.unmodifiableMap(entries.stream().collect(Collectors.toMap(SensorCacheEntry::getKey, SensorCacheEntry::getData))); + } + + public Map<String, ByteString> getEntries() { + return map; + } +} diff --git a/sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/internal/package-info.java b/sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/internal/package-info.java new file mode 100644 index 00000000000..cb2876cd8f1 --- /dev/null +++ b/sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/internal/package-info.java @@ -0,0 +1,24 @@ +/* + * SonarQube + * Copyright (C) 2009-2023 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +@ParametersAreNonnullByDefault +package org.sonar.scanner.protocol.internal; + +import javax.annotation.ParametersAreNonnullByDefault; + diff --git a/sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/output/FileStructure.java b/sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/output/FileStructure.java index d39c7aecea3..1928b5a00ff 100644 --- a/sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/output/FileStructure.java +++ b/sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/output/FileStructure.java @@ -67,7 +67,7 @@ public class FileStructure { } public File analysisCache() { - return new File(dir, "analysis-cache.pb"); + return new File(dir, "analysis-cache2.pb"); } public File analysisLog() { diff --git a/sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/output/ScannerReportReader.java b/sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/output/ScannerReportReader.java index c691fd08f3f..fd34d12a3b1 100644 --- a/sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/output/ScannerReportReader.java +++ b/sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/output/ScannerReportReader.java @@ -31,11 +31,10 @@ import org.sonar.core.util.Protobuf; import static org.sonar.core.util.CloseableIterator.emptyCloseableIterator; public class ScannerReportReader { - private final FileStructure fileStructure; - public ScannerReportReader(File dir) { - this.fileStructure = new FileStructure(dir); + public ScannerReportReader(FileStructure fileStructure) { + this.fileStructure = fileStructure; } public ScannerReport.Metadata readMetadata() { diff --git a/sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/output/ScannerReportWriter.java b/sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/output/ScannerReportWriter.java index c33cb94c8f7..a5dac430352 100644 --- a/sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/output/ScannerReportWriter.java +++ b/sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/output/ScannerReportWriter.java @@ -30,14 +30,10 @@ import org.sonar.scanner.protocol.internal.ScannerInternal; @Immutable public class ScannerReportWriter { - private final FileStructure fileStructure; - public ScannerReportWriter(File dir) { - if (!dir.exists() && !dir.mkdirs()) { - throw new IllegalStateException("Unable to create directory: " + dir); - } - this.fileStructure = new FileStructure(dir); + public ScannerReportWriter(FileStructure fileStructure) { + this.fileStructure = fileStructure; } public FileStructure getFileStructure() { @@ -95,12 +91,6 @@ public class ScannerReportWriter { return file; } - public File writeAnalysisCache(ScannerInternal.AnalysisCacheMsg cacheMsg) { - File file = fileStructure.analysisCache(); - Protobuf.writeGzip(cacheMsg, file); - return file; - } - public void appendComponentExternalIssue(int componentRef, ScannerReport.ExternalIssue issue) { File file = fileStructure.fileFor(FileStructure.Domain.EXTERNAL_ISSUES, componentRef); try (OutputStream out = new BufferedOutputStream(new FileOutputStream(file, true))) { diff --git a/sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/viewer/ScannerReportViewerApp.java b/sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/viewer/ScannerReportViewerApp.java index 4b95558619d..21b9e47d442 100644 --- a/sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/viewer/ScannerReportViewerApp.java +++ b/sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/viewer/ScannerReportViewerApp.java @@ -19,7 +19,10 @@ */ package org.sonar.scanner.protocol.viewer; -import java.awt.*; +import java.awt.BorderLayout; +import java.awt.Cursor; +import java.awt.Dimension; +import java.awt.EventQueue; import java.io.File; import java.io.IOException; import java.io.PrintWriter; @@ -31,7 +34,16 @@ import java.util.List; import java.util.Map; import java.util.Scanner; import javax.annotation.CheckForNull; -import javax.swing.*; +import javax.swing.JEditorPane; +import javax.swing.JFileChooser; +import javax.swing.JFrame; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JSplitPane; +import javax.swing.JTabbedPane; +import javax.swing.JTree; +import javax.swing.UIManager; import javax.swing.UIManager.LookAndFeelInfo; import javax.swing.event.TreeSelectionEvent; import javax.swing.event.TreeSelectionListener; @@ -41,6 +53,7 @@ import javax.swing.tree.TreeSelectionModel; import org.apache.commons.io.FileUtils; import org.apache.commons.lang.StringUtils; import org.sonar.core.util.CloseableIterator; +import org.sonar.scanner.protocol.output.FileStructure; import org.sonar.scanner.protocol.output.FileStructure.Domain; import org.sonar.scanner.protocol.output.ScannerReport; import org.sonar.scanner.protocol.output.ScannerReport.Changesets; @@ -111,19 +124,15 @@ public class ScannerReportViewerApp { * Launch the application. */ public static void main(String[] args) { - EventQueue.invokeLater(new Runnable() { - @Override - public void run() { - try { - ScannerReportViewerApp window = new ScannerReportViewerApp(); - window.frame.setVisible(true); - - window.loadReport(); - } catch (Exception e) { - e.printStackTrace(); - } - } + EventQueue.invokeLater(() -> { + try { + ScannerReportViewerApp window = new ScannerReportViewerApp(); + window.frame.setVisible(true); + window.loadReport(); + } catch (Exception e) { + e.printStackTrace(); + } }); } @@ -184,7 +193,8 @@ public class ScannerReportViewerApp { } private void loadReport(File file) { - reader = new ScannerReportReader(file); + FileStructure fileStructure = new FileStructure(file); + reader = new ScannerReportReader(fileStructure); metadata = reader.readMetadata(); updateTitle(); loadComponents(); @@ -651,13 +661,6 @@ public class ScannerReportViewerApp { return componentTree; } - /** - * @wbp.factory - */ - public static JPanel createComponentPanel() { - return new JPanel(); - } - protected JEditorPane getComponentEditor() { return componentEditor; } diff --git a/sonar-scanner-protocol/src/main/protobuf/scanner_internal.proto b/sonar-scanner-protocol/src/main/protobuf/scanner_internal.proto index 4a9f0c53a58..e384b6252f0 100644 --- a/sonar-scanner-protocol/src/main/protobuf/scanner_internal.proto +++ b/sonar-scanner-protocol/src/main/protobuf/scanner_internal.proto @@ -3,6 +3,7 @@ syntax = "proto3"; option java_package = "org.sonar.scanner.protocol.internal"; option optimize_for = SPEED; -message AnalysisCacheMsg { - map<string, bytes> map = 1; +message SensorCacheEntry { + string key = 1; + bytes data = 2; } diff --git a/sonar-scanner-protocol/src/test/java/org/sonar/scanner/protocol/internal/SensorCacheDataTest.java b/sonar-scanner-protocol/src/test/java/org/sonar/scanner/protocol/internal/SensorCacheDataTest.java new file mode 100644 index 00000000000..fa769fc3355 --- /dev/null +++ b/sonar-scanner-protocol/src/test/java/org/sonar/scanner/protocol/internal/SensorCacheDataTest.java @@ -0,0 +1,41 @@ +/* + * SonarQube + * Copyright (C) 2009-2023 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.scanner.protocol.internal; + +import com.google.protobuf.ByteString; +import java.util.List; +import org.junit.Test; +import org.sonar.scanner.protocol.internal.ScannerInternal.SensorCacheEntry; + +import static java.nio.charset.StandardCharsets.UTF_8; +import static java.util.Map.entry; +import static org.assertj.core.api.Assertions.assertThat; + +public class SensorCacheDataTest { + @Test + public void constructor_processes_entries() { + SensorCacheEntry entry1 = SensorCacheEntry.newBuilder().setKey("key1").setData(ByteString.copyFrom("data1", UTF_8)).build(); + SensorCacheEntry entry2 = SensorCacheEntry.newBuilder().setKey("key2").setData(ByteString.copyFrom("data2", UTF_8)).build(); + + SensorCacheData data = new SensorCacheData(List.of(entry1, entry2)); + assertThat(data.getEntries()).containsExactly(entry(entry1.getKey(), entry1.getData()), entry(entry2.getKey(), entry2.getData())); + } + +} 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 06c272c8b95..ac686857cbb 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 @@ -25,8 +25,8 @@ 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 java.util.LinkedList; +import java.util.List; import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; import org.junit.Before; @@ -35,8 +35,7 @@ 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; -import org.sonar.scanner.protocol.internal.ScannerInternal.AnalysisCacheMsg; +import org.sonar.scanner.protocol.internal.ScannerInternal.SensorCacheEntry; import org.sonar.scanner.protocol.output.ScannerReport.Measure.StringValue; import org.sonar.scanner.protocol.output.ScannerReport.SyntaxHighlightingRule.HighlightingType; @@ -47,24 +46,24 @@ import static org.assertj.core.api.Assertions.assertThat; public class ScannerReportReaderTest { - private static int UNKNOWN_COMPONENT_REF = 123; + private static final int UNKNOWN_COMPONENT_REF = 123; @Rule public TemporaryFolder temp = new TemporaryFolder(); - private File dir; - + private FileStructure fileStructure; private ScannerReportReader underTest; @Before public void setUp() throws Exception { - dir = temp.newFolder(); - underTest = new ScannerReportReader(dir); + File dir = temp.newFolder(); + fileStructure = new FileStructure(dir); + underTest = new ScannerReportReader(fileStructure); } @Test public void read_metadata() { - ScannerReportWriter writer = new ScannerReportWriter(dir); + ScannerReportWriter writer = new ScannerReportWriter(fileStructure); ScannerReport.Metadata.Builder metadata = ScannerReport.Metadata.newBuilder() .setAnalysisDate(15000000L) .setProjectKey("PROJECT_A") @@ -86,7 +85,7 @@ public class ScannerReportReaderTest { @Test public void read_components() { - ScannerReportWriter writer = new ScannerReportWriter(dir); + ScannerReportWriter writer = new ScannerReportWriter(fileStructure); ScannerReport.Component.Builder component = ScannerReport.Component.newBuilder() .setRef(1) .setProjectRelativePath("src/main/java/Foo.java"); @@ -102,7 +101,7 @@ public class ScannerReportReaderTest { @Test public void read_issues() { - ScannerReportWriter writer = new ScannerReportWriter(dir); + ScannerReportWriter writer = new ScannerReportWriter(fileStructure); ScannerReport.Issue issue = ScannerReport.Issue.newBuilder() .build(); writer.writeComponentIssues(1, asList(issue)); @@ -113,7 +112,7 @@ public class ScannerReportReaderTest { @Test public void read_external_issues() { - ScannerReportWriter writer = new ScannerReportWriter(dir); + ScannerReportWriter writer = new ScannerReportWriter(fileStructure); ScannerReport.ExternalIssue issue = ScannerReport.ExternalIssue.newBuilder() .build(); writer.appendComponentExternalIssue(1, issue); @@ -129,7 +128,7 @@ public class ScannerReportReaderTest { @Test public void read_measures() { - ScannerReportWriter writer = new ScannerReportWriter(dir); + ScannerReportWriter writer = new ScannerReportWriter(fileStructure); ScannerReport.Measure.Builder measure = ScannerReport.Measure.newBuilder() .setStringValue(StringValue.newBuilder().setValue("value_a")); writer.appendComponentMeasure(1, measure.build()); @@ -144,7 +143,7 @@ public class ScannerReportReaderTest { @Test public void read_changesets() { - ScannerReportWriter writer = new ScannerReportWriter(dir); + ScannerReportWriter writer = new ScannerReportWriter(fileStructure); ScannerReport.Changesets.Builder scm = ScannerReport.Changesets.newBuilder() .setComponentRef(1) .addChangeset(ScannerReport.Changesets.Changeset.newBuilder().setDate(123_456_789).setAuthor("jack.daniels").setRevision("123-456-789")); @@ -161,7 +160,7 @@ public class ScannerReportReaderTest { @Test public void read_duplications() { - ScannerReportWriter writer = new ScannerReportWriter(dir); + ScannerReportWriter writer = new ScannerReportWriter(fileStructure); writer.writeMetadata(ScannerReport.Metadata.newBuilder() .setRootComponentRef(1).build()); writer.writeComponent(ScannerReport.Component.newBuilder() @@ -182,7 +181,7 @@ public class ScannerReportReaderTest { .build(); writer.writeComponentDuplications(1, asList(duplication)); - ScannerReportReader sut = new ScannerReportReader(dir); + ScannerReportReader sut = new ScannerReportReader(fileStructure); assertThat(sut.readComponentDuplications(1)).toIterable().hasSize(1); } @@ -193,7 +192,7 @@ public class ScannerReportReaderTest { @Test public void read_duplication_blocks() { - ScannerReportWriter writer = new ScannerReportWriter(dir); + ScannerReportWriter writer = new ScannerReportWriter(fileStructure); writer.writeMetadata(ScannerReport.Metadata.newBuilder() .setRootComponentRef(1).build()); writer.writeComponent(ScannerReport.Component.newBuilder() @@ -208,37 +207,46 @@ public class ScannerReportReaderTest { .build(); writer.writeCpdTextBlocks(1, singletonList(duplicationBlock)); - ScannerReportReader sut = new ScannerReportReader(dir); + ScannerReportReader sut = new ScannerReportReader(fileStructure); assertThat(sut.readCpdTextBlocks(1)).toIterable().hasSize(1); } @Test public void read_analysis_cache() throws IOException { - ScannerReportWriter writer = new ScannerReportWriter(dir); - writer.writeAnalysisCache(ScannerInternal.AnalysisCacheMsg.newBuilder() - .putMap("key", ByteString.copyFrom("data", UTF_8)) - .build()); + ScannerReportWriter writer = new ScannerReportWriter(fileStructure); + + SensorCacheEntry entry1 = SensorCacheEntry.newBuilder() + .setKey("key") + .setData(ByteString.copyFrom("data", UTF_8)) + .build(); + SensorCacheEntry entry2 = SensorCacheEntry.newBuilder() + .setKey("key") + .setData(ByteString.copyFrom("data", UTF_8)) + .build(); - ScannerReportReader reader = new ScannerReportReader(dir); + Protobuf.writeStream(List.of(entry1, entry2), fileStructure.analysisCache(), false); + ScannerReportReader reader = new ScannerReportReader(fileStructure); - AnalysisCacheMsg cache = Protobuf.read(new GZIPInputStream(reader.getAnalysisCache()), ScannerInternal.AnalysisCacheMsg.parser()); - assertThat(cache.getMapMap()).containsOnly(new AbstractMap.SimpleEntry<>("key", ByteString.copyFrom("data", UTF_8))); + CloseableIterator<SensorCacheEntry> it = Protobuf.readStream(reader.getAnalysisCache(), SensorCacheEntry.parser()); + List<SensorCacheEntry> data = new LinkedList<>(); + it.forEachRemaining(data::add); + assertThat(data).containsExactly(entry1, entry2); } @Test public void read_analysis_cache_returns_null_if_no_file_exists() { - ScannerReportReader reader = new ScannerReportReader(dir); + ScannerReportReader reader = new ScannerReportReader(fileStructure); assertThat(reader.getAnalysisCache()).isNull(); } - @Test + @Test public void empty_list_if_no_duplication_block_found() { assertThat(underTest.readComponentDuplications(UNKNOWN_COMPONENT_REF)).toIterable().isEmpty(); } @Test public void read_syntax_highlighting() { - ScannerReportWriter writer = new ScannerReportWriter(dir); + ScannerReportWriter writer = new ScannerReportWriter(fileStructure); writer.writeMetadata(ScannerReport.Metadata.newBuilder() .setRootComponentRef(1) .build()); @@ -270,7 +278,7 @@ public class ScannerReportReaderTest { @Test public void read_symbols() { - ScannerReportWriter writer = new ScannerReportWriter(dir); + ScannerReportWriter writer = new ScannerReportWriter(fileStructure); writer.writeMetadata(ScannerReport.Metadata.newBuilder() .setRootComponentRef(1) .build()); @@ -292,7 +300,7 @@ public class ScannerReportReaderTest { .build()) .build())); - underTest = new ScannerReportReader(dir); + underTest = new ScannerReportReader(fileStructure); assertThat(underTest.readComponentSymbols(1)).toIterable().hasSize(1); } @@ -303,7 +311,7 @@ public class ScannerReportReaderTest { @Test public void read_coverage() { - ScannerReportWriter writer = new ScannerReportWriter(dir); + ScannerReportWriter writer = new ScannerReportWriter(fileStructure); writer.writeMetadata(ScannerReport.Metadata.newBuilder() .setRootComponentRef(1) .build()); @@ -324,8 +332,8 @@ public class ScannerReportReaderTest { .setCoveredConditions(4) .build())); - underTest = new ScannerReportReader(dir); - try (CloseableIterator<ScannerReport.LineCoverage> it = new ScannerReportReader(dir).readComponentCoverage(1)) { + underTest = new ScannerReportReader(fileStructure); + try (CloseableIterator<ScannerReport.LineCoverage> it = new ScannerReportReader(fileStructure).readComponentCoverage(1)) { ScannerReport.LineCoverage coverage = it.next(); assertThat(coverage.getLine()).isOne(); assertThat(coverage.getConditions()).isOne(); @@ -341,17 +349,17 @@ public class ScannerReportReaderTest { @Test public void read_source_lines() throws Exception { - ScannerReportWriter writer = new ScannerReportWriter(dir); + ScannerReportWriter writer = new ScannerReportWriter(fileStructure); File file = writer.getFileStructure().fileFor(FileStructure.Domain.SOURCE, 1); FileUtils.writeLines(file, Lists.newArrayList("line1", "line2")); - File sourceFile = new ScannerReportReader(dir).readFileSource(1); + File sourceFile = new ScannerReportReader(fileStructure).readFileSource(1); assertThat(sourceFile).isEqualTo(file); } @Test public void read_file_source() throws Exception { - ScannerReportWriter writer = new ScannerReportWriter(dir); + ScannerReportWriter writer = new ScannerReportWriter(fileStructure); try (FileOutputStream outputStream = new FileOutputStream(writer.getSourceFile(1))) { IOUtils.write("line1\nline2", outputStream); } diff --git a/sonar-scanner-protocol/src/test/java/org/sonar/scanner/protocol/output/ScannerReportWriterTest.java b/sonar-scanner-protocol/src/test/java/org/sonar/scanner/protocol/output/ScannerReportWriterTest.java index 1cdb81fe6ac..9cc354a16f6 100644 --- a/sonar-scanner-protocol/src/test/java/org/sonar/scanner/protocol/output/ScannerReportWriterTest.java +++ b/sonar-scanner-protocol/src/test/java/org/sonar/scanner/protocol/output/ScannerReportWriterTest.java @@ -41,20 +41,13 @@ public class ScannerReportWriterTest { @Rule public TemporaryFolder temp = new TemporaryFolder(); File dir; - ScannerReportWriter underTest; + private FileStructure fileStructure; + private ScannerReportWriter underTest; @Before public void setUp() throws Exception { - dir = temp.newFolder(); - underTest = new ScannerReportWriter(dir); - } - - @Test - public void create_dir_if_does_not_exist() { - FileUtils.deleteQuietly(dir); - underTest = new ScannerReportWriter(dir); - - assertThat(dir).isDirectory().exists(); + fileStructure = new FileStructure(temp.newFolder()); + underTest = new ScannerReportWriter(fileStructure); } @Test |