| 1 package test.net.sourceforge.pmd.properties; 2 3 import net.sourceforge.pmd.PropertyDescriptor; 4 import net.sourceforge.pmd.properties.StringProperty; 5 6 8 public class StringPropertyTest extends AbstractPropertyDescriptorTester { 9 10 private static final int maxStringLength = 52; 11 private static final char delimiter = '|'; 12 private static final char[] charSet = filter(allChars.toCharArray(), delimiter); 13 14 public StringPropertyTest() { 15 super(); 16 } 17 18 23 protected Object createValue(int count) { 24 25 if (count == 1) return newString(); 26 27 String [] values = new String [count]; 28 for (int i=0; i<count; i++) values[i] = (String )createValue(1); 29 return values; 30 } 31 32 36 private String newString() { 37 38 int strLength = randomInt(0, maxStringLength); 39 40 char[] chars = new char[strLength]; 41 for (int i=0; i<chars.length; i++) chars[i] = randomCharIn(charSet); 42 return new String (chars); 43 } 44 45 50 private char randomCharIn(char[] chars) { 51 return randomChar(chars); 52 } 53 54 59 protected PropertyDescriptor createProperty(int maxCount) { 60 return maxCount == 1 ? 61 new StringProperty("testString", "Test string property", "brian", 1.0f) : 62 new StringProperty("testString", "Test string property", new String [] {"hello", "world"}, 1.0f, delimiter); 63 } 64 65 } 66 | Popular Tags |