FileDocCategorySizeDatePackage
EnumeratedAttributeTest.javaAPI DocApache Ant 1.703445Wed Dec 13 06:16:18 GMT 2006org.apache.tools.ant.types

EnumeratedAttributeTest

public 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 voidtestContains()

        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 voidtestExceptions()

        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 voidtestFactory()

		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
		}