Move test config from file to test class

Keep it simple. The config file stored only a single line for years.
This commit is contained in:
Stefan Birkner
2020-09-30 22:41:47 +02:00
parent 6e3bd734b8
commit 6b23b13497
3 changed files with 2 additions and 49 deletions

View File

@ -8,11 +8,8 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.fail;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import org.apache.commons.io.FileUtils;
@ -84,37 +81,8 @@ public class PMDCoverageTest {
}
}
/**
* Name of the configuration file used by testResourceFileCommands().
*/
private static final String PMD_CONFIG_FILE = "pmd_tests.conf";
/**
* Run PMD using the command lines found in PMD_CONFIG_FILE.
*/
@Test
public void testResourceFileCommands() {
InputStream is = getClass().getResourceAsStream(PMD_CONFIG_FILE);
if (is != null) {
try {
BufferedReader r = new BufferedReader(new InputStreamReader(is));
String l;
while ((l = r.readLine()) != null) {
l = l.trim();
if (l.length() == 0 || l.charAt(0) == '#') {
continue;
}
runPmd(l);
}
r.close();
} catch (IOException ioe) {
fail("Problem reading config file: " + ioe.getLocalizedMessage());
}
} else {
fail("Missing config file: " + PMD_CONFIG_FILE);
}
public void runAllJavaPmdOnSourceTree() {
runPmd("-d src/main/java -f text -R rulesets/internal/all-java.xml -language java");
}
}

View File

@ -1,5 +0,0 @@
#
# all-java on pmd source tree
# note: add "-debug" to see any parsing/processing exceptions
#
-d src/main/java -f text -R rulesets/internal/all-java.xml -language java

View File

@ -1,10 +0,0 @@
#
# all-java on pmd source tree
#
src text rulesets/internal/all-java.xml -version java 1.5
#
# jdk 1.6 source files
#
/usr/java/jdk1.6.0_06/src.zip text rulesets/internal/all-java.xml -version java 1.6