FileDocCategorySizeDatePackage
SelfTest.javaAPI DocphoneME MR2 API (J2ME)11511Wed May 02 18:00:00 BST 2007com.sun.midp.i3test

SelfTest

public class SelfTest extends Object

Fields Summary
static final String
pkgname
static int
internalErrorCount
static int
selfTestCount
static String
errorLog
Constructors Summary
Methods Summary
static voidcheck(java.lang.String label, int eTotalCases, int eTotalTests, int eTotalAsserts, int eTotalFailures, int eErrorClassNotFound, int eErrorConstructorException, int eErrorNotTestCase, int eErrorTestRunThrows, int eErrorNoTests, int eErrorAssertWithoutTest, int eErrorTestWithoutAssert)


      
         
         
         
         
         
         
         
         
         
         
         
         
    
        String buf = "";

        if (eTotalCases != TestCase.totalCases) {
            buf += "  totalCases: expected " + eTotalCases +
                ", got " + TestCase.totalCases + "\n";
        }

        if (eTotalTests != TestCase.totalTests) {
            buf += "  totalTests: expected " + eTotalTests +
                ", got " + TestCase.totalTests + "\n";
        }

        if (eTotalAsserts != TestCase.totalAsserts) {
            buf += "  totalAsserts: expected " + eTotalAsserts +
                ", got " + TestCase.totalAsserts + "\n";
        }

        if (eTotalFailures != TestCase.totalFailures) {
            buf += "  totalFailures: expected " + eTotalFailures +
                ", got " + TestCase.totalFailures + "\n";
        }

        if (eErrorClassNotFound != TestCase.errorClassNotFound) {
            buf += "  errorClassNotFound: expected " + eErrorClassNotFound +
                ", got " + TestCase.errorClassNotFound + "\n";
        }

        if (eErrorConstructorException != TestCase.errorConstructorException) {
            buf += "  errorConstructorException: expected " +
                eErrorConstructorException +
                ", got " + TestCase.errorConstructorException + "\n";
        }

        if (eErrorNotTestCase != TestCase.errorNotTestCase) {
            buf += "  errorNotTestCase: expected " + eErrorNotTestCase +
                ", got " + TestCase.errorNotTestCase + "\n";
        }

        if (eErrorTestRunThrows != TestCase.errorTestRunThrows) {
            buf += "  errorTestRunThrows: expected " + eErrorTestRunThrows +
                ", got " + TestCase.errorTestRunThrows + "\n";
        }

        if (eErrorNoTests != TestCase.errorNoTests) {
            buf += "  errorNoTests: expected " + eErrorNoTests +
                ", got " + TestCase.errorNoTests + "\n";
        }

        if (eErrorAssertWithoutTest != TestCase.errorAssertWithoutTest) {
            buf += "  errorAssertWithoutTest: expected " +
                eErrorAssertWithoutTest +
                ", got " + TestCase.errorAssertWithoutTest + "\n";
        }

        if (eErrorTestWithoutAssert != TestCase.errorTestWithoutAssert) {
            buf += "  errorTestWithoutAssert: expected " +
                eErrorTestWithoutAssert +
                ", got " + TestCase.errorTestWithoutAssert + "\n";
        }

        if (! "".equals(buf)) {
            internalErrorCount++;
            errorLog += "INTERNAL ERROR in " + label + "\n" + buf;
        }
    
static voidrun()

        System.out.println();
        System.out.println("Starting self test.  Ignore messages below.");
        System.out.println();
        System.out.println("========================================");
        System.out.println();

        runOneTest("xyzzy.plugh");
        check("NotFound",                   0, 0,  0,  0, 1, 0, 0, 0, 0, 0, 0);

        runOneTest("SelfTest$BadConstructor");
        check("ConstructorException",       1, 0,  0,  0, 0, 1, 0, 0, 0, 0, 0);

        runOneTest("SelfTest$NotTestCase");
        check("NotTestCase",                0, 0,  0,  0, 0, 0, 1, 0, 0, 0, 0);

        runOneTest("SelfTest$TestRunThrows1");
        check("TestRunThrows1",             1, 0,  0,  0, 0, 0, 0, 1, 1, 0, 0);

        runOneTest("SelfTest$TestRunThrows2");
        check("TestRunThrows2",             1, 1,  0,  0, 0, 0, 0, 1, 0, 0, 1);

        runOneTest("SelfTest$NoTests");
        check("NoTests",                    1, 0,  0,  0, 0, 0, 0, 0, 1, 0, 0);

        runOneTest("SelfTest$AssertWithoutTest");
        check("AssertWithoutTest",          1, 0,  0,  0, 0, 0, 0, 0, 1, 1, 0);

        runOneTest("SelfTest$TestWithoutAssert1");
        check("TestWithoutAssert1",         1, 1,  0,  0, 0, 0, 0, 0, 0, 0, 1);

        runOneTest("SelfTest$TestWithoutAssert2");
        check("TestWithoutAssert2",         1, 2,  1,  0, 0, 0, 0, 0, 0, 0, 1);

        runOneTest("SelfTest$TestWithoutAssert3");
        check("TestWithoutAssert3",         1, 2,  1,  0, 0, 0, 0, 0, 0, 0, 1);

        runOneTest("SelfTest$TestAllSuccess");
        check("TestAllSuccess",             1, 1, 24,  0, 0, 0, 0, 0, 0, 0, 0);

        runOneTest("SelfTest$TestAllFail");
        check("TestAllFail",                1, 1, 24, 24, 0, 0, 0, 0, 0, 0, 0);

        runOneTest("SelfTest$TestRequestSecurityToken");
        check("TestRequestSecurityToken",       1, 1,  1,  0, 0, 0, 0, 0, 0, 0, 0);

        System.out.println();
        System.out.println("========================================");
        System.out.println();
        if (! "".equals(errorLog)) {
            System.out.print(errorLog);
        }
        System.out.println();
        System.out.println(
            "Self test run complete: " +
            selfTestCount + " test(s), " + internalErrorCount + " error(s).");
    
static voidrunOneTest(java.lang.String clname)

        TestCase.reset();
        TestCase.runTestCase(pkgname + "." + clname);
        selfTestCount++;