use of org.sonar.api.batch.fs.internal.DefaultFileSystem in project sonarqube by SonarSource.
the class JavaCpdBlockIndexerTest method setUp.
@Before
public void setUp() throws IOException {
MockitoAnnotations.initMocks(this);
File baseDir = temp.newFolder();
DefaultFileSystem fs = new DefaultFileSystem(baseDir);
file = new TestInputFileBuilder("foo", "src/ManyStatements.java").setModuleBaseDir(baseDir.toPath()).setLanguage(JAVA).build();
fs.add(file);
File ioFile = file.file();
FileUtils.copyURLToFile(this.getClass().getResource("ManyStatements.java"), ioFile);
settings = new MapSettings();
engine = new JavaCpdBlockIndexer(fs, settings, index);
}
use of org.sonar.api.batch.fs.internal.DefaultFileSystem in project sonarqube by SonarSource.
the class DefaultSensorContextTest method prepare.
@Before
public void prepare() throws Exception {
activeRules = new ActiveRulesBuilder().build();
fs = new DefaultFileSystem(temp.newFolder().toPath());
MetricFinder metricFinder = mock(MetricFinder.class);
when(metricFinder.<Integer>findByKey(CoreMetrics.NCLOC_KEY)).thenReturn(CoreMetrics.NCLOC);
when(metricFinder.<String>findByKey(CoreMetrics.FUNCTION_COMPLEXITY_DISTRIBUTION_KEY)).thenReturn(CoreMetrics.FUNCTION_COMPLEXITY_DISTRIBUTION);
settings = new MapSettings();
sensorStorage = mock(SensorStorage.class);
analysisMode = mock(AnalysisMode.class);
runtime = SonarRuntimeImpl.forSonarQube(Version.parse("5.5"), SonarQubeSide.SCANNER);
adaptor = new DefaultSensorContext(mock(InputModule.class), settings, fs, activeRules, analysisMode, sensorStorage, runtime);
}
use of org.sonar.api.batch.fs.internal.DefaultFileSystem in project sonar-java by SonarSource.
the class JavaTestClasspathTest method empty_libraries_if_only_main_files.
@Test
public void empty_libraries_if_only_main_files() throws Exception {
fs = new DefaultFileSystem(new File("src/test/files/classpath/"));
TestInputFileBuilder inputFile = new TestInputFileBuilder("", "plop.java");
inputFile.setType(InputFile.Type.MAIN);
inputFile.setLanguage("java");
fs.add(inputFile.build());
javaTestClasspath = createJavaClasspath();
assertThat(javaTestClasspath.getElements()).isEmpty();
}
use of org.sonar.api.batch.fs.internal.DefaultFileSystem in project sonar-java by SonarSource.
the class JavaTestClasspathTest method setUp.
@Before
public void setUp() throws Exception {
fs = new DefaultFileSystem(new File("src/test/files/classpath/"));
TestInputFileBuilder inputFile = new TestInputFileBuilder("", "foo.java");
inputFile.setLanguage("java");
inputFile.setType(InputFile.Type.TEST);
fs.add(inputFile.build());
settings = new MapSettings();
}
use of org.sonar.api.batch.fs.internal.DefaultFileSystem in project sonar-java by SonarSource.
the class JavaTestClasspathTest method no_interaction_with_FileSystem_at_initialization.
/**
* See SONARJAVA-1764
* The fileSystem should not be used in initialization phase, as it will fail the analysis if other plugins are used.
* Accessing the filesystem before the Sensor phase is not supported by SonarQube.
*/
@Test
public void no_interaction_with_FileSystem_at_initialization() {
fs = Mockito.spy(new DefaultFileSystem(new File("src/test/files/classpath/")));
javaTestClasspath = new JavaTestClasspath(settings.asConfig(), fs);
Mockito.verifyZeroInteractions(fs);
}
Aggregations