本文整理汇总了Java中org.xml.sax.helpers.NamespaceSupport.popContext方法的典型用法代码示例。如果您正苦于以下问题:Java NamespaceSupport.popContext方法的具体用法?Java NamespaceSupport.popContext怎么用?Java NamespaceSupport.popContext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.xml.sax.helpers.NamespaceSupport
的用法示例。
在下文中一共展示了NamespaceSupport.popContext方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testPopContext
import org.xml.sax.helpers.NamespaceSupport; //导入方法依赖的package包/类
@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]);
}
示例2: testcase01
import org.xml.sax.helpers.NamespaceSupport; //导入方法依赖的package包/类
/**
* 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});
}
示例3: testcase02
import org.xml.sax.helpers.NamespaceSupport; //导入方法依赖的package包/类
/**
* 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"});
}
示例4: testcase03
import org.xml.sax.helpers.NamespaceSupport; //导入方法依赖的package包/类
/**
* 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"});
}
示例5: testcase04
import org.xml.sax.helpers.NamespaceSupport; //导入方法依赖的package包/类
/**
* 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));
}
示例6: testConstructor
import org.xml.sax.helpers.NamespaceSupport; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@TestTargets ({
@TestTargetNew(
level = TestLevel.COMPLETE,
notes = "Checks that a new NamespaceSupport object contains a " +
"default context with two predefined prefixes.",
method = "NamespaceSupport",
args = {}
),
@TestTargetNew(
level = TestLevel.PARTIAL_COMPLETE,
method = "popContext",
args = {}
)
})
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.
}
}
示例7: testPush_PopContext
import org.xml.sax.helpers.NamespaceSupport; //导入方法依赖的package包/类
@TestTargets ({
@TestTargetNew(
level = TestLevel.COMPLETE,
method = "pushContext",
args = {}
),
@TestTargetNew(
level = TestLevel.PARTIAL_COMPLETE,
method = "popContext",
args = {}
)
})
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.
}
}
示例8: testReset
import org.xml.sax.helpers.NamespaceSupport; //导入方法依赖的package包/类
@TestTargets ({
@TestTargetNew(
level = TestLevel.COMPLETE,
method = "reset",
args = {}
),
@TestTargetNew(
level = TestLevel.PARTIAL_COMPLETE,
method = "popContext",
args = {}
)
})
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.
}
}