diff --git a/pmd/regress/test/net/sourceforge/pmd/properties/NonRuleWithAllPropertyTypes.java b/pmd/regress/test/net/sourceforge/pmd/properties/NonRuleWithAllPropertyTypes.java index 94086197c2..5b8319ce70 100644 --- a/pmd/regress/test/net/sourceforge/pmd/properties/NonRuleWithAllPropertyTypes.java +++ b/pmd/regress/test/net/sourceforge/pmd/properties/NonRuleWithAllPropertyTypes.java @@ -14,25 +14,26 @@ import net.sourceforge.pmd.properties.TypeProperty; class NonRuleWithAllPropertyTypes extends AbstractRule { - private static final PropertyDescriptor singleStr = new StringProperty("singleStr", "Property with a single string value", "hello world" , 3.0f); - private static final PropertyDescriptor multiStr = new StringProperty("multiStr", "Property with multiple string values", new String[] {"hello", "world"}, 5.0f, '|'); + // descriptors are public to enable us to write external tests + public static final PropertyDescriptor singleStr = new StringProperty("singleStr", "Property with a single string value", "hello world" , 3.0f); + public static final PropertyDescriptor multiStr = new StringProperty("multiStr", "Property with multiple string values", new String[] {"hello", "world"}, 5.0f, '|'); - private static final PropertyDescriptor singleInt = new IntegerProperty("singleInt", "Property with a single integer value", 8 , 3.0f); - private static final PropertyDescriptor multiInt = new IntegerProperty("multiInt", "Property with multiple integer values", new int[] {1,2,3,4}, 5.0f, 5); + public static final PropertyDescriptor singleInt = new IntegerProperty("singleInt", "Property with a single integer value", 8 , 3.0f); + public static final PropertyDescriptor multiInt = new IntegerProperty("multiInt", "Property with multiple integer values", new int[] {1,2,3,4}, 5.0f, 5); - private static final PropertyDescriptor singleBool = new BooleanProperty("singleBool", "Property with a single boolean value", true, 6.0f); - private static final PropertyDescriptor multiBool = new BooleanProperty("multiBool", "Property with multiple boolean values", new boolean[] { true, false}, 5.0f, 2); + public static final PropertyDescriptor singleBool = new BooleanProperty("singleBool", "Property with a single boolean value", true, 6.0f); + public static final PropertyDescriptor multiBool = new BooleanProperty("multiBool", "Property with multiple boolean values", new boolean[] { true, false}, 5.0f, 2); - private static final PropertyDescriptor singleChar = new CharacterProperty("singleChar", "Property with a single character value", 'a', 5.0f); - private static final PropertyDescriptor multiChar = new CharacterProperty("multiChar", "Property with multiple character values", new char[] {'a', 'e', 'i', 'o', 'u'}, 6.0f, '|'); + public static final PropertyDescriptor singleChar = new CharacterProperty("singleChar", "Property with a single character value", 'a', 5.0f); + public static final PropertyDescriptor multiChar = new CharacterProperty("multiChar", "Property with multiple character values", new char[] {'a', 'e', 'i', 'o', 'u'}, 6.0f, '|'); - private static final PropertyDescriptor singleFloat = new FloatProperty("singleFloat", "Property with a single float value", 9.9f, 5.0f); - private static final PropertyDescriptor multiFloat = new FloatProperty("multiFloat", "Property with multiple float values", new float[] {1,2,3}, 6.0f, 3); + public static final PropertyDescriptor singleFloat = new FloatProperty("singleFloat", "Property with a single float value", 9.9f, 5.0f); + public static final PropertyDescriptor multiFloat = new FloatProperty("multiFloat", "Property with multiple float values", new float[] {1,2,3}, 6.0f, 3); - private static final PropertyDescriptor singleType = new TypeProperty("singleType", "Property with a single type value", String.class, 5.0f); - private static final PropertyDescriptor multiType = new TypeProperty("multiType", "Property with multiple type values", new Class[] {Integer.class, Object.class}, 6.0f); + public static final PropertyDescriptor singleType = new TypeProperty("singleType", "Property with a single type value", String.class, 5.0f); + public static final PropertyDescriptor multiType = new TypeProperty("multiType", "Property with multiple type values", new Class[] {Integer.class, Object.class}, 6.0f); - private static final PropertyDescriptor enumType = new EnumeratedProperty("enumType", "Property with a enumerated choices", new Object[][] {{"String", String.class},{"Object", Object.class}}, 5.0f); + public static final PropertyDescriptor enumType = new EnumeratedProperty("enumType", "Property with a enumerated choices", new Object[][] {{"String", String.class},{"Object", Object.class}}, 5.0f); private static final Map propertyDescriptorsByName = asFixedMap(new PropertyDescriptor[] { diff --git a/pmd/regress/test/net/sourceforge/pmd/properties/PropertyAccessorTest.java b/pmd/regress/test/net/sourceforge/pmd/properties/PropertyAccessorTest.java index d1c39c731e..6a19e9e89e 100644 --- a/pmd/regress/test/net/sourceforge/pmd/properties/PropertyAccessorTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/properties/PropertyAccessorTest.java @@ -31,15 +31,15 @@ public class PropertyAccessorTest extends SimpleAggregatorTst { public void testIntegers() throws ReportException { - rule.setProperty("singleInt", new Integer(0)); + rule.setProperty(NonRuleWithAllPropertyTypes.singleInt, new Integer(0)); assertTrue(rule.getIntProperty("singleInt") == 0); - rule.setProperties("multiInt", new Object[] {new Integer(0), new Integer(1)}); - assertTrue(areEqual(rule.getIntProperties("multiInt"), new int[]{0, 1})); + rule.setProperties(NonRuleWithAllPropertyTypes.multiInt, new Object[] {new Integer(0), new Integer(1)}); + assertTrue(areEqual(rule.getIntProperties(NonRuleWithAllPropertyTypes.multiInt), new int[]{0, 1})); boolean exceptionOccurred = false; try { - rule.setProperties("singleInt", new Object[] {new Integer(0), new Integer(1)}); + rule.setProperties(NonRuleWithAllPropertyTypes.singleInt, new Object[] {new Integer(0), new Integer(1)}); } catch (Exception ex) { exceptionOccurred = true; } @@ -47,7 +47,7 @@ public class PropertyAccessorTest extends SimpleAggregatorTst { exceptionOccurred = false; try { - rule.setProperty("multiInt", new Integer(0)); + rule.setProperty(NonRuleWithAllPropertyTypes.multiInt, new Integer(0)); } catch (Exception ex) { exceptionOccurred = true; } @@ -56,15 +56,15 @@ public class PropertyAccessorTest extends SimpleAggregatorTst { public void testBooleans() throws ReportException { - rule.setProperty("singleBool", Boolean.FALSE); + rule.setProperty(NonRuleWithAllPropertyTypes.singleBool, Boolean.FALSE); assertFalse(rule.getBooleanProperty("singleBool")); - rule.setProperties("multiBool", new Boolean[] {Boolean.TRUE, Boolean.FALSE}); - assertTrue(areEqual(rule.getBooleanProperties("multiBool"), new boolean[]{true, false})); + rule.setProperties(NonRuleWithAllPropertyTypes.multiBool, new Boolean[] {Boolean.TRUE, Boolean.FALSE}); + assertTrue(areEqual(rule.getBooleanProperties(NonRuleWithAllPropertyTypes.multiBool), new boolean[]{true, false})); boolean exceptionOccurred = false; try { - rule.setProperties("singleBool", new Boolean[] {Boolean.TRUE, Boolean.FALSE}); + rule.setProperties(NonRuleWithAllPropertyTypes.singleBool, new Boolean[] {Boolean.TRUE, Boolean.FALSE}); } catch (Exception ex) { exceptionOccurred = true; } @@ -72,7 +72,7 @@ public class PropertyAccessorTest extends SimpleAggregatorTst { exceptionOccurred = false; try { - rule.setProperty("multiBool", Boolean.TRUE); + rule.setProperty(NonRuleWithAllPropertyTypes.multiBool, Boolean.TRUE); } catch (Exception ex) { exceptionOccurred = true; } @@ -106,15 +106,15 @@ public class PropertyAccessorTest extends SimpleAggregatorTst { public void testStrings() throws ReportException { - rule.setProperty("singleStr", "brian"); + rule.setProperty(NonRuleWithAllPropertyTypes.singleStr, "brian"); assertEquals(rule.getStringProperty("singleStr"), "brian"); - rule.setProperties("multiStr", new String[] {"hello", "world"}); - assertTrue(CollectionUtil.arraysAreEqual(rule.getStringProperties("multiStr"), new String[] {"hello", "world"})); + rule.setProperties(NonRuleWithAllPropertyTypes.multiStr, new String[] {"hello", "world"}); + assertTrue(CollectionUtil.arraysAreEqual(rule.getStringProperties(NonRuleWithAllPropertyTypes.multiStr), new String[] {"hello", "world"})); boolean exceptionOccurred = false; try { - rule.setProperties("singleStr", new String[] {"hello", "world"}); + rule.setProperties(NonRuleWithAllPropertyTypes.singleStr, new String[] {"hello", "world"}); } catch (Exception ex) { exceptionOccurred = true; } @@ -122,7 +122,7 @@ public class PropertyAccessorTest extends SimpleAggregatorTst { exceptionOccurred = false; try { - rule.setProperty("multiStr", "brian"); + rule.setProperty(NonRuleWithAllPropertyTypes.multiStr, "brian"); } catch (Exception ex) { exceptionOccurred = true; }