From 1de9f7cd49d25ab9ec3137a4fce6123f6bc5072d Mon Sep 17 00:00:00 2001 From: Romain PELISSE Date: Wed, 14 Nov 2012 21:29:43 +0100 Subject: [PATCH] pmd: Reindent and whitespaces --- .../pmd/coverage/PMDCoverageTest.java | 152 +++++++++--------- 1 file changed, 80 insertions(+), 72 deletions(-) diff --git a/pmd/src/test/java/net/sourceforge/pmd/coverage/PMDCoverageTest.java b/pmd/src/test/java/net/sourceforge/pmd/coverage/PMDCoverageTest.java index 05f2c76af5..960359257c 100644 --- a/pmd/src/test/java/net/sourceforge/pmd/coverage/PMDCoverageTest.java +++ b/pmd/src/test/java/net/sourceforge/pmd/coverage/PMDCoverageTest.java @@ -7,88 +7,96 @@ import static org.junit.Assert.fail; import java.io.BufferedReader; import java.io.File; +import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; +import java.io.PrintStream; import net.sourceforge.pmd.PMD; +import org.junit.Ignore; import org.junit.Test; + + public class PMDCoverageTest { - /** - * Test some of the PMD command line options - */ - @Test - public void testPmdOptions() { - runPmd("src/main/java/net/sourceforge/pmd/lang/java/rule/design text rulesets/internal/all-java.xml -version java 1.5 -stress -benchmark"); - } - - /** - * Run the PMD command line tool, i.e. call PMD.main(). - * - * @param commandLine - */ - private void runPmd(String commandLine) { - String[] args; - args = commandLine.split("\\s"); - - File f = null; - try { - f = File.createTempFile("pmd", ".txt"); - int n = args.length; - String[] a = new String[n + 2]; - System.arraycopy(args, 0, a, 0, n); - a[n] = "-reportfile"; - a[n + 1] = f.getAbsolutePath(); - args = a; - - PMD.run(args); - - // FIXME: check that output doesn't have parsing errors - } catch (IOException ioe) { - fail("Problem creating temporary file: " + ioe.getLocalizedMessage()); - } finally { - if (f != null) f.delete(); - } - } - - /** - * 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); + /** + * Test some of the PMD command line options + */ + @Test + public void testPmdOptions() { + runPmd("src/main/java/net/sourceforge/pmd/lang/java/rule/design text rulesets/internal/all-java.xml -version java 1.5 -stress -benchmark"); } - } - public static junit.framework.Test suite() { - return new junit.framework.JUnit4TestAdapter(PMDCoverageTest.class); - } + /** + * Run the PMD command line tool, i.e. call PMD.main(). + * + * @param commandLine + */ + private void runPmd(String commandLine) { + String[] args; + args = commandLine.split("\\s"); + + File f = null; + try { + f = File.createTempFile("pmd", ".txt"); + int n = args.length; + String[] a = new String[n + 2]; + System.arraycopy(args, 0, a, 0, n); + a[n] = "-reportfile"; + a[n + 1] = f.getAbsolutePath(); + args = a; + + File file = new File("/dev/null"); + PrintStream printStream = new PrintStream(new FileOutputStream(file)); + System.setOut(printStream); + PMD.run(args); + + // FIXME: check that output doesn't have parsing errors + } catch (IOException ioe) { + fail("Problem creating temporary file: " + ioe.getLocalizedMessage()); + } finally { + if (f != null) f.delete(); + } + } + + /** + * 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 static junit.framework.Test suite() { + return new junit.framework.JUnit4TestAdapter(PMDCoverageTest.class); + } }