Several folks (most recently, Wouter Zelle) have written XSLT scripts
which you can use to transform the XML report into nifty HTML. To do this,
diff --git a/pmd/src/test/java/net/sourceforge/pmd/LanguageVersionTest.java b/pmd/src/test/java/net/sourceforge/pmd/LanguageVersionTest.java
index 7015842469..2316bda20d 100644
--- a/pmd/src/test/java/net/sourceforge/pmd/LanguageVersionTest.java
+++ b/pmd/src/test/java/net/sourceforge/pmd/LanguageVersionTest.java
@@ -6,6 +6,7 @@ import java.util.Arrays;
import java.util.Collection;
import junit.framework.JUnit4TestAdapter;
+import net.sourceforge.pmd.ant.SourceLanguage;
import net.sourceforge.pmd.lang.LanguageVersion;
import org.junit.Test;
@@ -16,20 +17,41 @@ import org.junit.runners.Parameterized.Parameters;
@RunWith(Parameterized.class)
public class LanguageVersionTest {
+ private String language;
+ private String version;
private String terseName;
private LanguageVersion expected;
- public LanguageVersionTest(String terseName, LanguageVersion expected) {
- this.terseName = terseName;
+ public LanguageVersionTest(String language, String version, LanguageVersion expected) {
+ this.language = language;
+ this.version = version;
+ this.terseName = language;
+ if (version != null && !version.isEmpty()) {
+ this.terseName += " " + version;
+ }
this.expected = expected;
}
@Parameters
public static Collection data() {
- return Arrays.asList(new Object[][] { { "java 1.3", LanguageVersion.JAVA_13 },
- { "java 1.4", LanguageVersion.JAVA_14 }, { "java 1.5", LanguageVersion.JAVA_15 },
- { "java 1.6", LanguageVersion.JAVA_16 }, { "java 1.7", LanguageVersion.JAVA_17 },
- { "jsp", LanguageVersion.JSP }, });
+ return Arrays.asList(new Object[][] {
+ { "java", "1.3", LanguageVersion.JAVA_13 },
+ { "java", "1.4", LanguageVersion.JAVA_14 },
+ { "java", "1.5", LanguageVersion.JAVA_15 },
+ { "java", "1.6", LanguageVersion.JAVA_16 },
+ { "java", "1.7", LanguageVersion.JAVA_17 },
+ { "jsp", "", LanguageVersion.JSP },
+ { "xml", "", LanguageVersion.XML },
+ { "xsl", "", LanguageVersion.XSL },
+ { "ecmascript", "3", LanguageVersion.ECMASCRIPT },
+ { "cpp", "", LanguageVersion.CPP },
+ { "fortran", "", LanguageVersion.FORTRAN },
+ { "php", "", LanguageVersion.PHP },
+ { "ruby", "", LanguageVersion.RUBY },
+
+ // this one won't be found: case sensitive!
+ { "JAVA", "1.7", null },
+ });
}
@Test
@@ -37,6 +59,18 @@ public class LanguageVersionTest {
assertEquals(expected, LanguageVersion.findByTerseName(terseName));
}
+ @Test
+ public void testFindVersionsForLanguageTerseName() {
+ SourceLanguage sourceLanguage = new SourceLanguage();
+ sourceLanguage.setName(language);
+ sourceLanguage.setVersion(version);
+
+ LanguageVersion languageVersion = LanguageVersion.findVersionsForLanguageTerseName(sourceLanguage.getName(),
+ sourceLanguage.getVersion());
+
+ assertEquals(expected, languageVersion);
+ }
+
public static junit.framework.Test suite() {
return new JUnit4TestAdapter(LanguageVersionTest.class);
}
diff --git a/pmd/src/test/java/net/sourceforge/pmd/ant/PMDTaskTest.java b/pmd/src/test/java/net/sourceforge/pmd/ant/PMDTaskTest.java
index 26f01c7b19..134652e19c 100644
--- a/pmd/src/test/java/net/sourceforge/pmd/ant/PMDTaskTest.java
+++ b/pmd/src/test/java/net/sourceforge/pmd/ant/PMDTaskTest.java
@@ -111,6 +111,12 @@ public class PMDTaskTest extends BuildFileTest {
assertOutputContaining("Use ===/!== to compare with true/false or Numbers");
}
+ @Test
+ public void testXML() {
+ executeTarget("testXML");
+ assertOutputContaining("Potentialy mistyped CDATA section with extra [ at beginning or ] at the end.");
+ }
+
@Test
public void testClasspath() {
executeTarget("testClasspath");
diff --git a/pmd/src/test/resources/ant/xml/mistypedcdata.xml b/pmd/src/test/resources/ant/xml/mistypedcdata.xml
new file mode 100644
index 0000000000..62c287cc98
--- /dev/null
+++ b/pmd/src/test/resources/ant/xml/mistypedcdata.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
diff --git a/pmd/src/test/resources/net/sourceforge/pmd/ant/xml/pmdtasktest.xml b/pmd/src/test/resources/net/sourceforge/pmd/ant/xml/pmdtasktest.xml
index d8c9a58848..bf4dafa0a1 100644
--- a/pmd/src/test/resources/net/sourceforge/pmd/ant/xml/pmdtasktest.xml
+++ b/pmd/src/test/resources/net/sourceforge/pmd/ant/xml/pmdtasktest.xml
@@ -128,6 +128,16 @@