01: /**
02: * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
03: */package test.net.sourceforge.pmd.ant;
04:
05: import net.sourceforge.pmd.ant.Formatter;
06: import net.sourceforge.pmd.ant.PMDTask;
07: import net.sourceforge.pmd.ant.RuleSetWrapper;
08:
09: import org.apache.tools.ant.BuildException;
10: import org.junit.Ignore;
11: import org.junit.Test;
12:
13: public class PMDTaskTest {
14:
15: @Test(expected=BuildException.class)
16: public void testNoFormattersValidation() {
17: PMDTask task = new PMDTask();
18: task.execute();
19: }
20:
21: @Test(expected=BuildException.class)
22: public void testFormatterWithNoToFileAttribute() {
23: PMDTask task = new PMDTask();
24: task.addFormatter(new Formatter());
25: task.execute();
26: }
27:
28: @Test(expected=BuildException.class)
29: public void testNoRuleSets() {
30: PMDTask task = new PMDTask();
31: task.execute();
32: }
33:
34: @Ignore("This test has a TODO in it")
35: @Test
36: public void testNestedRuleset() {
37: PMDTask task = new PMDTask();
38: RuleSetWrapper r = new RuleSetWrapper();
39: r.addText("rulesets/basic.xml");
40: task.addRuleset(r);
41: r.addText("rulesets/design.xml");
42: task.addRuleset(r);
43: Formatter f = new Formatter();
44: task.addFormatter(f);
45:
46: //TODO
47: try {
48: task.execute();
49: } catch (BuildException be) {
50: //fail(be.toString());
51: }
52: }
53:
54: @Test(expected=BuildException.class)
55: public void testInvalidJDK() {
56: PMDTask task = new PMDTask();
57: task.setTargetJDK("1.7");
58: task.execute();
59: }
60:
61: public static junit.framework.Test suite() {
62: return new junit.framework.JUnit4TestAdapter(PMDTaskTest.class);
63: }
64: }
|