Author: veithen
Date: Sun Aug 29 21:13:46 2010
New Revision: 990654

URL: http://svn.apache.org/viewvc?rev=990654&view=rev
Log:
Migrated existing dialect test cases to the new axiom-staxdialect-tests module 
so that we easily test different StAX implementations.

Added:
    
webservices/commons/trunk/modules/axiom/modules/axiom-staxdialect-tests/src/test/java/org/apache/axiom/util/stax/dialect/CreateXMLStreamWriterWithNullEncodingTestCase.java
   (with props)
    
webservices/commons/trunk/modules/axiom/modules/axiom-staxdialect-tests/src/test/java/org/apache/axiom/util/stax/dialect/DisallowDoctypeDeclWithDenialOfServiceTestCase.java
   (with props)
    
webservices/commons/trunk/modules/axiom/modules/axiom-staxdialect-tests/src/test/java/org/apache/axiom/util/stax/dialect/DisallowDoctypeDeclWithExternalSubsetTestCase.java
   (with props)
    
webservices/commons/trunk/modules/axiom/modules/axiom-staxdialect-tests/src/test/java/org/apache/axiom/util/stax/dialect/DisallowDoctypeDeclWithInternalSubsetTestCase.java
   (with props)
    
webservices/commons/trunk/modules/axiom/modules/axiom-staxdialect-tests/src/test/java/org/apache/axiom/util/stax/dialect/DummyHTTPServer.java
      - copied unchanged from r990637, 
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/util/stax/dialect/DummyHTTPServer.java
    
webservices/commons/trunk/modules/axiom/modules/axiom-staxdialect-tests/src/test/java/org/apache/axiom/util/stax/dialect/GetCharacterEncodingSchemeTestCase.java
   (with props)
    
webservices/commons/trunk/modules/axiom/modules/axiom-staxdialect-tests/src/test/java/org/apache/axiom/util/stax/dialect/GetEncodingTestCase.java
   (with props)
    
webservices/commons/trunk/modules/axiom/modules/axiom-staxdialect-tests/src/test/java/org/apache/axiom/util/stax/dialect/GetVersionTestCase.java
   (with props)
    
webservices/commons/trunk/modules/axiom/modules/axiom-staxdialect-tests/src/test/java/org/apache/axiom/util/stax/dialect/IsStandaloneTestCase.java
   (with props)
    
webservices/commons/trunk/modules/axiom/modules/axiom-staxdialect-tests/src/test/java/org/apache/axiom/util/stax/dialect/StandaloneSetTestCase.java
   (with props)
    
webservices/commons/trunk/modules/axiom/modules/axiom-staxdialect-tests/src/test/java/org/apache/axiom/util/stax/dialect/WriteStartDocumentWithNullEncodingTestCase.java
   (with props)
    
webservices/commons/trunk/modules/axiom/modules/axiom-staxdialect-tests/src/test/resources/org/
      - copied from r990637, 
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/resources/org/
Removed:
    
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/util/stax/dialect/
    
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/resources/org/
Modified:
    
webservices/commons/trunk/modules/axiom/modules/axiom-staxdialect-tests/src/test/java/org/apache/axiom/util/stax/dialect/DialectTest.java
    
webservices/commons/trunk/modules/axiom/modules/axiom-staxdialect-tests/src/test/java/org/apache/axiom/util/stax/dialect/DialectTestCase.java

Added: 
webservices/commons/trunk/modules/axiom/modules/axiom-staxdialect-tests/src/test/java/org/apache/axiom/util/stax/dialect/CreateXMLStreamWriterWithNullEncodingTestCase.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/CreateXMLStreamWriterWithNullEncodingTestCase.java?rev=990654&view=auto
==============================================================================
--- 
webservices/commons/trunk/modules/axiom/modules/axiom-staxdialect-tests/src/test/java/org/apache/axiom/util/stax/dialect/CreateXMLStreamWriterWithNullEncodingTestCase.java
 (added)
