use of org.sonar.api.batch.fs.internal.DefaultFileSystem in project sonar-java by SonarSource.
the class ClasspathForTestTest method empty_libraries_if_only_main_files.
@Test
void empty_libraries_if_only_main_files() throws Exception {
fs = new DefaultFileSystem(new File("src/test/files/classpath/"));
fs.add(TestUtils.emptyInputFile("plop.java"));
javaTestClasspath = createJavaClasspath();
assertThat(javaTestClasspath.getElements()).isEmpty();
}
use of org.sonar.api.batch.fs.internal.DefaultFileSystem in project sonar-java by SonarSource.
the class GeneratedFileTest method setUp.
@BeforeEach
public void setUp() throws Exception {
expected = tmp.resolve("file.jsp");
Files.write(expected, "content".getBytes(StandardCharsets.UTF_8));
fs = new DefaultFileSystem(tmp);
actual = new GeneratedFile(expected);
}
use of org.sonar.api.batch.fs.internal.DefaultFileSystem in project sonar-java by SonarSource.
the class SmapFileTest method test.
@Test
void test() throws Exception {
String sourceMap = "SMAP\n" + "test_jsp.java\n" + "JSP\n" + "*S JSP\n" + "*F\n" + "+ 0 test.jsp\n" + "WEB-INF/test.jsp\n" + "2 Incl.xyz\n" + "*L\n" + "1,5:116,0\n" + "123:207\n" + "130,3:210\n" + "140:250,7\n" + "160,3:300,2\n" + "160#2,3:300,2\n" + "160,3:300,2\n" + "*E\n";
DefaultFileSystem fs = new DefaultFileSystem(temporaryFolder);
DefaultInputFile inputFile = TestInputFileBuilder.create("module", temporaryFolder.toFile(), temporaryFolder.resolve("WEB-INF/test.jsp").toFile()).build();
fs.add(inputFile);
SmapFile smap = new SmapFile(temporaryFolder, sourceMap, temporaryFolder, fs);
assertThat(smap.getGeneratedFile()).isEqualTo(temporaryFolder.resolve("test_jsp.java"));
assertThat(smap.getFileSection()).containsExactly(entry(0, new SmapFile.FileInfo(0, "test.jsp", "WEB-INF/test.jsp", null)), entry(2, new SmapFile.FileInfo(2, "Incl.xyz", null, null)));
assertThat(smap.getLineSection()).containsExactly(new SmapFile.LineInfo(1, 0, 5, 116, 0), new SmapFile.LineInfo(123, 0, 1, 207, 1), new SmapFile.LineInfo(130, 0, 3, 210, 1), new SmapFile.LineInfo(140, 0, 1, 250, 7), new SmapFile.LineInfo(160, 0, 3, 300, 2), new SmapFile.LineInfo(160, 2, 3, 300, 2), new SmapFile.LineInfo(160, 2, 3, 300, 2));
}
use of org.sonar.api.batch.fs.internal.DefaultFileSystem in project sonar-java by SonarSource.
the class SurefireUtilsTest method return_default_value_if_property_unset.
@Test
void return_default_value_if_property_unset() throws Exception {
MapSettings settings = new MapSettings();
DefaultFileSystem fs = new DefaultFileSystem(new File("src/test/resources/org/sonar/plugins/surefire/api/SurefireUtilsTest"));
PathResolver pathResolver = new PathResolver();
assertThat(logTester.logs(LoggerLevel.INFO)).isEmpty();
List<File> directories = SurefireUtils.getReportsDirectories(settings.asConfig(), fs, pathResolver);
assertThat(directories).hasSize(1);
File directory = directories.get(0);
assertThat(directory.getCanonicalPath()).endsWith("target" + File.separator + "surefire-reports");
assertThat(directory).doesNotExist();
assertThat(directory.isDirectory()).isFalse();
assertThat(logTester.logs(LoggerLevel.INFO)).isEmpty();
}
use of org.sonar.api.batch.fs.internal.DefaultFileSystem in project sonar-java by SonarSource.
the class SurefireUtilsTest method should_get_report_paths_from_property.
@Test
void should_get_report_paths_from_property() {
MapSettings settings = new MapSettings();
settings.setProperty("sonar.junit.reportPaths", "target/surefire,submodule/target/surefire");
DefaultFileSystem fs = new DefaultFileSystem(new File("src/test/resources/org/sonar/plugins/surefire/api/SurefireUtilsTest/shouldGetReportsPathFromProperty"));
PathResolver pathResolver = new PathResolver();
assertThat(logTester.logs(LoggerLevel.INFO)).isEmpty();
List<File> directories = SurefireUtils.getReportsDirectories(settings.asConfig(), fs, pathResolver);
assertThat(directories).hasSize(2);
File directory1 = directories.get(0);
assertThat(directory1).exists().isDirectory();
File directory2 = directories.get(1);
assertThat(directory2).exists().isDirectory();
assertThat(logTester.logs(LoggerLevel.INFO)).isEmpty();
}
Aggregations