当前位置: 首页>>代码示例>>Java>>正文


Java DefaultFileSystem.add方法代码示例

本文整理汇总了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());

}
 
开发者ID:gretard,项目名称:sonar-ps-plugin,代码行数:24,代码来源:ScriptAnalyzerSensorTest.java

示例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());

}
 
开发者ID:gretard,项目名称:sonar-ps-plugin,代码行数:22,代码来源:TokenizerSensorTest.java

示例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);
}
 
开发者ID:racodond,项目名称:sonar-css-plugin,代码行数:18,代码来源:LessSyntaxHighlighterVisitorTest.java

示例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);
}
 
开发者ID:racodond,项目名称:sonar-css-plugin,代码行数:18,代码来源:ScssSyntaxHighlighterVisitorTest.java

示例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);
}
 
开发者ID:racodond,项目名称:sonar-css-plugin,代码行数:18,代码来源:CssSyntaxHighlighterVisitorTest.java

示例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);
}
 
开发者ID:racodond,项目名称:sonar-css-plugin,代码行数:18,代码来源:CpdVisitorTest.java

示例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);
}
 
开发者ID:racodond,项目名称:sonar-gherkin-plugin,代码行数:17,代码来源:SyntaxHighlighterVisitorTest.java

示例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);
}
 
开发者ID:SonarSource,项目名称:sonar-scm-git,代码行数:26,代码来源:JGitBlameCommandTest.java

示例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);
}
 
开发者ID:SonarSource,项目名称:sonar-scm-git,代码行数:23,代码来源:JGitBlameCommandTest.java

示例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);
}
 
开发者ID:SonarSource,项目名称:sonar-scm-git,代码行数:26,代码来源:JGitBlameCommandTest.java

示例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);
}
 
开发者ID:racodond,项目名称:sonar-jproperties-plugin,代码行数:17,代码来源:SyntaxHighlighterVisitorTest.java

示例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);
}
 
开发者ID:racodond,项目名称:sonar-json-plugin,代码行数:17,代码来源:SyntaxHighlighterVisitorTest.java

示例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();
}
 
开发者ID:GregBartlett,项目名称:sonar-resharper,代码行数:27,代码来源:ReSharperSensorTest.java

示例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);
}
 
开发者ID:SonarQubeCommunity,项目名称:sonar-lua,代码行数:27,代码来源:LuaSquidSensorTest.java

示例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));

}
 
开发者ID:AmadeusITGroup,项目名称:sonar-coverage-evolution,代码行数:13,代码来源:CoverageRuleTest.java


注:本文中的org.sonar.api.batch.fs.internal.DefaultFileSystem.add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。