+++ /dev/null
-/*--------------------------------------------------------------------------\r
- * Copyright 2009 Taro L. Saito\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- *--------------------------------------------------------------------------*/\r
-//--------------------------------------\r
-// XerialJ\r
-//\r
-// DOMWalkerTest.java\r
-// Since: 2009/03/31 9:36:17\r
-//\r
-// $URL$\r
-// $Author$\r
-//--------------------------------------\r
-package org.xerial.util.xml;\r
-\r
-import static org.junit.Assert.assertEquals;\r
-import static org.junit.Assert.assertNull;\r
-\r
-import java.util.HashMap;\r
-\r
-import org.junit.After;\r
-import org.junit.Before;\r
-import org.junit.Test;\r
-import org.xerial.util.FileResource;\r
-import org.xerial.util.log.Logger;\r
-import org.xerial.util.tree.TreeEvent;\r
-import org.xerial.util.tree.TreeEvent.EventType;\r
-import org.xerial.util.xml.pullparser.DOMBuilder;\r
-\r
-public class DOMWalkerTest\r
-{\r
- private static Logger _logger = Logger.getLogger(DOMWalkerTest.class);\r
-\r
- @Before\r
- public void setUp() throws Exception\r
- {}\r
-\r
- @After\r
- public void tearDown() throws Exception\r
- {}\r
-\r
- @Test\r
- public void testWalk() throws Exception\r
- {\r
- DOMBuilder builder = new DOMBuilder();\r
- DOMStreamReader walker = new DOMStreamReader(builder.parse(FileResource.open(DOMWalkerTest.class, "domtest.xml")));\r
-\r
- HashMap<String, String> nodeData = new HashMap<String, String>();\r
-\r
- TreeEvent e;\r
- while ((e = walker.next()) != null)\r
- {\r
- if (e.event == EventType.VISIT)\r
- nodeData.put(e.nodeName, e.nodeValue);\r
- }\r
-\r
- assertNull(nodeData.get("domtest"));\r
- assertNull(nodeData.get("birth"));\r
- assertEquals("Yui-chan", nodeData.get("name"));\r
- assertEquals("25", nodeData.get("day"));\r
- assertEquals("12", nodeData.get("month"));\r
- assertEquals("2002", nodeData.get("year"));\r
- assertEquals("xxxbbbaaa", nodeData.get("photo"));\r
- assertEquals("Tokyo", nodeData.get("address"));\r
-\r
- }\r
-\r
-}\r