You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@excalibur.apache.org by cz...@apache.org on 2004/06/21 14:42:19 UTC
svn commit: rev 21536 - excalibur/trunk/xmlutil/src/test/org/apache/excalibur/xml/dom/test
Author: cziegeler
Date: Mon Jun 21 05:42:18 2004
New Revision: 21536
Added:
excalibur/trunk/xmlutil/src/test/org/apache/excalibur/xml/dom/test/DefaultDOMParserTestCase.java
excalibur/trunk/xmlutil/src/test/org/apache/excalibur/xml/dom/test/DefaultDOMParserTestCase.xtest
Log:
Add a new test case for DOMParser
Added: excalibur/trunk/xmlutil/src/test/org/apache/excalibur/xml/dom/test/DefaultDOMParserTestCase.java
==============================================================================
--- (empty file)
+++ excalibur/trunk/xmlutil/src/test/org/apache/excalibur/xml/dom/test/DefaultDOMParserTestCase.java Mon Jun 21 05:42:18 2004
@@ -0,0 +1,78 @@
+/*
+ * Copyright 2002-2004 The Apache Software Foundation
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.excalibur.xml.dom.test;
+
+import java.io.StringReader;
+
+import org.apache.avalon.excalibur.testcase.ExcaliburTestCase;
+import org.apache.avalon.framework.component.ComponentException;
+import org.apache.excalibur.xml.dom.DOMParser;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.xml.sax.InputSource;
+
+/**
+ * @author <a href="mailto:dev@avalon.apache.org">Avalon Development Team</a>
+ */
+public class DefaultDOMParserTestCase extends ExcaliburTestCase
+{
+
+ private static final String CONTENT =
+ "<?xml version=\"1.0\"?>" +
+ "<test:root xmlns:test=\"http://localhost/test\">" +
+ "<test:element1/>" +
+ "<test:element2/>" +
+ "</test:root>";
+ private static final StringReader IN = new StringReader( CONTENT );
+
+ public DefaultDOMParserTestCase( String name )
+ {
+ super( name );
+ }
+
+ public void testCreateDOMHandler()
+ {
+ try
+ {
+ final DOMParser parser = (DOMParser)manager.lookup( DOMParser.ROLE );
+
+ final Document document = parser.parseDocument( new InputSource( IN ) );
+
+ final Element root = document.getDocumentElement();
+ assertEquals( "Wrong root element", "test:root", root.getNodeName() );
+ assertEquals( "Wrong namespace uri", "http://localhost/test", root.getNamespaceURI() );
+
+ final Node element1 = root.getFirstChild();
+ assertEquals( "Child is not an element", Node.ELEMENT_NODE, element1.getNodeType() );
+ assertEquals( "Wrong first element", "test:element1", element1.getNodeName() );
+
+ final Node element2 = root.getLastChild();
+ assertEquals( "Child is not an element", Node.ELEMENT_NODE, element2.getNodeType() );
+ assertEquals( "Wrong last element", "test:element2", element2.getNodeName() );
+ }
+ catch ( ComponentException e )
+ {
+ fail( "Failed to lookup components: " + e.getMessage() );
+ }
+ catch ( Exception e )
+ {
+ fail( "Failed to create handler: " + e.getMessage() );
+ }
+ }
+
+}
Added: excalibur/trunk/xmlutil/src/test/org/apache/excalibur/xml/dom/test/DefaultDOMParserTestCase.xtest
==============================================================================
--- (empty file)
+++ excalibur/trunk/xmlutil/src/test/org/apache/excalibur/xml/dom/test/DefaultDOMParserTestCase.xtest Mon Jun 21 05:42:18 2004
@@ -0,0 +1,49 @@
+<!--
+ Copyright 2002-2004 The Apache Software Foundation
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied.
+
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+<testcase>
+ <annotation><![CDATA[DOMHandler factory test
+ ]]></annotation>
+ <logkit>
+ <factories>
+ <factory type="file" class="org.apache.avalon.excalibur.logger.factory.FileTargetFactory"/>
+ </factories>
+ <targets>
+ <file id="root">
+ <filename>domparser-test.log</filename>
+ <format type="extended">
+ %7.7{priority} %5.5{time} [%8.8{category}] (%{context}): %{message}\n%{throwable}
+ </format>
+ </file>
+ </targets>
+ <categories>
+ <category name="test" log-level="DEBUG">
+ <log-target id-ref="root"/>
+ </category>
+ <category name="" log-level="DEBUG">
+ <log-target id-ref="root"/>
+ </category>
+ </categories>
+ </logkit>
+ <roles>
+ <role name="org.apache.excalibur.xml.dom.DOMParser" shorthand="parser" default-class="org.apache.excalibur.xml.impl.JaxpParser"/>
+ </roles>
+ <components>
+ <parser logger="test">
+ <parameter name="namespace-prefixes" value="true"/>
+ </parser>
+ </components>
+</testcase>
---------------------------------------------------------------------
To unsubscribe, e-mail: scm-unsubscribe@excalibur.apache.org
For additional commands, e-mail: scm-help@excalibur.apache.org