FileDocCategorySizeDatePackage
ExtendedTestCase.javaAPI DocphoneME MR2 API (J2ME)6746Wed May 02 18:00:44 BST 2007com.sun.midp.content

ExtendedTestCase

public abstract class ExtendedTestCase extends com.sun.midp.i3test.TestCase
Extension to the basic TestCase class to add ContentHandler specific assert methods.

Fields Summary
String
classname
Classname of the MIDlet.
Constructors Summary
Methods Summary
public voidassertEquals(java.lang.String message, java.lang.Object expected, java.lang.Object actual)
Override assertEquals to allow null pointers.

param
message message
param
expected the expected object
param
actual the actual object.

	if (expected == actual) {
	    // The identity and the null == null
	    return;
	}
	if (expected != null) {
	    assertTrue(message, expected.equals(actual));
	} else {
	    assertTrue(message, actual.equals(expected));
	}
    
public voidassertEquals(java.lang.String msg, InvocationImpl expected, InvocationImpl actual)
Assert that all of the fields of the two InvocationImpls match exactly.

param
msg the message to print for assert failures
param
expected the InvocationImpl containing the expected values
param
actual the InvocationImpl containing the actual values

	if (expected == actual) {
	    return;
	}
	assertNotNull(msg + " expected: ", actual);
	if (actual == null) {
	    return;
	}

        assertEquals("verify getID", expected.getID(), actual.getID());
        assertEquals("verify getType", expected.getType(), actual.getType());
        assertEquals("verify getURL", expected.getURL(), actual.getURL());
        assertTrue("verify responseRequired",
            expected.getResponseRequired() == actual.getResponseRequired());
	assertEquals("verify action",
		     expected.getAction(), actual.getAction());
        assertEquals("verify classname",
		     expected.classname, actual.classname);
        assertEquals("verify invokingSuiteId", expected.invokingSuiteId,
		     actual.invokingSuiteId);
        assertEquals("verify invokingClassname",
		     expected.invokingClassname,
		     actual.invokingClassname);
        assertEquals("verify tid", expected.tid, actual.tid);
        assertEquals("verify invokingAuthority",
		     expected.invokingAuthority,
		     actual.invokingAuthority);
        assertEquals("verify invokingID", expected.invokingID,
		     actual.invokingID);
	assertEquals("verify previousTid",
		     expected.previousTid, actual.previousTid);
	assertEquals("verify arguments",
		     expected.getArgs(), actual.getArgs());
	String[] args = expected.getArgs();
	int argsLen = args != null ? args.length : 0;
	assertEquals("verify argsLen", argsLen, actual.argsLen);
	assertEquals("verify data", expected.data, actual.data);
    
public voidassertEquals(java.lang.String msg, java.lang.String[] s1, java.lang.String[] s2)
Compare two arrays of strings, must be the same length and contents to match.

param
msg the message to print for assert failures
param
s1 an array of strings
param
s2 another array of strings

	// Identical arrays are equals
	if (s1 == s2) {
	    return;
	}
	// If either array is null then they don't match
	if (s1 == null) {
	    fail("mismatched arg arrays; expected is null");
	    return;
	}
	if (s2 == null) {
	    fail("mismatched arg arrays; actual is null");
	    return;
	}
	// If the lengths are unequal then they are not equal
	assertEquals("mismatched arg lengths", s1.length, s2.length);

	if (s1.length == s2.length) {
	    // Compare the strings in each array
	    for (int i = 0; i < s1.length; i++) {
		// Two strings, non-null of the same length
		assertEquals("arg " + i, s1[i], s2[i]);
	    }
	}
    
public voidassertEquals(java.lang.String msg, byte[] expected, byte[] actual)
Compare two byte arrays; must be same length.

param
msg the description of the array
param
expected the expected data array
param
actual the actual data array

        if (expected == actual) {
            return;
        }
        if (expected == null) {
            fail("expected string array is null");
            return;
        }
        if (actual == null) {
            fail("actual string array is null");
            return;
        }
        assertEquals(msg + " length", expected.length, actual.length);
	int badbytes = 0;
	if (expected.length == actual.length) {
	    for (int i = 0; i < expected.length; i++) {
		if (expected[i] != actual[i]) {
		    if (0 == badbytes++) {
			fail(msg + " data does not match");
		    }
		    assertEquals("  " + i + ": ", expected[i], actual[i]);
		}
	    }
	}
    
RegistryImplgetRegistry()
Initialize the registry for this application.

return
the registry for the Framework class


                      
      
	try {
	    SecurityToken token = getSecurityToken();
	    MIDletStateHandler mstate =
		MIDletStateHandler.getMidletStateHandler();
            MIDletSuite msuite = mstate.getMIDletSuite();
	    msuite.setTempProperty(token, "MIDlet-1",
				   "CHAPI Tests,," + classname);

	    return RegistryImpl.getRegistryImpl(classname, token);
	} catch (SecurityException sx) {
	    fail("SecurityException: can't setTempProperty");
	} catch (Throwable t) {
	    assertNull("i3test can't get registry for class " + classname, t);
	    t.printStackTrace();
	}
	return null;
    
public static voidsleep(long millis)
Sleep a bit.

param
millis millseconds to sleep

        try {
            Thread.sleep(millis);
        } catch (InterruptedException ie) {
        }