コード例 #1
0
  @Test
  public void getTestFiles() {
    final DefaultProjectFileSystem fs = newDefaultProjectFileSystem(project);

    assertThat(fs.getTestFiles(Java.INSTANCE).size(), is(1));
    assertThat(fs.getTestFiles(Java.INSTANCE), hasItem(named("BarTest.java")));
  }
コード例 #2
0
 @Test
 public void createSonarWorkingDirectory() {
   DefaultProjectFileSystem fs = newDefaultProjectFileSystem(project);
   java.io.File dir = fs.getSonarWorkingDirectory();
   assertThat(dir.exists(), is(true));
   assertThat(dir.listFiles().length, is(0));
 }
コード例 #3
0
  @Test
  public void getJavaSourceFiles() {
    final DefaultProjectFileSystem fs = newDefaultProjectFileSystem(project);

    assertThat(fs.getJavaSourceFiles().size(), is(2));
    assertThat(fs.getJavaSourceFiles(), hasItem(named("Bar.java")));
    assertThat(fs.getJavaSourceFiles(), hasItem(named("Whizz.java")));
  }
コード例 #4
0
 @Test
 public void getJapaneseCharSet() {
   project =
       MavenTestUtils.loadProjectFromPom(
           DefaultProjectFileSystemTest.class, "japanese-project/pom.xml");
   DefaultProjectFileSystem fs = newDefaultProjectFileSystem(project);
   assertThat(fs.getSourceCharset().name(), is("Shift_JIS"));
 }
コード例 #5
0
  @Test
  public void hasJavaSourceFiles() {
    final DefaultProjectFileSystem fs = newDefaultProjectFileSystem(project);
    assertThat(fs.hasJavaSourceFiles(), is(true));

    PropertiesConfiguration conf = new PropertiesConfiguration();
    conf.setProperty(CoreProperties.PROJECT_EXCLUSIONS_PROPERTY, "**/*.java");
    project.setConfiguration(conf);
    assertThat(fs.hasJavaSourceFiles(), is(false));
  }
コード例 #6
0
 /** 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));
 }
コード例 #7
0
  /** See http://jira.codehaus.org/browse/SONAR-2280 */
  @Test
  public void resolvePathShouldReturnCanonicalFile() {
    MavenProject pom = mock(MavenProject.class);
    when(pom.getBasedir()).thenReturn(new File("/project"));
    Project project = new Project("foo").setPom(pom);
    DefaultProjectFileSystem fs = new DefaultProjectFileSystem(project, null);

    assertThat(fs.resolvePath(".").getAbsolutePath(), endsWith("project"));
    assertThat(fs.resolvePath("../project").getAbsolutePath(), endsWith("project"));
  }
コード例 #8
0
  @Test
  public void applyExclusionPatternsToSourceFiles() {
    PropertiesConfiguration conf = new PropertiesConfiguration();
    conf.setProperty(CoreProperties.PROJECT_EXCLUSIONS_PROPERTY, "**/B*.java");
    project.setConfiguration(conf);

    final DefaultProjectFileSystem fs = newDefaultProjectFileSystem(project);

    assertThat(fs.getJavaSourceFiles().size(), is(1));
    assertThat(fs.getJavaSourceFiles(), hasItem(named("Whizz.java")));
  }
コード例 #9
0
  @Test
  public void doNotApplyExclusionPatternsToTestFiles() {
    PropertiesConfiguration conf = new PropertiesConfiguration();
    conf.setProperty(CoreProperties.PROJECT_EXCLUSIONS_PROPERTY, "**/B*.java");
    project.setConfiguration(conf);

    final DefaultProjectFileSystem fs = newDefaultProjectFileSystem(project);

    assertThat(fs.getTestFiles(Java.INSTANCE).size(), is(1));
    assertThat(fs.getTestFiles(Java.INSTANCE), hasItem(named("BarTest.java")));
  }
コード例 #10
0
  /** See http://jira.codehaus.org/browse/SONAR-1449 */
  @Test
  public void exclusionPatternOnAjFiles() {
    PropertiesConfiguration conf = new PropertiesConfiguration();
    conf.setProperty(CoreProperties.PROJECT_EXCLUSIONS_PROPERTY, "**/*.aj");
    project.setConfiguration(conf);

    final DefaultProjectFileSystem fs = newDefaultProjectFileSystem(project);

    assertThat(fs.getSourceFiles(Java.INSTANCE).size(), is(2));
    assertThat(fs.getSourceFiles(Java.INSTANCE), hasItem(named("Whizz.java")));
    assertThat(fs.getSourceFiles(Java.INSTANCE), hasItem(named("Bar.java")));
  }
コード例 #11
0
  @Test
  public void shouldUseExtendedFilters() {
    DefaultProjectFileSystem fsWithoutFilter = newDefaultProjectFileSystem(project);
    assertThat(fsWithoutFilter.getSourceFiles().size(), is(2));
    assertThat(fsWithoutFilter.getSourceFiles(), hasItem(named("Bar.java")));

    FileFilter filter =
        new FileFilter() {
          public boolean accept(File file) {
            return !StringUtils.equals(file.getName(), "Bar.java");
          }
        };
    DefaultProjectFileSystem fsWithFilter =
        new DefaultProjectFileSystem(project, new Languages(Java.INSTANCE), filter);
    assertThat(fsWithFilter.getSourceFiles().size(), is(1));
    assertThat(fsWithFilter.getSourceFiles(), not(hasItem(named("Bar.java"))));
  }