aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/sonar-pmd-plugin/src
diff options
context:
space:
mode:
authorfmallet <freddy.mallet@gmail.com>2010-09-16 08:47:47 +0000
committerfmallet <freddy.mallet@gmail.com>2010-09-16 08:47:47 +0000
commitaf671ec593977add8ea924b4f9f88302bd0ef81c (patch)
tree9bcfb15239ec4c28e0daf9bde50bbd75b49f99c1 /plugins/sonar-pmd-plugin/src
parentf27104c1d98ac616ba1c91c3cfe96e0e495b725a (diff)
downloadsonarqube-af671ec593977add8ea924b4f9f88302bd0ef81c.tar.gz
sonarqube-af671ec593977add8ea924b4f9f88302bd0ef81c.zip
Prevent Unit Tests from generating report file outside of the /target directory
Diffstat (limited to 'plugins/sonar-pmd-plugin/src')
-rw-r--r--plugins/sonar-pmd-plugin/src/test/java/org/sonar/plugins/pmd/PmdExecutorTest.java2
-rw-r--r--plugins/sonar-pmd-plugin/src/test/java/org/sonar/plugins/pmd/PmdProfileExporterTest.java5
2 files changed, 4 insertions, 3 deletions
diff --git a/plugins/sonar-pmd-plugin/src/test/java/org/sonar/plugins/pmd/PmdExecutorTest.java b/plugins/sonar-pmd-plugin/src/test/java/org/sonar/plugins/pmd/PmdExecutorTest.java
index 64343d7d97f..eabaddb6abb 100644
--- a/plugins/sonar-pmd-plugin/src/test/java/org/sonar/plugins/pmd/PmdExecutorTest.java
+++ b/plugins/sonar-pmd-plugin/src/test/java/org/sonar/plugins/pmd/PmdExecutorTest.java
@@ -50,6 +50,7 @@ public class PmdExecutorTest {
File root = new File(getClass().getResource("/org/sonar/plugins/pmd/PmdExecutorTest/executeOnManySourceDirs/").toURI());
when(fs.getSourceFiles(Java.INSTANCE)).thenReturn(Arrays.asList(new File(root, "src1/FirstClass.java"), new File(root, "src2/SecondClass.java")));
when(fs.getSourceCharset()).thenReturn(Charset.forName("UTF-8"));
+ when(fs.getSonarWorkingDirectory()).thenReturn(new File("target"));
project.setFileSystem(fs);
PmdConfiguration conf = mock(PmdConfiguration.class);
@@ -74,6 +75,7 @@ public class PmdExecutorTest {
ProjectFileSystem fs = mock(ProjectFileSystem.class);
when(fs.getSourceFiles(Java.INSTANCE)).thenReturn(Arrays.asList(new File("test-resources/ignorePmdFailures/DoesNotCompile.java")));
when(fs.getSourceCharset()).thenReturn(Charset.forName("UTF-8"));
+ when(fs.getSonarWorkingDirectory()).thenReturn(new File("target"));
project.setFileSystem(fs);
PmdConfiguration conf = mock(PmdConfiguration.class);
diff --git a/plugins/sonar-pmd-plugin/src/test/java/org/sonar/plugins/pmd/PmdProfileExporterTest.java b/plugins/sonar-pmd-plugin/src/test/java/org/sonar/plugins/pmd/PmdProfileExporterTest.java
index 594c4cbc75f..d6189e13196 100644
--- a/plugins/sonar-pmd-plugin/src/test/java/org/sonar/plugins/pmd/PmdProfileExporterTest.java
+++ b/plugins/sonar-pmd-plugin/src/test/java/org/sonar/plugins/pmd/PmdProfileExporterTest.java
@@ -27,8 +27,6 @@ import org.sonar.plugins.pmd.xml.PmdRule;
import org.sonar.test.TestUtils;
import org.xml.sax.SAXException;
-import com.thoughtworks.xstream.io.xml.JDomReader;
-
public class PmdProfileExporterTest {
private PmdProfileExporter exporter = new PmdProfileExporter();
@@ -61,7 +59,8 @@ public class PmdProfileExporterTest {
xpath.setParameter(PmdConstants.XPATH_EXPRESSION_PARAM, "//FieldDeclaration");
xpath.setParameter(PmdConstants.XPATH_MESSAGE_PARAM, "This is bad");
exporter.exportProfile(profile, xmlOutput);
- assertEquals(TestUtils.getResourceContent("/org/sonar/plugins/pmd/export_xpath_rules.xml"), StringUtils.remove(xmlOutput.toString(), '\r'));
+ assertEquals(TestUtils.getResourceContent("/org/sonar/plugins/pmd/export_xpath_rules.xml"),
+ StringUtils.remove(xmlOutput.toString(), '\r'));
}
@Test