+++ /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
-// XMLStreamWalkerTest.java\r
-// Since: Mar 30, 2009 7:02:29 PM\r
-//\r
-// $URL: http://www.xerial.org/svn/project/XerialJ/trunk/xerial-core/src/test/java/org/xerial/util/xml/XMLStreamReaderTest.java $\r
-// $Author: leo $\r
-//--------------------------------------\r
-package org.xerial.util.xml;\r
-\r
-import static org.junit.Assert.*;\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
-\r
-public class XMLStreamReaderTest\r
-{\r
- private static Logger _logger = Logger.getLogger(XMLStreamReaderTest.class);\r
-\r
- @Before\r
- public void setUp() throws Exception\r
- {}\r
-\r
- @After\r
- public void tearDown() throws Exception\r
- {}\r
-\r
- public HashMap<String, String> parse(String xml) throws Exception\r
- {\r
- XMLStreamReader walker = new XMLStreamReader(FileResource.open(XMLStreamReaderTest.class, xml));\r
- TreeEvent e = null;\r
- HashMap<String, String> data = new HashMap<String, String>();\r
- while ((e = walker.next()) != null)\r
- {\r
- _logger.debug(e);\r
- if (e.isVisit() || e.isText())\r
- data.put(e.nodeName, e.nodeValue);\r
-\r
- }\r
- return data;\r
-\r
- }\r
-\r
- @Test\r
- public void testParse() throws Exception\r
- {\r
- HashMap<String, String> data = parse("../bean/skip.xml");\r
-\r
- assertEquals("Will ship internationally, See description for charges", data.get("shipping"));\r
- assertEquals("page", data.get("text"));\r
- assertNull(data.get("item"));\r
- }\r
-\r
- @Test\r
- public void testSimple() throws Exception\r
- {\r
- HashMap<String, String> data = parse("simple.xml");\r
-\r
- assertEquals("Leo", data.get("author"));\r
- assertEquals("Hello World! Nice to meet you", data.get("wiki"));\r
-\r
- }\r
-\r
-}\r