本文整理汇总了Java中org.sonar.api.batch.fs.internal.DefaultFileSystem类的典型用法代码示例。如果您正苦于以下问题:Java DefaultFileSystem类的具体用法?Java DefaultFileSystem怎么用?Java DefaultFileSystem使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DefaultFileSystem类属于org.sonar.api.batch.fs.internal包,在下文中一共展示了DefaultFileSystem类的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: should_fail_fast_when_clone_is_shallow
import org.sonar.api.batch.fs.internal.DefaultFileSystem; //导入依赖的package包/类
@Test
public void should_fail_fast_when_clone_is_shallow() throws IOException {
File projectDir = temp.newFolder();
javaUnzip(new File("test-repos/shallow-git.zip"), projectDir);
File baseDir = new File(projectDir, "shallow-git");
DefaultFileSystem fs = new DefaultFileSystem(baseDir);
when(input.fileSystem()).thenReturn(fs);
DefaultInputFile inputFile = new TestInputFileBuilder("foo", DUMMY_JAVA).build();
when(input.filesToBlame()).thenReturn(Collections.singleton(inputFile));
JGitBlameCommand jGitBlameCommand = new JGitBlameCommand(new PathResolver());
BlameOutput output = mock(BlameOutput.class);
jGitBlameCommand.blame(input, output);
assertThat(logTester.logs()).first()
.matches(s -> s.contains("Shallow clone detected, no blame information will be provided."));
verifyZeroInteractions(output);
}
示例12: 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);
}
示例13: 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);
}
示例14: 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();
}
示例15: assertDelta
import org.sonar.api.batch.fs.internal.DefaultFileSystem; //导入依赖的package包/类
public void assertDelta(String content, int offsetDeltaExpected, int lineDeltaExpected) throws Exception {
String fileName = "char_before_prolog.xml";
File file = tmpFolder.newFile(fileName);
FileUtils.write(file, content);
DefaultInputFile inputFile = new DefaultInputFile("modulekey", fileName)
.setModuleBaseDir(file.getParentFile().toPath())
.setType(InputFile.Type.MAIN)
.setLanguage(Xml.KEY)
.setCharset(StandardCharsets.UTF_8);
DefaultFileSystem localFS = new DefaultFileSystem(new File(file.getParent()));
localFS.add(inputFile).setWorkDir(tmpFolder.newFolder());
XmlFile xmlFile = new XmlFile(wrap(inputFile), localFS);
assertThat(xmlFile.getOffsetDelta()).isEqualTo(offsetDeltaExpected);
assertThat(xmlFile.getLineDelta()).isEqualTo(lineDeltaExpected);
}