+++ 
webservices/commons/trunk/modules/axiom/modules/axiom-staxdialect-tests/src/test/java/org/apache/axiom/util/stax/dialect/CreateXMLStreamWriterWithNullEncodingTestCase.java
 Sun Aug 29 21:13:46 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 CreateXMLStreamWriterWithNullEncodingTestCase extends 
DialectTestCase {
+    protected void runTest() throws Throwable {
+        XMLOutputFactory factory = newNormalizedXMLOutputFactory();
+        // This should cause an exception
+        try {
+            factory.createXMLStreamWriter(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 createXMLStreamWriter to throw an exception");
+    }
+}

Propchange: 
webservices/commons/trunk/modules/axiom/modules/axiom-staxdialect-tests/src/test/java/org/apache/axiom/util/stax/dialect/CreateXMLStreamWriterWithNullEncodingTestCase.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=990654&r1=990653&r2=990654&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
 Sun Aug 29 21:13:46 2010
@@ -22,6 +22,7 @@ import java.util.Properties;
 
 import javax.xml.stream.FactoryConfigurationError;
 import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLOutputFactory;
 
 import junit.framework.TestSuite;
 
@@ -34,7 +35,17 @@ public class DialectTest extends TestSui
         super(name);
         this.classLoader = classLoader;
         this.props = props;
+        addDialectTest(new CreateXMLStreamWriterWithNullEncodingTestCase());
+        addDialectTest(new DisallowDoctypeDeclWithDenialOfServiceTestCase());
+        addDialectTest(new DisallowDoctypeDeclWithExternalSubsetTestCase());
+        addDialectTest(new DisallowDoctypeDeclWithInternalSubsetTestCase());
+        addDialectTest(new GetCharacterEncodingSchemeTestCase());
+        addDialectTest(new GetEncodingTestCase());
+        addDialectTest(new GetVersionTestCase());
         addDialectTest(new IsCharactersOnCDATASectionTestCase());
+        addDialectTest(new IsStandaloneTestCase());
+        addDialectTest(new StandaloneSetTestCase());
+        addDialectTest(new WriteStartDocumentWithNullEncodingTestCase());
     }
     
     private void addDialectTest(DialectTestCase testCase) {
@@ -72,4 +83,39 @@ public class DialectTest extends TestSui
         }
         return dialect.normalize(factory);
     }
+
+    XMLOutputFactory newXMLOutputFactory() {
+        String className = props == null ? null : 
props.getProperty(XMLOutputFactory.class.getName());
+        if (className == null) {
+            ClassLoader savedClassLoader = 
Thread.currentThread().getContextClassLoader();
+            Thread.currentThread().setContextClassLoader(classLoader);
+            try {
+                XMLOutputFactory factory = XMLOutputFactory.newInstance();
+                if (factory.getClass().getClassLoader() != classLoader) {
+                    throw new FactoryConfigurationError("Wrong factory!");
+                }
+                return factory;
+            } finally {
+                Thread.currentThread().setContextClassLoader(savedClassLoader);
+            }
+        } else {
+            try {
+                return 
(XMLOutputFactory)classLoader.loadClass(className).newInstance();
+            } catch (Exception ex) {
+                throw new FactoryConfigurationError(ex);
+            }
+        }
+    }
+    
+    XMLOutputFactory newNormalizedXMLOutputFactory() {
+        XMLOutputFactory factory = newXMLOutputFactory();
+        if (dialect == null) {
+            dialect = StAXDialectDetector.getDialect(factory.getClass());
+        }
+        return dialect.normalize(factory);
+    }
+    
+    StAXDialect getDialect() {
+        return dialect;
+    }
 }

Modified: 
webservices/commons/trunk/modules/axiom/modules/axiom-staxdialect-tests/src/test/java/org/apache/axiom/util/stax/dialect/DialectTestCase.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/DialectTestCase.java?rev=990654&r1=990653&r2=990654&view=diff
==============================================================================
--- 
webservices/commons/trunk/modules/axiom/modules/axiom-staxdialect-tests/src/test/java/org/apache/axiom/util/stax/dialect/DialectTestCase.java
 (original)
