You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commons-dev@ws.apache.org by ve...@apache.org on 2010/08/30 23:25:54 UTC

svn commit: r990949 - in /webservices/commons/trunk/modules/axiom/modules/axiom-staxdialect-tests/src/test: java/org/apache/axiom/util/stax/dialect/ resources/org/apache/axiom/util/stax/dialect/

Author: veithen
Date: Mon Aug 30 21:25:54 2010
New Revision: 990949

URL: http://svn.apache.org/viewvc?rev=990949&view=rev
Log:
Added some more dialect test cases.

Added:
    webservices/commons/trunk/modules/axiom/modules/axiom-staxdialect-tests/src/test/java/org/apache/axiom/util/stax/dialect/CreateXMLEventWriterWithNullEncodingTestCase.java   (with props)
    webservices/commons/trunk/modules/axiom/modules/axiom-staxdialect-tests/src/test/java/org/apache/axiom/util/stax/dialect/MaskedNamespaceTestCase.java   (with props)
    webservices/commons/trunk/modules/axiom/modules/axiom-staxdialect-tests/src/test/resources/org/apache/axiom/util/stax/dialect/masked_namespace.xml   (with props)
Modified:
    webservices/commons/trunk/modules/axiom/modules/axiom-staxdialect-tests/src/test/java/org/apache/axiom/util/stax/dialect/DialectTest.java

Added: webservices/commons/trunk/modules/axiom/modules/axiom-staxdialect-tests/src/test/java/org/apache/axiom/util/stax/dialect/CreateXMLEventWriterWithNullEncodingTestCase.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-staxdialect-tests/src/test/java/org/apache/axiom/util/stax/dialect/CreateXMLEventWriterWithNullEncodingTestCase.java?rev=990949&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-staxdialect-tests/src/test/java/org/apache/axiom/util/stax/dialect/CreateXMLEventWriterWithNullEncodingTestCase.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-staxdialect-tests/src/test/java/org/apache/axiom/util/stax/dialect/CreateXMLEventWriterWithNullEncodingTestCase.java Mon Aug 30 21:25:54 2010
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.axiom.util.stax.dialect;
+
+import javax.xml.stream.XMLOutputFactory;
+
+public class CreateXMLEventWriterWithNullEncodingTestCase extends DialectTestCase {
+    protected void runTest() throws Throwable {
+        XMLOutputFactory factory = newNormalizedXMLOutputFactory();
+        // This should cause an exception
+        try {
+            factory.createXMLEventWriter(System.out, null);
+        } catch (Throwable ex) {
+            // Expected
+            return;
+        }
+        // Attention here: since the fail method works by throwing an exception and we
+        // catch Throwable, it must be invoked outside of the catch block!
+        fail("Expected createXMLEventWriter to throw an exception");
+    }
+}

Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-staxdialect-tests/src/test/java/org/apache/axiom/util/stax/dialect/CreateXMLEventWriterWithNullEncodingTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-staxdialect-tests/src/test/java/org/apache/axiom/util/stax/dialect/DialectTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-staxdialect-tests/src/test/java/org/apache/axiom/util/stax/dialect/DialectTest.java?rev=990949&r1=990948&r2=990949&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-staxdialect-tests/src/test/java/org/apache/axiom/util/stax/dialect/DialectTest.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-staxdialect-tests/src/test/java/org/apache/axiom/util/stax/dialect/DialectTest.java Mon Aug 30 21:25:54 2010
@@ -35,6 +35,7 @@ public class DialectTest extends TestSui
         super(name);
         this.classLoader = classLoader;
         this.props = props;
+        addDialectTest(new CreateXMLEventWriterWithNullEncodingTestCase());
         addDialectTest(new CreateXMLStreamWriterWithNullEncodingTestCase());
         addDialectTest(new DisallowDoctypeDeclWithDenialOfServiceTestCase());
         addDialectTest(new DisallowDoctypeDeclWithExternalSubsetTestCase());
@@ -44,6 +45,7 @@ public class DialectTest extends TestSui
         addDialectTest(new GetVersionTestCase());
         addDialectTest(new IsCharactersOnCDATASectionTestCase());
         addDialectTest(new IsStandaloneTestCase());
+        addDialectTest(new MaskedNamespaceTestCase());
         addDialectTest(new StandaloneSetTestCase());
         addDialectTest(new WriteStartDocumentWithNullEncodingTestCase());
     }

Added: webservices/commons/trunk/modules/axiom/modules/axiom-staxdialect-tests/src/test/java/org/apache/axiom/util/stax/dialect/MaskedNamespaceTestCase.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-staxdialect-tests/src/test/java/org/apache/axiom/util/stax/dialect/MaskedNamespaceTestCase.java?rev=990949&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-staxdialect-tests/src/test/java/org/apache/axiom/util/stax/dialect/MaskedNamespaceTestCase.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-staxdialect-tests/src/test/java/org/apache/axiom/util/stax/dialect/MaskedNamespaceTestCase.java Mon Aug 30 21:25:54 2010
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.axiom.util.stax.dialect;
+
+import javax.xml.namespace.NamespaceContext;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamReader;
+
+public class MaskedNamespaceTestCase extends DialectTestCase {
+    protected void runTest() throws Throwable {
+        XMLInputFactory factory = newNormalizedXMLInputFactory();
+        XMLStreamReader reader = factory.createXMLStreamReader(
+                MaskedNamespaceTestCase.class.getResourceAsStream("masked_namespace.xml"));
+        reader.nextTag();
+        reader.nextTag();
+        assertEquals(XMLStreamReader.START_ELEMENT, reader.getEventType());
+        NamespaceContext nc = reader.getNamespaceContext();
+        assertEquals("urn:ns2", nc.getNamespaceURI("p"));
+        assertNull(nc.getPrefix("urn:ns1"));
+        assertFalse(nc.getPrefixes("urn:ns1").hasNext());
+    }
+}

Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-staxdialect-tests/src/test/java/org/apache/axiom/util/stax/dialect/MaskedNamespaceTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: webservices/commons/trunk/modules/axiom/modules/axiom-staxdialect-tests/src/test/resources/org/apache/axiom/util/stax/dialect/masked_namespace.xml
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-staxdialect-tests/src/test/resources/org/apache/axiom/util/stax/dialect/masked_namespace.xml?rev=990949&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-staxdialect-tests/src/test/resources/org/apache/axiom/util/stax/dialect/masked_namespace.xml (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-staxdialect-tests/src/test/resources/org/apache/axiom/util/stax/dialect/masked_namespace.xml Mon Aug 30 21:25:54 2010
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding ="UTF-8"?>
+<p:a xmlns:p="urn:ns1">
+    <p:b xmlns:p="urn:ns2"/>
+</p:a>
\ No newline at end of file

Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-staxdialect-tests/src/test/resources/org/apache/axiom/util/stax/dialect/masked_namespace.xml
------------------------------------------------------------------------------
    svn:eol-style = native