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

TestRegistryImpl

public class TestRegistryImpl extends ExtendedTestCase
Test the internal functions of RegistryImpl.

Fields Summary
private static final String
SUITE_ID
Constant application ID for testing.
private static final String
CLASSNAME
Constant classname for testing.
private static final String
GS_NAME
The name and ID of the GraphicalInstaller.
private static final int
GS_SUITEID
The suiteId of the GraphicalInstaller.
private static final String
GS_CLASSNAME
The class of the GraphicalInstaller.
private String[]
types
The types registered for the GraphicalInstaller.
private String[]
suffixes
The suffixes registered for the GraphicalInstaller.
RegistryImpl
registry
The registry to use.
Constructors Summary
Methods Summary
public voidrunTests()
Run the tests.


            
       
	setup();
	test001();
	test002();
    
voidsetup()
Setup the registry.

	registry = getRegistry();
    
voidtest001()
Test that the built-in suite is registered. The Graphical Installer must be present.

        declare("Verify built-in registration for GraphicalInstaller");
	try {
	    AppProxy app = AppProxy.getCurrent().forClass(GS_CLASSNAME);
	    ContentHandlerImpl ch = registry.getServer(app);

	    assertNotNull("Verify GraphicalInstaller is present", ch);
	    if (ch != null) {
		assertEquals("Verify getID",
			     GS_NAME, ch.getID());

		assertEquals("Verify classname",
			     GS_CLASSNAME, ch.classname);
		assertEquals("Verify getTypeCount",
			     2,  ch.getTypeCount());
		assertEquals("Verify Type1",
			     types[0], ch.getType(0));
		assertEquals("Verify Type2",
			     types[1], ch.getType(1));
		assertEquals("Verify getSuffixCount",
			     2, ch.getSuffixCount());
		assertEquals("Verify Suffix1",
			     suffixes[0], ch.getSuffix(0));
		assertEquals("Verify Suffix2",
			     suffixes[1], ch.getSuffix(1));
		assertEquals("Verify Action",
			     2, ch.getActionCount());
		assertEquals("Verify Action Name Maps",
			     3, ch.getActionNameMapCount());
	    }
	} catch (ClassNotFoundException cnfe) {
	    fail("Unexpected exception");
	    cnfe.printStackTrace();
	}
    
voidtest002()
Test that the value of the System property "CHAPI-Version" is "1.0".

	declare("Check system properties");
	String ver = System.getProperty("microedition.chapi.version");
	assertEquals("Verify microedition.chapi.version", "1.0", ver);