+++ 
webservices/commons/trunk/modules/axiom/modules/axiom-staxdialect-tests/src/test/java/org/apache/axiom/util/stax/dialect/DialectTestCase.java
 Sun Aug 29 21:13:46 2010
@@ -19,6 +19,7 @@
 package org.apache.axiom.util.stax.dialect;
 
 import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLOutputFactory;
 
 import junit.framework.TestCase;
 
@@ -33,4 +34,12 @@ public abstract class DialectTestCase ex
     protected XMLInputFactory newNormalizedXMLInputFactory() {
         return test.newNormalizedXMLInputFactory();
     }
+    
+    protected XMLOutputFactory newNormalizedXMLOutputFactory() {
+        return test.newNormalizedXMLOutputFactory();
+    }
+    
+    protected StAXDialect getDialect() {
+        return test.getDialect();
+    }
 }

Added: 
webservices/commons/trunk/modules/axiom/modules/axiom-staxdialect-tests/src/test/java/org/apache/axiom/util/stax/dialect/DisallowDoctypeDeclWithDenialOfServiceTestCase.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/DisallowDoctypeDeclWithDenialOfServiceTestCase.java?rev=990654&view=auto
==============================================================================
--- 
webservices/commons/trunk/modules/axiom/modules/axiom-staxdialect-tests/src/test/java/org/apache/axiom/util/stax/dialect/DisallowDoctypeDeclWithDenialOfServiceTestCase.java
 (added)
+++ 
webservices/commons/trunk/modules/axiom/modules/axiom-staxdialect-tests/src/test/java/org/apache/axiom/util/stax/dialect/DisallowDoctypeDeclWithDenialOfServiceTestCase.java
 Sun Aug 29 21:13:46 2010
