diff options
author | Julien HENRY <julien.henry@sonarsource.com> | 2016-05-10 18:45:48 +0200 |
---|---|---|
committer | Julien HENRY <julien.henry@sonarsource.com> | 2016-05-12 08:49:09 +0200 |
commit | f58fdc8b6b65f998e6addfecf7269625366523a5 (patch) | |
tree | 84612146b8e01196cb046ca0f4d2185194e3c2a6 /plugins | |
parent | 1ea649ef747a5938369b6c63c27e767a550f476b (diff) | |
download | sonarqube-f58fdc8b6b65f998e6addfecf7269625366523a5.tar.gz sonarqube-f58fdc8b6b65f998e6addfecf7269625366523a5.zip |
SONAR-7612 Improve documentation and SensorContextTester
Diffstat (limited to 'plugins')
3 files changed, 8 insertions, 15 deletions
diff --git a/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/lang/CpdTokenizerSensorTest.java b/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/lang/CpdTokenizerSensorTest.java index c58f85a9be7..ff329593106 100644 --- a/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/lang/CpdTokenizerSensorTest.java +++ b/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/lang/CpdTokenizerSensorTest.java @@ -21,7 +21,6 @@ package org.sonar.xoo.lang; import java.io.File; import java.io.IOException; -import java.io.StringReader; import org.apache.commons.io.FileUtils; import org.junit.Before; import org.junit.Rule; @@ -29,7 +28,6 @@ import org.junit.Test; import org.junit.rules.ExpectedException; import org.junit.rules.TemporaryFolder; import org.sonar.api.batch.fs.internal.DefaultInputFile; -import org.sonar.api.batch.fs.internal.FileMetadata; import org.sonar.api.batch.sensor.internal.DefaultSensorDescriptor; import org.sonar.api.batch.sensor.internal.SensorContextTester; @@ -80,7 +78,7 @@ public class CpdTokenizerSensorTest { FileUtils.write(sourceFile, content); DefaultInputFile inputFile = new DefaultInputFile("foo", "src/foo.xoo") .setLanguage("xoo") - .initMetadata(new FileMetadata().readMetadata(new StringReader(content))); + .initMetadata(content); context.fileSystem().add(inputFile); } diff --git a/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/lang/SyntaxHighlightingSensorTest.java b/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/lang/SyntaxHighlightingSensorTest.java index ade4d17c637..0a2b80da414 100644 --- a/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/lang/SyntaxHighlightingSensorTest.java +++ b/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/lang/SyntaxHighlightingSensorTest.java @@ -19,21 +19,18 @@ */ package org.sonar.xoo.lang; +import java.io.File; +import java.io.IOException; import org.apache.commons.io.FileUtils; import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.rules.TemporaryFolder; import org.sonar.api.batch.fs.internal.DefaultInputFile; -import org.sonar.api.batch.fs.internal.FileMetadata; import org.sonar.api.batch.sensor.highlighting.TypeOfText; import org.sonar.api.batch.sensor.internal.DefaultSensorDescriptor; import org.sonar.api.batch.sensor.internal.SensorContextTester; -import java.io.File; -import java.io.IOException; -import java.io.StringReader; - import static org.assertj.core.api.Assertions.assertThat; public class SyntaxHighlightingSensorTest { @@ -69,7 +66,7 @@ public class SyntaxHighlightingSensorTest { File symbol = new File(baseDir, "src/foo.xoo.highlighting"); FileUtils.write(symbol, "1:4:k\n12:15:cppd\n\n#comment"); DefaultInputFile inputFile = new DefaultInputFile("foo", "src/foo.xoo").setLanguage("xoo") - .initMetadata(new FileMetadata().readMetadata(new StringReader(" xoo\nazertyazer\nfoo"))); + .initMetadata(" xoo\nazertyazer\nfoo"); context.fileSystem().add(inputFile); sensor.execute(context); diff --git a/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/rule/OneIssuePerLineSensorTest.java b/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/rule/OneIssuePerLineSensorTest.java index 8993bac751e..f182004de3e 100644 --- a/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/rule/OneIssuePerLineSensorTest.java +++ b/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/rule/OneIssuePerLineSensorTest.java @@ -20,12 +20,10 @@ package org.sonar.xoo.rule; import java.io.IOException; -import java.io.StringReader; import org.junit.Rule; import org.junit.Test; import org.junit.rules.TemporaryFolder; import org.sonar.api.batch.fs.internal.DefaultInputFile; -import org.sonar.api.batch.fs.internal.FileMetadata; import org.sonar.api.batch.rule.Severity; import org.sonar.api.batch.sensor.internal.DefaultSensorDescriptor; import org.sonar.api.batch.sensor.internal.SensorContextTester; @@ -52,7 +50,7 @@ public class OneIssuePerLineSensorTest { @Test public void testRule() throws IOException { DefaultInputFile inputFile = new DefaultInputFile("foo", "src/Foo.xoo").setLanguage(Xoo.KEY) - .initMetadata(new FileMetadata().readMetadata(new StringReader("a\nb\nc\nd\ne\nf\ng\nh\ni\n"))); + .initMetadata("a\nb\nc\nd\ne\nf\ng\nh\ni\n"); SensorContextTester context = SensorContextTester.create(temp.newFolder()); context.fileSystem().add(inputFile); @@ -67,7 +65,7 @@ public class OneIssuePerLineSensorTest { @Test public void testForceSeverity() throws IOException { DefaultInputFile inputFile = new DefaultInputFile("foo", "src/Foo.xoo").setLanguage(Xoo.KEY) - .initMetadata(new FileMetadata().readMetadata(new StringReader("a\nb\nc\nd\ne\nf\ng\nh\ni\n"))); + .initMetadata("a\nb\nc\nd\ne\nf\ng\nh\ni\n"); SensorContextTester context = SensorContextTester.create(temp.newFolder()); context.fileSystem().add(inputFile); @@ -84,7 +82,7 @@ public class OneIssuePerLineSensorTest { @Test public void testProvideGap() throws IOException { DefaultInputFile inputFile = new DefaultInputFile("foo", "src/Foo.xoo").setLanguage(Xoo.KEY) - .initMetadata(new FileMetadata().readMetadata(new StringReader("a\nb\nc\nd\ne\nf\ng\nh\ni\n"))); + .initMetadata("a\nb\nc\nd\ne\nf\ng\nh\ni\n"); SensorContextTester context = SensorContextTester.create(temp.newFolder()); context.fileSystem().add(inputFile); @@ -101,7 +99,7 @@ public class OneIssuePerLineSensorTest { @Test public void testProvideGap_before_5_5() throws IOException { DefaultInputFile inputFile = new DefaultInputFile("foo", "src/Foo.xoo").setLanguage(Xoo.KEY) - .initMetadata(new FileMetadata().readMetadata(new StringReader("a\nb\nc\nd\ne\nf\ng\nh\ni\n"))); + .initMetadata("a\nb\nc\nd\ne\nf\ng\nh\ni\n"); SensorContextTester context = SensorContextTester.create(temp.newFolder()); context.fileSystem().add(inputFile); |