本文整理汇总了Java中org.sonar.api.batch.fs.internal.DefaultFileSystem.add方法的典型用法代码示例。如果您正苦于以下问题:Java DefaultFileSystem.add方法的具体用法?Java DefaultFileSystem.add怎么用?Java DefaultFileSystem.add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.sonar.api.batch.fs.internal.DefaultFileSystem
的用法示例。
在下文中一共展示了DefaultFileSystem.add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testExecute
import org.sonar.api.batch.fs.internal.DefaultFileSystem; //导入方法依赖的package包/类
@Test
public void testExecute() throws IOException {
Context t = new RulesDefinition.Context();
ScriptAnalyzerRulesDefinition def = new ScriptAnalyzerRulesDefinition();
def.define(t);
File baseFile = folder.newFile("test.ps1");
FileUtils.copyURLToFile(getClass().getResource("/testFiles/test.ps1"), baseFile);
DefaultFileSystem fs = new DefaultFileSystem(folder.getRoot());
DefaultInputFile ti = new DefaultInputFile("test", "test.ps1");
ti.initMetadata(new String(Files.readAllBytes(baseFile.toPath())));
fs.add(ti);
SensorContextTester ctxTester = SensorContextTester.create(folder.getRoot());
ScriptAnalyzerSensor s = new ScriptAnalyzerSensor(fs, temp);
s.execute(ctxTester);
Assert.assertEquals(4, ctxTester.allIssues().size());
}
示例2: testExecute
import org.sonar.api.batch.fs.internal.DefaultFileSystem; //导入方法依赖的package包/类
@Test
public void testExecute() throws IOException, InterruptedException {
File baseFile = folder.newFile("test.ps1");
FileUtils.copyURLToFile(getClass().getResource("/testFiles/test.ps1"), baseFile);
DefaultFileSystem fs = new DefaultFileSystem(folder.getRoot());
DefaultInputFile ti = new DefaultInputFile("test", "test.ps1");
ti.initMetadata(new String(Files.readAllBytes(baseFile.toPath())));
ti.setLanguage(PowershellLanguage.KEY);
fs.add(ti);
SensorContextTester ctxTester = SensorContextTester.create(folder.getRoot());
ctxTester.setFileSystem(fs);
TokenizerSensor s = new TokenizerSensor(new Settings(), temp);
s.execute(ctxTester);
Assert.assertEquals(16, ctxTester.cpdTokens("test:test.ps1").size());
Assert.assertEquals(1, ctxTester.highlightingTypeAt("test:test.ps1", 1, 5).size());
}
示例3: setUp
import org.sonar.api.batch.fs.internal.DefaultFileSystem; //导入方法依赖的package包/类
@Before
public void setUp() throws IOException {
DefaultFileSystem fileSystem = new DefaultFileSystem(tempFolder.getRoot());
fileSystem.setEncoding(Charsets.UTF_8);
file = tempFolder.newFile();
inputFile = new DefaultInputFile("moduleKey", file.getName())
.setLanguage("less")
.setType(InputFile.Type.MAIN);
fileSystem.add(inputFile);
sensorContext = SensorContextTester.create(tempFolder.getRoot());
sensorContext.setFileSystem(fileSystem);
visitorContext = mock(TreeVisitorContext.class);
highlighterVisitor = new LessSyntaxHighlighterVisitor(sensorContext);
when(visitorContext.getFile()).thenReturn(file);
}
示例4: setUp
import org.sonar.api.batch.fs.internal.DefaultFileSystem; //导入方法依赖的package包/类
@Before
public void setUp() throws IOException {
DefaultFileSystem fileSystem = new DefaultFileSystem(tempFolder.getRoot());
fileSystem.setEncoding(Charsets.UTF_8);
file = tempFolder.newFile();
inputFile = new DefaultInputFile("moduleKey", file.getName())
.setLanguage("scss")
.setType(InputFile.Type.MAIN);
fileSystem.add(inputFile);
sensorContext = SensorContextTester.create(tempFolder.getRoot());
sensorContext.setFileSystem(fileSystem);
visitorContext = mock(TreeVisitorContext.class);
highlighterVisitor = new ScssSyntaxHighlighterVisitor(sensorContext);
when(visitorContext.getFile()).thenReturn(file);
}
示例5: setUp
import org.sonar.api.batch.fs.internal.DefaultFileSystem; //导入方法依赖的package包/类
@Before
public void setUp() throws IOException {
DefaultFileSystem fileSystem = new DefaultFileSystem(tempFolder.getRoot());
fileSystem.setEncoding(Charsets.UTF_8);
file = tempFolder.newFile();
inputFile = new DefaultInputFile("moduleKey", file.getName())
.setLanguage("css")
.setType(InputFile.Type.MAIN);
fileSystem.add(inputFile);
sensorContext = SensorContextTester.create(tempFolder.getRoot());
sensorContext.setFileSystem(fileSystem);
visitorContext = mock(TreeVisitorContext.class);
highlighterVisitor = new CssSyntaxHighlighterVisitor(sensorContext);
when(visitorContext.getFile()).thenReturn(file);
}
示例6: setUp
import org.sonar.api.batch.fs.internal.DefaultFileSystem; //导入方法依赖的package包/类
@Before
public void setUp() throws IOException {
DefaultFileSystem fileSystem = new DefaultFileSystem(tempFolder.getRoot());
fileSystem.setEncoding(Charsets.UTF_8);
file = tempFolder.newFile();
inputFile = new DefaultInputFile("moduleKey", file.getName())
.setLanguage("css")
.setType(InputFile.Type.MAIN);
fileSystem.add(inputFile);
sensorContext = SensorContextTester.create(tempFolder.getRoot());
sensorContext.setFileSystem(fileSystem);
visitorContext = mock(TreeVisitorContext.class);
cpdVisitor = new CpdVisitor(sensorContext);
when(visitorContext.getFile()).thenReturn(file);
}
示例7: setUp
import org.sonar.api.batch.fs.internal.DefaultFileSystem; //导入方法依赖的package包/类
@Before
public void setUp() throws IOException {
DefaultFileSystem fileSystem = new DefaultFileSystem(tempFolder.getRoot());
fileSystem.setEncoding(Charsets.UTF_8);
file = tempFolder.newFile();
inputFile = new DefaultInputFile("moduleKey", file.getName())
.setLanguage("gherkin")
.setType(InputFile.Type.MAIN);
fileSystem.add(inputFile);
sensorContext = SensorContextTester.create(tempFolder.getRoot());
sensorContext.setFileSystem(fileSystem);
visitorContext = mock(TreeVisitorContext.class);
highlighterVisitor = new SyntaxHighlighterVisitor(sensorContext);
when(visitorContext.getFile()).thenReturn(file);
}
示例8: properFailureIfNotAGitProject
import org.sonar.api.batch.fs.internal.DefaultFileSystem; //导入方法依赖的package包/类
@Test
public void properFailureIfNotAGitProject() throws IOException {
File projectDir = temp.newFolder();
javaUnzip(new File("test-repos/dummy-git.zip"), projectDir);
JGitBlameCommand jGitBlameCommand = new JGitBlameCommand(new PathResolver());
File baseDir = new File(projectDir, "dummy-git");
// Delete .git
FileUtils.forceDelete(new File(baseDir, ".git"));
DefaultFileSystem fs = new DefaultFileSystem(baseDir);
when(input.fileSystem()).thenReturn(fs);
DefaultInputFile inputFile = new TestInputFileBuilder("foo", DUMMY_JAVA).build();
fs.add(inputFile);
BlameOutput blameResult = mock(BlameOutput.class);
when(input.filesToBlame()).thenReturn(Arrays.<InputFile>asList(inputFile));
thrown.expect(MessageException.class);
thrown.expectMessage("Not inside a Git work tree: ");
jGitBlameCommand.blame(input, blameResult);
}
示例9: dontFailOnModifiedFile
import org.sonar.api.batch.fs.internal.DefaultFileSystem; //导入方法依赖的package包/类
@Test
public void dontFailOnModifiedFile() throws IOException {
File projectDir = temp.newFolder();
javaUnzip(new File("test-repos/dummy-git.zip"), projectDir);
JGitBlameCommand jGitBlameCommand = new JGitBlameCommand(new PathResolver());
File baseDir = new File(projectDir, "dummy-git");
DefaultFileSystem fs = new DefaultFileSystem(baseDir);
when(input.fileSystem()).thenReturn(fs);
String relativePath = DUMMY_JAVA;
DefaultInputFile inputFile = new TestInputFileBuilder("foo", relativePath).build();
fs.add(inputFile);
// Emulate a modification
Files.write(baseDir.toPath().resolve(relativePath), "modification and \n some new line".getBytes());
BlameOutput blameResult = mock(BlameOutput.class);
when(input.filesToBlame()).thenReturn(Arrays.<InputFile>asList(inputFile));
jGitBlameCommand.blame(input, blameResult);
}
示例10: dontFailOnNewFile
import org.sonar.api.batch.fs.internal.DefaultFileSystem; //导入方法依赖的package包/类
@Test
public void dontFailOnNewFile() throws IOException {
File projectDir = temp.newFolder();
javaUnzip(new File("test-repos/dummy-git.zip"), projectDir);
JGitBlameCommand jGitBlameCommand = new JGitBlameCommand(new PathResolver());
File baseDir = new File(projectDir, "dummy-git");
DefaultFileSystem fs = new DefaultFileSystem(baseDir);
when(input.fileSystem()).thenReturn(fs);
String relativePath = DUMMY_JAVA;
String relativePath2 = "src/main/java/org/dummy/Dummy2.java";
DefaultInputFile inputFile = new TestInputFileBuilder("foo", relativePath).build();
fs.add(inputFile);
DefaultInputFile inputFile2 = new TestInputFileBuilder("foo", relativePath2).build();
fs.add(inputFile2);
// Emulate a new file
FileUtils.copyFile(new File(baseDir, relativePath), new File(baseDir, relativePath2));
BlameOutput blameResult = mock(BlameOutput.class);
when(input.filesToBlame()).thenReturn(Arrays.<InputFile>asList(inputFile, inputFile2));
jGitBlameCommand.blame(input, blameResult);
}
示例11: setUp
import org.sonar.api.batch.fs.internal.DefaultFileSystem; //导入方法依赖的package包/类
private void setUp(Charset charset) throws IOException {
this.charset = charset;
DefaultFileSystem fileSystem = new DefaultFileSystem(tempFolder.getRoot());
fileSystem.setEncoding(charset);
file = tempFolder.newFile();
inputFile = new DefaultInputFile("moduleKey", file.getName())
.setLanguage("jproperties")
.setType(InputFile.Type.MAIN);
fileSystem.add(inputFile);
sensorContext = SensorContextTester.create(tempFolder.getRoot());
sensorContext.setFileSystem(fileSystem);
visitorContext = mock(TreeVisitorContext.class);
highlighterVisitor = new SyntaxHighlighterVisitor(sensorContext);
when(visitorContext.getFile()).thenReturn(file);
}
示例12: setUp
import org.sonar.api.batch.fs.internal.DefaultFileSystem; //导入方法依赖的package包/类
@Before
public void setUp() throws IOException {
DefaultFileSystem fileSystem = new DefaultFileSystem(tempFolder.getRoot());
fileSystem.setEncoding(Charsets.UTF_8);
file = tempFolder.newFile();
inputFile = new DefaultInputFile("moduleKey", file.getName())
.setLanguage("json")
.setType(InputFile.Type.MAIN);
fileSystem.add(inputFile);
sensorContext = SensorContextTester.create(tempFolder.getRoot());
sensorContext.setFileSystem(fileSystem);
visitorContext = mock(TreeVisitorContext.class);
highlighterVisitor = new SyntaxHighlighterVisitor(sensorContext);
when(visitorContext.getFile()).thenReturn(file);
}
示例13: shouldExecuteOnProject
import org.sonar.api.batch.fs.internal.DefaultFileSystem; //导入方法依赖的package包/类
@Test
public void shouldExecuteOnProject() {
Settings settings = mock(Settings.class);
RulesProfile profile = mock(RulesProfile.class);
DefaultFileSystem fileSystem = new DefaultFileSystem();
ResourcePerspectives perspectives = mock(ResourcePerspectives.class);
Project project = mock(Project.class);
ReSharperSensor sensor = new ReSharperSensor(
new ReSharperConfiguration("lang", "foo-resharper", "fooReportkey"),
settings, profile, fileSystem, perspectives);
assertThat(sensor.shouldExecuteOnProject(project)).isFalse();
fileSystem.add(new DefaultInputFile("").setAbsolutePath("").setLanguage("foo"));
when(profile.getActiveRulesByRepository("foo-resharper")).thenReturn(ImmutableList.<ActiveRule>of());
assertThat(sensor.shouldExecuteOnProject(project)).isFalse();
fileSystem.add(new DefaultInputFile("").setAbsolutePath("").setLanguage("lang"));
when(profile.getActiveRulesByRepository("foo-resharper")).thenReturn(ImmutableList.of(mock(ActiveRule.class)));
assertThat(sensor.shouldExecuteOnProject(project)).isTrue();
when(profile.getActiveRulesByRepository("foo-resharper")).thenReturn(ImmutableList.<ActiveRule>of());
assertThat(sensor.shouldExecuteOnProject(project)).isFalse();
}
示例14: analyse2
import org.sonar.api.batch.fs.internal.DefaultFileSystem; //导入方法依赖的package包/类
@Test
public void analyse2() throws FileNotFoundException {
DefaultFileSystem fs = new DefaultFileSystem(TEST_DIR);
tester.setFileSystem(fs);
DefaultInputFile inputFile = new DefaultInputFile("key", "timeFormatter.lua")
.setType(InputFile.Type.MAIN)
.setLanguage(Lua.KEY)
.initMetadata(new FileMetadata().readMetadata(new FileReader(new File(TEST_DIR, "timeFormatter.lua"))));
fs.add(inputFile);
sensor.execute(tester);
String componentKey = inputFile.key();
assertThat(tester.measure(componentKey, CoreMetrics.COMPLEXITY_IN_CLASSES).value()).isEqualTo(0);
assertThat(tester.measure(componentKey, CoreMetrics.NCLOC).value()).isEqualTo(0);
assertThat(tester.measure(componentKey, CoreMetrics.COMMENT_LINES).value()).isEqualTo(59);
assertThat(tester.measure(componentKey, CoreMetrics.STATEMENTS).value()).isEqualTo(0);
assertThat(tester.measure(componentKey, CoreMetrics.FUNCTIONS).value()).isEqualTo(0);
assertThat(tester.measure(componentKey, CoreMetrics.COMPLEXITY).value()).isEqualTo(0);
assertThat(tester.measure(componentKey, CoreMetrics.FILE_COMPLEXITY_DISTRIBUTION).value()).isEqualTo("0=1;5=0;10=0;20=0;30=0;60=0;90=0");
assertThat(tester.measure(componentKey, CoreMetrics.FUNCTION_COMPLEXITY_DISTRIBUTION).value()).isEqualTo("1=0;2=0;4=0;6=0;8=0;10=0;12=0");
assertThat(tester.allIssues()).hasSize(0);
}
示例15: testDecreasingOverallCoverageRule
import org.sonar.api.batch.fs.internal.DefaultFileSystem; //导入方法依赖的package包/类
@Test
public void testDecreasingOverallCoverageRule() {
DefaultFileSystem fs = new DefaultFileSystem(null);
fs.addLanguages("c", "java", "xml");
fs.add(new DefaultInputFile("a.java").setAbsolutePath("a.java").setLanguage("java").setLines(10));
fs.add(new DefaultInputFile("b.java").setAbsolutePath("b.java").setLanguage("java").setLines(15));
fs.add(new DefaultInputFile("foo.c").setAbsolutePath("foo.c").setLanguage("c").setLines(20));
assertEquals("java", CoverageRule.mostCommonLanguage(fs));
}