@@ -0,0 +1,58 @@
+/*
+ * 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 java.io.InputStream;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+public class DisallowDoctypeDeclWithDenialOfServiceTestCase extends 
DialectTestCase {
+    protected void runTest() throws Throwable {
+        XMLInputFactory factory = newNormalizedXMLInputFactory();
+        factory = getDialect().disallowDoctypeDecl(factory);
+        InputStream in = 
DisallowDoctypeDeclWithDenialOfServiceTestCase.class.getResourceAsStream("doctype_dos.xml");
+        try {
+            boolean gotException = false;
+            boolean reachedDocumentElement = false;
+            try {
+                XMLStreamReader reader = factory.createXMLStreamReader(in);
+                try {
+                    while (reader.hasNext()) {
+                        if (reader.next() == XMLStreamConstants.START_ELEMENT) 
{
+                            reachedDocumentElement = true;
+                        }
+                    }
+                } finally {
+                    reader.close();
+                }
+            } catch (XMLStreamException ex) {
+                gotException = true;
+            } catch (RuntimeException ex) {
+                gotException = true;
+            }
+            assertTrue("Expected exception", gotException);
+            assertFalse("The parser failed to throw an exception before 
reaching the document element", reachedDocumentElement);
+        } finally {
+            in.close();
+        }
+    }
+}

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

Added: 
webservices/commons/trunk/modules/axiom/modules/axiom-staxdialect-tests/src/test/java/org/apache/axiom/util/stax/dialect/DisallowDoctypeDeclWithExternalSubsetTestCase.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/DisallowDoctypeDeclWithExternalSubsetTestCase.java?rev=990654&view=auto
==============================================================================
--- 
webservices/commons/trunk/modules/axiom/modules/axiom-staxdialect-tests/src/test/java/org/apache/axiom/util/stax/dialect/DisallowDoctypeDeclWithExternalSubsetTestCase.java
 (added)
+++ 
webservices/commons/trunk/modules/axiom/modules/axiom-staxdialect-tests/src/test/java/org/apache/axiom/util/stax/dialect/DisallowDoctypeDeclWithExternalSubsetTestCase.java
 Sun Aug 29 21:13:46 2010
@@ -0,0 +1,62 @@
+/*
+ * 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 java.io.StringReader;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+public class DisallowDoctypeDeclWithExternalSubsetTestCase extends 
DialectTestCase {
+    protected void runTest() throws Throwable {
+        XMLInputFactory factory = newNormalizedXMLInputFactory();
+        factory = getDialect().disallowDoctypeDecl(factory);
+        DummyHTTPServer server = new DummyHTTPServer();
+        server.start();
+        try {
+            boolean gotException = false;
+            boolean reachedDocumentElement = false;
+            try {
+                XMLStreamReader reader = factory.createXMLStreamReader(new 
StringReader(
+                        "<?xml version='1.0'?><!DOCTYPE root SYSTEM '" + 
server.getBaseURL() +
+                        "dummy.dtd'><root/>"));
+                try {
+                    while (reader.hasNext()) {
+                        if (reader.next() == XMLStreamConstants.START_ELEMENT) 
{
+                            reachedDocumentElement = true;
+                        }
+                    }
+                } finally {
+                    reader.close();
+                }
+            } catch (XMLStreamException ex) {
+                gotException = true;
+            } catch (RuntimeException ex) {
+                gotException = true;
+            }
+            assertTrue("Expected exception", gotException);
+            assertFalse("The parser tried to load external DTD subset", 
server.isRequestReceived());
+            assertFalse("The parser failed to throw an exception before 
reaching the document element", reachedDocumentElement);
+        } finally {
+            server.stop();
+        }
+    }
+}

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

Added: 
webservices/commons/trunk/modules/axiom/modules/axiom-staxdialect-tests/src/test/java/org/apache/axiom/util/stax/dialect/DisallowDoctypeDeclWithInternalSubsetTestCase.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/DisallowDoctypeDeclWithInternalSubsetTestCase.java?rev=990654&view=auto
==============================================================================
--- 
webservices/commons/trunk/modules/axiom/modules/axiom-staxdialect-tests/src/test/java/org/apache/axiom/util/stax/dialect/DisallowDoctypeDeclWithInternalSubsetTestCase.java
 (added)
+++ 
webservices/commons/trunk/modules/axiom/modules/axiom-staxdialect-tests/src/test/java/org/apache/axiom/util/stax/dialect/DisallowDoctypeDeclWithInternalSubsetTestCase.java
 Sun Aug 29 21:13:46 2010
@@ -0,0 +1,54 @@
+/*
+ * 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 java.io.StringReader;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+public class DisallowDoctypeDeclWithInternalSubsetTestCase extends 
DialectTestCase {
+    protected void runTest() throws Throwable {
+        XMLInputFactory factory = newNormalizedXMLInputFactory();
+        factory = getDialect().disallowDoctypeDecl(factory);
+        boolean gotException = false;
+        boolean reachedDocumentElement = false;
+        try {
+            XMLStreamReader reader = factory.createXMLStreamReader(new 
StringReader(
+                    "<?xml version='1.0'?><!DOCTYPE root []><root/>"));
+            try {
+                while (reader.hasNext()) {
+                    if (reader.next() == XMLStreamConstants.START_ELEMENT) {
+                        reachedDocumentElement = true;
+                    }
+                }
+            } finally {
+                reader.close();
+            }
+        } catch (XMLStreamException ex) {
+            gotException = true;
+        } catch (RuntimeException ex) {
+            gotException = true;
+        }
+        assertTrue("Expected exception", gotException);
+        assertFalse("The parser failed to throw an exception before reaching 
the document element", reachedDocumentElement);
+    }
+}

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

Added: 
webservices/commons/trunk/modules/axiom/modules/axiom-staxdialect-tests/src/test/java/org/apache/axiom/util/stax/dialect/GetCharacterEncodingSchemeTestCase.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/GetCharacterEncodingSchemeTestCase.java?rev=990654&view=auto
==============================================================================
--- 
webservices/commons/trunk/modules/axiom/modules/axiom-staxdialect-tests/src/test/java/org/apache/axiom/util/stax/dialect/GetCharacterEncodingSchemeTestCase.java
 (added)
+++ 
webservices/commons/trunk/modules/axiom/modules/axiom-staxdialect-tests/src/test/java/org/apache/axiom/util/stax/dialect/GetCharacterEncodingSchemeTestCase.java
 Sun Aug 29 21:13:46 2010
@@ -0,0 +1,41 @@
+/*
+ * 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 java.io.ByteArrayInputStream;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamReader;
+
+public class GetCharacterEncodingSchemeTestCase extends DialectTestCase {
+    protected void runTest() throws Throwable {
+        XMLInputFactory factory = newNormalizedXMLInputFactory();
+        XMLStreamReader reader = factory.createXMLStreamReader(new 
ByteArrayInputStream(
+                "<?xml version='1.0' 
encoding='iso-8859-15'?><root/>".getBytes("iso-8859-15")));
+        assertEquals("iso-8859-15", reader.getCharacterEncodingScheme());
+        reader.next();
+        try {
+            reader.getCharacterEncodingScheme();
+            fail("Expected IllegalStateException");
+        } catch (IllegalStateException ex) {
+            // Expected
+        }
+        reader.close();
+    }
+}

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

Added: 
webservices/commons/trunk/modules/axiom/modules/axiom-staxdialect-tests/src/test/java/org/apache/axiom/util/stax/dialect/GetEncodingTestCase.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/GetEncodingTestCase.java?rev=990654&view=auto
==============================================================================
--- 
webservices/commons/trunk/modules/axiom/modules/axiom-staxdialect-tests/src/test/java/org/apache/axiom/util/stax/dialect/GetEncodingTestCase.java
 (added)
+++ 
webservices/commons/trunk/modules/axiom/modules/axiom-staxdialect-tests/src/test/java/org/apache/axiom/util/stax/dialect/GetEncodingTestCase.java
 Sun Aug 29 21:13:46 2010
@@ -0,0 +1,41 @@
+/*
+ * 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 java.io.ByteArrayInputStream;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamReader;
+
+public class GetEncodingTestCase extends DialectTestCase {
+    protected void runTest() throws Throwable {
+        XMLInputFactory factory = newNormalizedXMLInputFactory();
+        XMLStreamReader reader = factory.createXMLStreamReader(new 
ByteArrayInputStream(
+                "<?xml version='1.0' 
encoding='iso-8859-15'?><root/>".getBytes("iso-8859-15")));
+        assertEquals("iso-8859-15", reader.getEncoding());
+        reader.next();
+        try {
+            reader.getEncoding();
+            fail("Expected IllegalStateException");
+        } catch (IllegalStateException ex) {
+            // Expected
+        }
+        reader.close();
+    }
+}

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

Added: 
webservices/commons/trunk/modules/axiom/modules/axiom-staxdialect-tests/src/test/java/org/apache/axiom/util/stax/dialect/GetVersionTestCase.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/GetVersionTestCase.java?rev=990654&view=auto
==============================================================================
--- 
webservices/commons/trunk/modules/axiom/modules/axiom-staxdialect-tests/src/test/java/org/apache/axiom/util/stax/dialect/GetVersionTestCase.java
 (added)
+++ 
webservices/commons/trunk/modules/axiom/modules/axiom-staxdialect-tests/src/test/java/org/apache/axiom/util/stax/dialect/GetVersionTestCase.java
 Sun Aug 29 21:13:46 2010
@@ -0,0 +1,41 @@
+/*
+ * 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 java.io.StringReader;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamReader;
+
+public class GetVersionTestCase extends DialectTestCase {
+    protected void runTest() throws Throwable {
+        XMLInputFactory factory = newNormalizedXMLInputFactory();
+        XMLStreamReader reader = factory.createXMLStreamReader(
+                new StringReader("<?xml version='1.0'?><root/>"));
+        assertEquals("1.0", reader.getVersion());
+        reader.next();
+        try {
+            reader.getVersion();
+            fail("Expected IllegalStateException");
+        } catch (IllegalStateException ex) {
+            // Expected
+        }
+        reader.close();
+    }
+}

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

Added: 
webservices/commons/trunk/modules/axiom/modules/axiom-staxdialect-tests/src/test/java/org/apache/axiom/util/stax/dialect/IsStandaloneTestCase.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/IsStandaloneTestCase.java?rev=990654&view=auto
==============================================================================
--- 
webservices/commons/trunk/modules/axiom/modules/axiom-staxdialect-tests/src/test/java/org/apache/axiom/util/stax/dialect/IsStandaloneTestCase.java
 (added)
+++ 
webservices/commons/trunk/modules/axiom/modules/axiom-staxdialect-tests/src/test/java/org/apache/axiom/util/stax/dialect/IsStandaloneTestCase.java
 Sun Aug 29 21:13:46 2010
@@ -0,0 +1,41 @@
+/*
+ * 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 java.io.StringReader;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamReader;
+
+public class IsStandaloneTestCase extends DialectTestCase {
+    protected void runTest() throws Throwable {
+        XMLInputFactory factory = newNormalizedXMLInputFactory();
+        XMLStreamReader reader = factory.createXMLStreamReader(
+                new StringReader("<?xml version='1.0' 
standalone='no'?><root/>"));
+        assertEquals(false, reader.isStandalone());
+        reader.next();
+        try {
+            reader.isStandalone();
+            fail("Expected IllegalStateException");
+        } catch (IllegalStateException ex) {
+            // Expected
+        }
+        reader.close();
+    }
+}

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

Added: 
webservices/commons/trunk/modules/axiom/modules/axiom-staxdialect-tests/src/test/java/org/apache/axiom/util/stax/dialect/StandaloneSetTestCase.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/StandaloneSetTestCase.java?rev=990654&view=auto
==============================================================================
--- 
webservices/commons/trunk/modules/axiom/modules/axiom-staxdialect-tests/src/test/java/org/apache/axiom/util/stax/dialect/StandaloneSetTestCase.java
 (added)
+++ 
webservices/commons/trunk/modules/axiom/modules/axiom-staxdialect-tests/src/test/java/org/apache/axiom/util/stax/dialect/StandaloneSetTestCase.java
 Sun Aug 29 21:13:46 2010
@@ -0,0 +1,41 @@
+/*
+ * 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 java.io.StringReader;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamReader;
+
+public class StandaloneSetTestCase extends DialectTestCase {
+    protected void runTest() throws Throwable {
+        XMLInputFactory factory = newNormalizedXMLInputFactory();
+        XMLStreamReader reader = factory.createXMLStreamReader(
+                new StringReader("<?xml version='1.0'?><root/>"));
+        assertEquals(false, reader.standaloneSet());
+        reader.next();
+        try {
+            reader.standaloneSet();
+            fail("Expected IllegalStateException");
+        } catch (IllegalStateException ex) {
+            // Expected
+        }
+        reader.close();
+    }
+}

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

Added: 
webservices/commons/trunk/modules/axiom/modules/axiom-staxdialect-tests/src/test/java/org/apache/axiom/util/stax/dialect/WriteStartDocumentWithNullEncodingTestCase.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/WriteStartDocumentWithNullEncodingTestCase.java?rev=990654&view=auto
==============================================================================
--- 
webservices/commons/trunk/modules/axiom/modules/axiom-staxdialect-tests/src/test/java/org/apache/axiom/util/stax/dialect/WriteStartDocumentWithNullEncodingTestCase.java
 (added)
+++ 
webservices/commons/trunk/modules/axiom/modules/axiom-staxdialect-tests/src/test/java/org/apache/axiom/util/stax/dialect/WriteStartDocumentWithNullEncodingTestCase.java
 Sun Aug 29 21:13:46 2010
@@ -0,0 +1,34 @@
+/*
+ * 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.XMLStreamWriter;
+
+public class WriteStartDocumentWithNullEncodingTestCase extends 
DialectTestCase {
+    protected void runTest() throws Throwable {
+        XMLStreamWriter writer = 
newNormalizedXMLOutputFactory().createXMLStreamWriter(System.out, "UTF-8");
+        try {
+            writer.writeStartDocument(null, "1.0");
+        } catch (Throwable ex) {
+            // Expected
+            return;
+        }
+        fail("Expected writeStartDocument to throw an exception");
+    }
+}

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


Reply via email to