FileDocCategorySizeDatePackage
TestMonth.javaAPI DocApache Axis 1.44571Sat Apr 22 18:57:26 BST 2006test.types

TestMonth

public class TestMonth extends TestCase
Test validation of types.Month

Fields Summary
Constructors Summary
public TestMonth(String name)

        super(name);
    
Methods Summary
private voidrunFailTest(int month, java.lang.String tz)
Run a failure test. values should be invalid.

        Month oMonth = null;
        try {
            oMonth = new Month(month, tz);
        }
        catch (Exception e) { // catch the validation exception
        }
        // object is not instantiated on bad data value
        assertNull("validation restriction failed [ month=" + String.valueOf(month) + 
                   ",tz=" + tz + "]. did not restrict bad value.", oMonth);
    
private voidrunFailTest(java.lang.String source)

        Month oMonth = null;
        try {
            oMonth = new Month(source);
        }
        catch (Exception e) { // catch the validation exception
        }
        // object is not instantiated on bad data value
        assertNull("validation restriction failed [ " + source +
                 "]. did not restrict bad value.", oMonth);
    
private voidrunPassTest(int month, java.lang.String tz)
Run a successful test. values should be valid.

        Month oMonth = null;
        try {
            oMonth = new Month(month, tz);
        }
        catch (Exception e) { // catch the validation exception
            assertTrue("Validation exception thrown on valid input", false);
        }
        assertEquals("Month month not equal", month, oMonth.getMonth());
        assertEquals("Month timezone not equal", tz, oMonth.getTimezone());
    
private voidrunPassTest(java.lang.String source)

        Month oMonth = null;
        try {
            oMonth = new Month(source);
        }
        catch (Exception e) { // catch the validation exception
            assertTrue("Validation exception thrown on valid input", false);
        }
        assertEquals("Month.toString() not equal", source, oMonth.toString());
    
public voidtestBadMonth()
Test that a bad month fails

        runFailTest(13, null);
    
public voidtestBadMonthString()

        runFailTest("--13--");
    
public voidtestBadMonthString2()

        runFailTest("--1--");
    
public voidtestBadString()
Test that badly formatted strings fail

        runFailTest("11--");
        runFailTest("-11--");
        runFailTest("--11-");
        runFailTest("--11");
        runFailTest("xx07-13");
        runFailTest("garbage");
    
public voidtestBadTimezone()
Test that a bad timezone fails

        runFailTest(7, "badzone");
    
public voidtestBadTimezoneString()

        runFailTest("--07--+EDT");
    
public voidtestNormal()
Test that a normal date succeeeds

        // test all twelve months
        for (int m=1; m < 13; m++) {
            runPassTest(m, null);
        }
    
public voidtestNormalNegativeTimezone()

        runPassTest("--11---11:00");
    
public voidtestNormalPositiveTimezone()

        runPassTest("--11--+05:00");
    
public voidtestNormalString()

        // test all twelve months
        // use NumberFormat to ensure leading zeros
        NumberFormat nf = NumberFormat.getInstance();
        nf.setMinimumIntegerDigits(2);
        for (int m=1; m < 13; m++) {
            String s = "--" + nf.format(m) + "--";
            runPassTest(s);
        }
    
public voidtestNormalTimezone()

        runPassTest("--01--Z");