예제 #1
0
  @Test
  public void should_ignore_PMD_error() throws PMDException, FileNotFoundException {
    when(inputFile.getFile()).thenReturn(new File("source.java"));
    when(inputFile.getInputStream()).thenReturn(inputStream);
    doThrow(new PMDException("BUG"))
        .when(pmd)
        .processFile(inputStream, Charsets.UTF_8.displayName(), rulesets, ruleContext);

    new PmdTemplate(pmd).process(inputFile, Charsets.UTF_8, rulesets, ruleContext);
  }
예제 #2
0
  @Test
  public void should_process_input_file() throws PMDException, FileNotFoundException {
    when(inputFile.getFile()).thenReturn(new File("source.java"));
    when(inputFile.getInputStream()).thenReturn(inputStream);

    new PmdTemplate(pmd).process(inputFile, Charsets.UTF_8, rulesets, ruleContext);

    verify(ruleContext).setSourceCodeFilename(new File("source.java").getAbsolutePath());
    verify(pmd).processFile(inputStream, Charsets.UTF_8.displayName(), rulesets, ruleContext);
  }