EnumeratedAttributeTestpublic class EnumeratedAttributeTest extends TestCase JUnit 3 testcases for org.apache.tools.ant.EnumeratedAttribute. |
Fields Summary |
---|
private static String[] | expected |
Constructors Summary |
---|
public EnumeratedAttributeTest(String name)
super(name);
|
Methods Summary |
---|
public void | testContains()
EnumeratedAttribute t1 = new TestNormal();
for (int i=0; i<expected.length; i++) {
assertTrue(expected[i]+" is in TestNormal",
t1.containsValue(expected[i]));
assertTrue(expected[i].toUpperCase()+" is in TestNormal",
!t1.containsValue(expected[i].toUpperCase()));
}
assertTrue("TestNormal doesn\'t have \"d\" attribute",
!t1.containsValue("d"));
assertTrue("TestNull doesn\'t have \"d\" attribute and doesn\'t die",
!(new TestNull()).containsValue("d"));
| public void | testExceptions()
EnumeratedAttribute t1 = new TestNormal();
for (int i=0; i<expected.length; i++) {
try {
t1.setValue(expected[i]);
} catch (BuildException be) {
fail("unexpected exception for value "+expected[i]);
}
}
try {
t1.setValue("d");
fail("expected exception for value \"d\"");
} catch (BuildException be) {
}
try {
(new TestNull()).setValue("d");
fail("expected exception for value \"d\" in TestNull");
} catch (BuildException be) {
} catch (Throwable other) {
fail("unexpected death of TestNull: "+other.getMessage());
}
| public void | testFactory()
Factory ea = (Factory)EnumeratedAttribute.getInstance(Factory.class, "one");
assertEquals("Factory did not set the right value.", ea.getValue(), "one");
try {
EnumeratedAttribute.getInstance(Factory.class, "illegal");
fail("Factory should fail when trying to set an illegal value.");
} catch (BuildException be) {
// was expected
}
|
|