You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ws.apache.org by ve...@apache.org on 2013/04/02 20:37:36 UTC
svn commit: r1463662 - in /webservices/axiom/trunk/modules:
axiom-api/src/main/java/org/apache/axiom/om/
axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/serializer/push/sax/
axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/ axiom-...
Author: veithen
Date: Tue Apr 2 18:37:35 2013
New Revision: 1463662
URL: http://svn.apache.org/r1463662
Log:
OMDataSource#serialize(XMLStreamWriter) must not call XMLStreamWriter#close().
Added:
webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/push/CloseScenario.java (with props)
Modified:
webservices/axiom/trunk/modules/axiom-api/src/main/java/org/apache/axiom/om/OMDataSource.java
webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/serializer/push/sax/ContentHandlerXMLStreamWriter.java
webservices/axiom/trunk/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/PushOMBuilder.java
webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/push/PushOMDataSourceScenario.java
Modified: webservices/axiom/trunk/modules/axiom-api/src/main/java/org/apache/axiom/om/OMDataSource.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-api/src/main/java/org/apache/axiom/om/OMDataSource.java?rev=1463662&r1=1463661&r2=1463662&view=diff
==============================================================================
--- webservices/axiom/trunk/modules/axiom-api/src/main/java/org/apache/axiom/om/OMDataSource.java (original)
+++ webservices/axiom/trunk/modules/axiom-api/src/main/java/org/apache/axiom/om/OMDataSource.java Tue Apr 2 18:37:35 2013
@@ -147,6 +147,7 @@ public interface OMDataSource {
* {@link XMLStreamWriter#writeCharacters(char[], int, int)} to write the base64 encoded data to
* the stream.
* </ul>
+ * <li>The implementation MUST NOT call {@link XMLStreamWriter#close()}.
* </ul>
* <p>
* On the other hand, the caller of this method (typically an {@link OMSourcedElement} instance)
Modified: webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/serializer/push/sax/ContentHandlerXMLStreamWriter.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/serializer/push/sax/ContentHandlerXMLStreamWriter.java?rev=1463662&r1=1463661&r2=1463662&view=diff
==============================================================================
--- webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/serializer/push/sax/ContentHandlerXMLStreamWriter.java (original)
+++ webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/serializer/push/sax/ContentHandlerXMLStreamWriter.java Tue Apr 2 18:37:35 2013
@@ -264,6 +264,7 @@ final class ContentHandlerXMLStreamWrite
}
public void close() throws XMLStreamException {
+ throw new UnsupportedOperationException("OMDataSource#serialize(XMLStreamWriter) MUST NOT call XMLStreamWriter#close()");
}
public void writeStartDocument() throws XMLStreamException {
Modified: webservices/axiom/trunk/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/PushOMBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/PushOMBuilder.java?rev=1463662&r1=1463661&r2=1463662&view=diff
==============================================================================
--- webservices/axiom/trunk/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/PushOMBuilder.java (original)
+++ webservices/axiom/trunk/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/PushOMBuilder.java Tue Apr 2 18:37:35 2013
@@ -196,7 +196,7 @@ public class PushOMBuilder extends Abstr
}
public void close() throws XMLStreamException {
- // Do nothing
+ throw new UnsupportedOperationException("OMDataSource#serialize(XMLStreamWriter) MUST NOT call XMLStreamWriter#close()");
}
public void writeDataHandler(DataHandler dataHandler, String contentID, boolean optimize)
Added: webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/push/CloseScenario.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/push/CloseScenario.java?rev=1463662&view=auto
==============================================================================
--- webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/push/CloseScenario.java (added)
+++ webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/push/CloseScenario.java Tue Apr 2 18:37:35 2013
@@ -0,0 +1,59 @@
+/*
+ * 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.ts.om.sourcedelement.push;
+
+import java.util.Collections;
+import java.util.Map;
+
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.axiom.om.OMDataSource;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.testutils.suite.MatrixTestCase;
+import org.junit.Assert;
+
+/**
+ * Scenario that calls {@link XMLStreamWriter#close()} which is forbidden by the contract of
+ * {@link OMDataSource#serialize(XMLStreamWriter)}.
+ */
+public class CloseScenario implements PushOMDataSourceScenario {
+ public void addTestParameters(MatrixTestCase testCase) {
+ testCase.addTestParameter("scenario", "close");
+ }
+
+ public Map getNamespaceContext() {
+ return Collections.EMPTY_MAP;
+ }
+
+ public void serialize(XMLStreamWriter writer) throws XMLStreamException {
+ writer.writeEmptyElement(null, "root", null);
+ try {
+ writer.close();
+ Assert.fail("Expected UnsupportedOperationException");
+ } catch (UnsupportedOperationException ex) {
+ // Expected
+ }
+ }
+
+ public void validate(OMElement element, boolean dataHandlersPreserved) throws Throwable {
+ // Just expand the element
+ element.getFirstOMChild();
+ }
+}
Propchange: webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/push/CloseScenario.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/push/PushOMDataSourceScenario.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/push/PushOMDataSourceScenario.java?rev=1463662&r1=1463661&r2=1463662&view=diff
==============================================================================
--- webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/push/PushOMDataSourceScenario.java (original)
+++ webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/push/PushOMDataSourceScenario.java Tue Apr 2 18:37:35 2013
@@ -35,6 +35,7 @@ import org.apache.axiom.testutils.suite.
*/
public interface PushOMDataSourceScenario extends Dimension {
PushOMDataSourceScenario[] INSTANCES = {
+ new CloseScenario(),
new GetNamespaceContextScenario(),
new WriteAttributeAutoPrefixScenario(),
new WriteAttributeNamespaceUnawareScenario(),