1   package test.net.sourceforge.pmd.properties;
2   
3   import net.sourceforge.pmd.PropertyDescriptor;
4   import net.sourceforge.pmd.properties.BooleanProperty;
5   
6   /**
7    * @author Brian Remedios
8    */
9   public class BooleanPropertyTest extends AbstractPropertyDescriptorTester {
10  
11  	public BooleanPropertyTest() {
12  		super();
13  	}
14  
15  	/**
16  	 * Method createValue.
17  	 * @param valueCount int
18  	 * @return Object
19  	 */
20  	public Object createValue(int valueCount) {
21  		
22  		if (valueCount == 1) return System.currentTimeMillis() % 1 > 0 ?
23  			Boolean.TRUE : Boolean.FALSE;
24  		
25  		Boolean[] values = new Boolean[valueCount];
26  		for (int i=0; i<values.length; i++) values[i] = (Boolean)createValue(1);
27  		return values;
28  	}
29  
30  	/**
31  	 * Method createProperty.
32  	 * @param maxValues int
33  	 * @return PropertyDescriptor
34  	 */
35  	public PropertyDescriptor createProperty(int maxValues) {
36  		return maxValues == 1 ?
37  			new BooleanProperty("testBoolean", "Test boolean property", false, 1.0f) :
38  			new BooleanProperty("testBoolean", "Test boolean property", new boolean[] {false}, 1.0f, maxValues);
39  	}
40  
41      public static junit.framework.Test suite() {
42          return new junit.framework.JUnit4TestAdapter(BooleanPropertyTest.class);
43      }
44  }