01: package test.net.sourceforge.pmd.properties;
02:
03: import java.util.ArrayList;
04: import java.util.HashMap;
05:
06: import net.sourceforge.pmd.PropertyDescriptor;
07: import net.sourceforge.pmd.properties.EnumeratedProperty;
08:
09: /**
10: */
11: public class EnumeratedPropertyTest extends
12: AbstractPropertyDescriptorTester {
13:
14: private static final String[] keys = new String[] { "map",
15: "emptyArray", "list", "string", };
16:
17: private static final Object[] values = new Object[] {
18: new HashMap(), new Object[0], new ArrayList(),
19: "Hello World!", };
20:
21: public EnumeratedPropertyTest() {
22: super ();
23: }
24:
25: /**
26: * Method createValue.
27: * @param count int
28: * @return Object
29: */
30: protected Object createValue(int count) {
31:
32: if (count == 1)
33: return randomChoice(values);
34:
35: Object[] values = new Object[count];
36: for (int i = 0; i < values.length; i++)
37: values[i] = createValue(1);
38: return values;
39: }
40:
41: /**
42: * Method createProperty.
43: * @param maxCount int
44: * @return PropertyDescriptor
45: */
46: protected PropertyDescriptor createProperty(int maxCount) {
47:
48: return maxCount == 1 ? new EnumeratedProperty<Object>(
49: "testEnumerations",
50: "Test enumerations with complex types", keys, values,
51: 1.0f) : new EnumeratedProperty<Object>(
52: "testEnumerations",
53: "Test enumerations with complex types", keys, values,
54: 1.0f, 3);
55: }
56:
57: public static junit.framework.Test suite() {
58: return new junit.framework.JUnit4TestAdapter(
59: EnumeratedPropertyTest.class);
60: }
61: }
|