Java Code Examples for org.xml.sax.helpers.NamespaceSupport#popContext()
The following examples show how to use
org.xml.sax.helpers.NamespaceSupport#popContext() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NSSupportTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
@Test public void testPopContext() { String[] parts = new String[3]; NamespaceSupport nssupport = new NamespaceSupport(); nssupport.pushContext(); nssupport.declarePrefix("dc", "http://www.purl.org/dc"); Assert.assertEquals(nssupport.getPrefix("http://www.purl.org/dc"), "dc"); nssupport.popContext(); Assert.assertNull(nssupport.getPrefix("http://www.purl.org/dc")); nssupport.processName("dc:name1", parts, false); Assert.assertNull(parts[0]); Assert.assertNull(parts[1]); Assert.assertNull(parts[2]); }
Example 2
Source File: NSSupportTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * Test for NamespaceSupport.getDeclaredPrefixes(). */ @Test public void testcase01() { String[] prefixes = new String[2]; NamespaceSupport support = new NamespaceSupport(); support.pushContext(); support.declarePrefix(EMPTY_PREFIX, W3_URI); support.declarePrefix(DC_PREFIX, PURL_URI); Enumeration e = support.getDeclaredPrefixes(); int i = 0; while(e.hasMoreElements()) { prefixes[i++] = e.nextElement().toString(); } support.popContext(); assertEquals(prefixes, new String[]{EMPTY_PREFIX, DC_PREFIX}); }
Example 3
Source File: NamespaceSupportTest.java From j2objc with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") public void testConstructor() { String prefix; boolean xmlPrefixExists = false; ns = new NamespaceSupport(); Enumeration<String> prefixes = ns.getDeclaredPrefixes(); while (prefixes.hasMoreElements()) { prefix = prefixes.nextElement(); if (prefix.equals("xml")) xmlPrefixExists = true; } assertTrue("Test 1: xml prefix does not exist.", xmlPrefixExists); // Check that only one context has been created by the constructor. try { ns.popContext(); fail("Test 2: EmptyStackException expected."); } catch (EmptyStackException e) { // Expected. } }
Example 4
Source File: NamespaceSupportTest.java From j2objc with Apache License 2.0 | 6 votes |
public void testPush_PopContext() { int count; ns = new NamespaceSupport(); count = countPrefixes(); ns.pushContext(); ns.declarePrefix("dc", "http://www.purl.org/dc#"); assertEquals("Test 1: Incorrect prefix count;", count + 1, countPrefixes()); ns.popContext(); assertEquals("Test 2: Incorrect prefix count;", count, countPrefixes()); // Check that only one context has been created by pushContext(). try { ns.popContext(); fail("Test 3: EmptyStackException expected."); } catch (EmptyStackException e) { // Expected. } }
Example 5
Source File: NamespaceSupportTest.java From j2objc with Apache License 2.0 | 6 votes |
public void testReset() { int count; ns = new NamespaceSupport(); count = countPrefixes(); ns.pushContext(); ns.declarePrefix("dc", "http://www.purl.org/dc#"); assertEquals("Test 1: Incorrect prefix count;", count + 1, countPrefixes()); ns.reset(); assertEquals("Test 2: Incorrect prefix count;", count, countPrefixes()); // Check that only one context has been created by reset(). try { ns.popContext(); fail("Test 3: EmptyStackException expected."); } catch (EmptyStackException e) { // Expected. } }
Example 6
Source File: NSSupportTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * Test for NamespaceSupport.getDeclaredPrefixes() and support.processName(). */ @Test public void testcase02() { String[] parts = new String[3]; NamespaceSupport support = new NamespaceSupport(); support.pushContext(); support.declarePrefix(DC_PREFIX, PURL_URI); parts = support.processName("dc:title", parts, false); support.popContext(); assertEquals(parts, new String[]{PURL_URI, "title", "dc:title"}); }
Example 7
Source File: NSSupportTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * Test for NamespaceSupport.getDeclaredPrefixes() and support.processName(). */ @Test public void testcase03() { String[] parts = new String[3]; NamespaceSupport support = new NamespaceSupport(); support.pushContext(); support.declarePrefix(EMPTY_PREFIX, W3_URI); parts = support.processName("a", parts, false); support.popContext(); assertEquals(parts, new String[]{W3_URI, "a", "a"}); }
Example 8
Source File: NSSupportTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * Test for NamespaceSupport.popContext(). */ @Test public void testcase04() { NamespaceSupport support = new NamespaceSupport(); support.pushContext(); support.declarePrefix(EMPTY_PREFIX, W3_URI); support.declarePrefix(DC_PREFIX, PURL_URI); assertEquals(support.getURI(EMPTY_PREFIX), W3_URI); assertEquals(support.getURI(DC_PREFIX), PURL_URI); support.popContext(); assertNull(support.getURI(EMPTY_PREFIX)); assertNull(support.getURI(DC_PREFIX)); }