01: /**
02: * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
03: */package test.net.sourceforge.pmd.testframework;
04:
05: import java.util.Properties;
06:
07: import net.sourceforge.pmd.Rule;
08: import net.sourceforge.pmd.SourceType;
09:
10: /**
11: * Stores the information required to run a complete test.
12: */
13: public class TestDescriptor {
14: private Rule rule;
15: private Properties properties;
16: private String description;
17: private int numberOfProblemsExpected;
18: private String code;
19: private SourceType sourceType;
20: private boolean reinitializeRule = false; //default
21: private boolean isRegressionTest = true;
22:
23: public TestDescriptor(String code, String description,
24: int numberOfProblemsExpected, Rule rule) {
25: this (code, description, numberOfProblemsExpected, rule,
26: RuleTst.DEFAULT_SOURCE_TYPE);
27: }
28:
29: public TestDescriptor(String code, String description,
30: int numberOfProblemsExpected, Rule rule,
31: SourceType sourceType) {
32: this .rule = rule;
33: this .code = code;
34: this .description = description;
35: this .numberOfProblemsExpected = numberOfProblemsExpected;
36: this .sourceType = sourceType;
37: }
38:
39: public void setProperties(Properties properties) {
40: this .properties = properties;
41: }
42:
43: public Properties getProperties() {
44: return properties;
45: }
46:
47: public String getCode() {
48: return code;
49: }
50:
51: public SourceType getSourceType() {
52: return sourceType;
53: }
54:
55: public String getDescription() {
56: return description;
57: }
58:
59: public int getNumberOfProblemsExpected() {
60: return numberOfProblemsExpected;
61: }
62:
63: public Rule getRule() {
64: return rule;
65: }
66:
67: public boolean getReinitializeRule() {
68: return reinitializeRule;
69: }
70:
71: public void setReinitializeRule(boolean reinitializeRule) {
72: this .reinitializeRule = reinitializeRule;
73: }
74:
75: /**
76: * Checks whether we are testing for regression problems only.
77: * Return value is based on the system property "pmd.regress".
78: *
79: * @return <code>true</code> if system property "pmd.regress" is set to <code>true</code>, <code>false</code> otherwise
80: */
81: public static boolean inRegressionTestMode() {
82: //get the "pmd.regress" System property
83: return Boolean.getBoolean("pmd.regress");
84: }
85:
86: public boolean isRegressionTest() {
87: return isRegressionTest;
88: }
89:
90: public void setRegressionTest(boolean isRegressionTest) {
91: this.isRegressionTest = isRegressionTest;
92: }
93: }
|