1
2
3
4 package net.sourceforge.pmd.testframework;
5
6 import java.util.Properties;
7
8 import net.sourceforge.pmd.Rule;
9 import net.sourceforge.pmd.lang.LanguageVersion;
10
11 import org.junit.Ignore;
12
13
14
15
16 @Ignore("this is not a unit test")
17 public class TestDescriptor {
18 private Rule rule;
19 private Properties properties;
20 private String description;
21 private int numberOfProblemsExpected;
22 private String code;
23 private LanguageVersion languageVersion;
24 private boolean reinitializeRule = true;
25 private boolean isRegressionTest = true;
26
27
28 public TestDescriptor() {
29
30 }
31
32 public TestDescriptor(String code, String description, int numberOfProblemsExpected, Rule rule) {
33 this(code, description, numberOfProblemsExpected, rule, RuleTst.DEFAULT_LANGUAGE_VERSION);
34 }
35
36 public TestDescriptor(String code, String description, int numberOfProblemsExpected, Rule rule, LanguageVersion languageVersion) {
37 this.rule = rule;
38 this.code = code;
39 this.description = description;
40 this.numberOfProblemsExpected = numberOfProblemsExpected;
41 this.languageVersion = languageVersion;
42 }
43
44 public void setProperties(Properties properties) {
45 this.properties = properties;
46 }
47
48 public Properties getProperties() {
49 return properties;
50 }
51
52 public String getCode() {
53 return code;
54 }
55
56 public LanguageVersion getLanguageVersion() {
57 return languageVersion;
58 }
59
60 public String getDescription() {
61 return description;
62 }
63
64 public int getNumberOfProblemsExpected() {
65 return numberOfProblemsExpected;
66 }
67
68 public Rule getRule() {
69 return rule;
70 }
71
72 public boolean getReinitializeRule() {
73 return reinitializeRule;
74 }
75
76 public void setReinitializeRule(boolean reinitializeRule) {
77 this.reinitializeRule = reinitializeRule;
78 }
79
80
81
82
83
84
85
86 public static boolean inRegressionTestMode() {
87 boolean inRegressionMode = true;
88 try {
89
90 String property = System.getProperty("pmd.regress");
91 if (property != null) {
92 inRegressionMode = Boolean.parseBoolean(property);
93 }
94 } catch (IllegalArgumentException e) {
95 } catch (NullPointerException e) {
96 }
97
98 return inRegressionMode;
99 }
100
101 public boolean isRegressionTest() {
102 return isRegressionTest;
103 }
104
105 public void setRegressionTest(boolean isRegressionTest) {
106 this.isRegressionTest = isRegressionTest;
107 }
108 }