⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 domhelpertest.java

📁 在Struts2中的jar包xwork的源代码.版本为2.0.7
💻 JAVA
字号:
/* * Copyright (c) 2002-2003 by OpenSymphony * All rights reserved. */package com.opensymphony.xwork2.util;import java.io.StringReader;import junit.framework.TestCase;import org.w3c.dom.Document;import org.w3c.dom.Element;import org.w3c.dom.NodeList;import org.xml.sax.InputSource;import com.opensymphony.xwork2.util.location.Location;/** * Test cases for {@link DomHelper}. */public class DomHelperTest extends TestCase {    private String xml = "<!DOCTYPE foo [\n" +                         "<!ELEMENT foo (bar)>\n" +                         "<!ELEMENT bar (#PCDATA)>\n" +                         "]>\n" +                         "<foo>\n" +                         " <bar/>\n" +                         "</foo>\n";        public void testParse() throws Exception {        InputSource in = new InputSource(new StringReader(xml));        in.setSystemId("foo://bar");                Document doc = DomHelper.parse(in);        assertNotNull(doc);        assertTrue("Wrong root node",            "foo".equals(doc.getDocumentElement().getNodeName()));                NodeList nl = doc.getElementsByTagName("bar");        assertTrue(nl.getLength() == 1);                            }        public void testGetLocationObject() throws Exception {        InputSource in = new InputSource(new StringReader(xml));        in.setSystemId("foo://bar");                Document doc = DomHelper.parse(in);                NodeList nl = doc.getElementsByTagName("bar");                Location loc = DomHelper.getLocationObject((Element)nl.item(0));                assertNotNull(loc);        assertTrue("Should be line 6, was "+loc.getLineNumber(),             6==loc.getLineNumber());    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -