1 package test.net.sourceforge.pmd.properties; 2 3 import java.util.ArrayList ; 4 import java.util.HashMap ; 5 6 import net.sourceforge.pmd.PropertyDescriptor; 7 import net.sourceforge.pmd.properties.EnumeratedProperty; 8 9 11 public class EnumeratedPropertyTest extends AbstractPropertyDescriptorTester { 12 13 private static final Object [][] mixedItems = new Object [][] { 14 {"map", new HashMap ()}, 15 {"emptyArray", new Object [0]}, 16 {"list", new ArrayList ()}, 17 {"string", "Hello World!"}, 18 }; 19 20 public EnumeratedPropertyTest() { 21 super(); 22 } 23 24 29 protected Object createValue(int count) { 30 31 if (count == 1) return ((Object [])randomChoice(mixedItems))[1]; 32 33 Object [] values = new Object [count]; 34 for (int i=0; i<values.length; i++) values[i] = createValue(1); 35 return values; 36 } 37 38 43 protected PropertyDescriptor createProperty(int maxCount) { 44 45 return maxCount == 1 ? 46 new EnumeratedProperty("testEnumerations", "Test enumerations with complex types", mixedItems, 1.0f) : 47 new EnumeratedProperty("testEnumerations", "Test enumerations with complex types", mixedItems, 1.0f, 3); 48 } 49 50 } 51 | Popular Tags |