Code example for NamespaceSupport

Methods: declarePrefix, getPrefix, pushContext

            // Expected. 
    public void testDeclare_GetPrefix() { 
        // Part 1: Check that xml and xmlns are not accepted as prefixes. 
        assertFalse("Test 1: Invalid prefix accepted.",
                ns.declarePrefix("xml", marketUri));
        assertFalse("Test 2: Invalid prefix accepted.",
                ns.declarePrefix("xmlns", marketUri));
        // Part 2: Check that declarePrefix and getPrefix work for valid 
        // prefixes. 
        assertTrue("Test 3: Valid prefix not accepted.",
                ns.declarePrefix("ak", marketUri));
        assertTrue("Test 4: Incorrect prefix returned.",
        assertTrue("Test 5: Valid prefix not accepted.",
                ns.declarePrefix("bk", marketUri));
        assertTrue("Test 6: Incorrect prefix returned.",
        assertTrue("Test 7: Valid prefix not accepted.",
                ns.declarePrefix("", defaultUri));
        // Part 3: Negative Tests for getPrefix. 
        assertNull("Test 8: Non-null value returned for the URI that is " +
                "assigned to the default namespace.", 
        assertNull("Test 9: Non-null value returned for an unassigned URI.",
                ns.getPrefix(defaultUri + "/42"));
    public void testGetPrefixesLjava_lang_String() { 
        ArrayList<String> prefixes;