1 19 package org.enhydra.zeus.binding; 20 21 import java.util.BitSet ; 22 import java.util.Vector ; 23 24 import junit.framework.Test; 25 import junit.framework.TestCase; 26 import junit.framework.TestSuite; 27 28 import org.enhydra.zeus.AbstractBindingTest; 29 import org.enhydra.zeus.Binding; 30 31 44 public abstract class AbstractPropertyTest extends AbstractBindingTest { 45 46 54 protected abstract Property createProperty(); 55 56 63 public AbstractPropertyTest(String name) { 64 super(name); 65 } 66 67 76 public static Test suite() { 77 return new TestSuite(AbstractPropertyTest.class); 78 } 79 80 88 public Binding createBinding() { 89 90 return createProperty(); 92 } 93 94 99 public void testSetModifier() { 100 Property property = createProperty(); 101 BitSet modifiers = new BitSet (); 102 modifiers.set(Property.ACCESS_PRIVATE); 103 modifiers.set(Property.SOURCE_ATTLIST); 104 105 property.setModifier(modifiers); 106 assertEquals(modifiers, property.getModifier()); 107 108 modifiers = new BitSet (); 109 modifiers.set(Property.ACCESS_PUBLIC); 110 modifiers.set(Property.SOURCE_ELEMENT); 111 112 property.setModifier(modifiers); 113 assertEquals(modifiers, property.getModifier()); 114 } 115 116 121 public void testGetModifier() { 122 Property property = createProperty(); 123 BitSet modifiers = new BitSet (); 124 modifiers.set(Property.ACCESS_PRIVATE); 125 modifiers.set(Property.SOURCE_ATTLIST); 126 127 property.setModifier(modifiers); 128 assertEquals(modifiers, property.getModifier()); 129 } 130 131 136 public void testGetModifierString() { 137 Property property = createProperty(); 138 BitSet modifiers = new BitSet (); 139 modifiers.set(Property.ACCESS_PRIVATE); 140 modifiers.set(Property.SOURCE_ATTLIST); 141 String expected = "private"; 142 143 property.setModifier(modifiers); 144 assertEquals(expected, property.getModifierString()); 145 146 modifiers = new BitSet (); 147 modifiers.set(Property.ACCESS_PUBLIC); 148 modifiers.set(Property.STORAGE_STATIC); 149 modifiers.set(Property.MUTABILITY_FINAL); 150 expected = "public static final"; 151 152 property.setModifier(modifiers); 153 assertEquals(expected, property.getModifierString()); 154 } 155 156 161 public void testSetIsCollection() { 162 Property property = createProperty(); 163 boolean expected = true; 164 property.setIsCollection(expected); 165 assertEquals(expected, property.isCollection()); 166 167 expected = false; 168 property.setIsCollection(expected); 169 assertEquals(expected, property.isCollection()); 170 } 171 172 177 public void testIsCollection() { 178 Property property = createProperty(); 179 boolean expected = true; 180 property.setIsCollection(expected); 181 assertEquals(expected, property.isCollection()); 182 } 183 184 189 public void testHasDefaultValue() { 190 Property property = createProperty(); 191 boolean expected = true; 192 property.setDefaultValue("defaultValue"); 193 assertEquals(expected, property.hasDefaultValue()); 194 } 195 196 201 public void testSetDefaultValue() { 202 Property property = createProperty(); 203 String expected1 = "defaultValue"; 204 property.setDefaultValue(expected1); 205 assertEquals(expected1, (String )property.getDefaultValue()); 206 207 Integer expected2 = new Integer (10); 208 property.setDefaultValue(expected2); 209 assertEquals(expected2, (Integer )property.getDefaultValue()); 210 } 211 212 217 public void testGetDefaultValue() { 218 Property property = createProperty(); 219 String expected1 = "defaultValue"; 220 property.setDefaultValue(expected1); 221 assertEquals(expected1, (String )property.getDefaultValue()); 222 } 223 224 229 public void testHasEnumeration() { 230 Property property = createProperty(); 231 boolean expected = true; 232 property.setEnumeration(new Vector ()); 233 assertEquals(expected, property.hasEnumeration()); 234 } 235 236 241 public void testSetEnumeration() { 242 Property property = createProperty(); 243 Vector expected1 = new Vector (); 244 expected1.add("value1"); 245 expected1.add("value2"); 246 property.setEnumeration(expected1); 247 assertEquals(expected1, property.getEnumeration()); 248 249 Vector expected2 = new Vector (); 250 expected2.add(new Integer (1)); 251 expected2.add(new Integer (2)); 252 property.setEnumeration(expected2); 253 assertEquals(expected2, property.getEnumeration()); 254 } 255 256 261 public void testGetEnumeration() { 262 Property property = createProperty(); 263 Vector expected1 = new Vector (); 264 expected1.add("value1"); 265 expected1.add("value2"); 266 property.setEnumeration(expected1); 267 assertEquals(expected1, property.getEnumeration()); 268 } 269 } 270 | Popular Tags |