@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));
 }
예제 #3
0
  @Test
  public void overrideVersion() {
    MavenProject pom = MavenTestUtils.loadPom(getClass(), "overrideVersion.xml");
    MavenPlugin.registerPlugin(pom, "mygroup", "my.artifact", "1.0", true);

    MavenPlugin plugin = MavenPlugin.getPlugin(pom, "mygroup", "my.artifact");
    assertThat(plugin).isNotNull();
    assertThat(plugin.getPlugin().getVersion()).isEqualTo("1.0");
    assertThat(plugin.getParameter("foo")).isEqualTo("bar");
  }
예제 #4
0
  @Test
  public void mergeSettings() {
    MavenProject pom = MavenTestUtils.loadPom(getClass(), "mergeSettings.xml");
    MavenPlugin.registerPlugin(pom, "mygroup", "my.artifact", "1.0", false);

    MavenPlugin plugin = MavenPlugin.getPlugin(pom, "mygroup", "my.artifact");
    assertThat(plugin).isNotNull();
    assertThat(plugin.getPlugin().getVersion()).isEqualTo("0.9");
    assertThat(plugin.getParameter("foo")).isEqualTo("bar");
  }
예제 #5
0
  @Test
  public void registerNewPlugin() {
    MavenProject pom = MavenTestUtils.loadPom(getClass(), "registerNewPlugin.xml");
    MavenPlugin mavenPlugin =
        MavenPlugin.registerPlugin(pom, "mygroup", "my.artifact", "1.0", true);

    assertThat(mavenPlugin).isNotNull();
    Plugin plugin = MavenUtils.getPlugin(pom.getBuildPlugins(), "mygroup", "my.artifact");
    assertThat(plugin).isNotNull();
    assertThat(plugin.getVersion()).isEqualTo("1.0");
  }
예제 #6
0
  @Test
  public void keepPluginDependencies() {
    MavenProject pom = MavenTestUtils.loadPom(getClass(), "keepPluginDependencies.xml");
    MavenPlugin mavenPlugin =
        MavenPlugin.registerPlugin(pom, "mygroup", "my.artifact", "1.0", false);
    assertThat(mavenPlugin).isNotNull();

    Plugin plugin = MavenUtils.getPlugin(pom.getBuildPlugins(), "mygroup", "my.artifact");
    assertThat(plugin).isNotNull();
    assertThat(plugin.getVersion()).isEqualTo("0.9");
    assertThat(plugin.getDependencies().size()).isEqualTo(1);
  }
  @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/>"));
  }
예제 #8
0
  @Test
  public void getConfigurationFromReport() {
    MavenProject pom = MavenTestUtils.loadPom(getClass(), "getConfigurationFromReport.xml");
    MavenPlugin.registerPlugin(pom, "mygroup", "my.artifact", "1.0", true);

    assertThat(pom.getBuildPlugins().size()).isEqualTo(1);
    assertThat(pom.getReportPlugins().size()).isEqualTo(0);

    MavenPlugin plugin = MavenPlugin.getPlugin(pom, "mygroup", "my.artifact");
    assertThat(plugin).isNotNull();
    assertThat(plugin.getPlugin().getVersion()).isEqualTo("1.0");
    assertThat(plugin.getParameter("foo")).isEqualTo("bar");
  }
 /** 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"));
   }
 }
예제 #10
0
  @Test
  public void doNotOverrideVersionFromPluginManagementSection() {
    MavenProject pom = MavenTestUtils.loadPom(getClass(), "overridePluginManagementSection.xml");
    MavenPlugin mavenPlugin =
        MavenPlugin.registerPlugin(pom, "mygroup", "my.artifact", "1.0", false);
    assertThat(mavenPlugin).isNotNull();

    Plugin plugin = MavenUtils.getPlugin(pom.getBuildPlugins(), "mygroup", "my.artifact");
    assertThat(plugin).isNotNull();
    assertThat(plugin.getVersion()).isEqualTo("0.9");

    Plugin pluginManagement =
        MavenUtils.getPlugin(pom.getPluginManagement().getPlugins(), "mygroup", "my.artifact");
    assertThat(pluginManagement).isNull();
  }
  @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");
 }