@Test public void getJapaneseCharSet() { project = MavenTestUtils.loadProjectFromPom( DefaultProjectFileSystemTest.class, "japanese-project/pom.xml"); DefaultProjectFileSystem fs = newDefaultProjectFileSystem(project); assertThat(fs.getSourceCharset().name(), is("Shift_JIS")); }
/** See http://jira.codehaus.org/browse/SONAR-2266 */ @Test public void shouldReturnOnlyExistingSourceAndTestDirectories() { // in this example : "src/main/java" is a file, "src/test/java" doesn't exists project = MavenTestUtils.loadProjectFromPom( DefaultProjectFileSystemTest.class, "nonexistent-dirs/pom.xml"); DefaultProjectFileSystem fs = newDefaultProjectFileSystem(project); assertThat(fs.getSourceDirs().size(), is(0)); assertThat(fs.getTestDirs().size(), is(0)); }
@Test public void writeConfigurationToWorkingDir() throws IOException { Project project = MavenTestUtils.loadProjectFromPom(getClass(), "writeConfigurationToWorkingDir/pom.xml"); CheckstyleProfileExporter exporter = new FakeExporter(); CheckstyleConfiguration configuration = new CheckstyleConfiguration(null, exporter, null, project.getFileSystem()); File xmlFile = configuration.getXMLDefinitionFile(); assertThat(xmlFile.exists(), is(true)); assertThat(FileUtils.readFileToString(xmlFile), is("<conf/>")); }
/** Example of hidden files/directories : .DSStore, .svn, .git */ @Test public void hiddenFilesAreIgnored() { if (!SystemUtils.IS_OS_WINDOWS) { // hidden files/directories can not be stored in svn windows // On Mac/Linux it's easy, just prefix the filename by '.' project = MavenTestUtils.loadProjectFromPom( DefaultProjectFileSystemTest.class, "hidden-files/pom.xml"); ProjectFileSystem fs = newDefaultProjectFileSystem(project); List<File> files = fs.getSourceFiles(); assertThat(files.size(), is(1)); assertThat(files.get(0).getName(), is("foo.sql")); } }
@Test public void languageWithNoSpecificFileSuffixes() { class NoSuffixLanguage implements Language { public String getKey() { return "no-suffix"; } public String getName() { return "no-suffix"; } public String[] getFileSuffixes() { return new String[0]; } } project = MavenTestUtils.loadProjectFromPom( DefaultProjectFileSystemTest.class, "sample-with-different-suffixes/pom.xml"); ProjectFileSystem fs = newDefaultProjectFileSystem(project); List<File> files = fs.getSourceFiles(new NoSuffixLanguage()); assertThat(files.size(), is(2)); }
@Before public void before() { project = MavenTestUtils.loadProjectFromPom(DefaultProjectFileSystemTest.class, "sample/pom.xml"); }