ws-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From veit...@apache.org
Subject svn commit: r1201241 - in /webservices/commons/trunk/modules/axiom/modules: axiom-api/src/main/java/org/apache/axiom/om/ axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/ axiom-testutils/src/main/java/org/apache/axiom/testutils/io/
Date Sat, 12 Nov 2011 10:16:13 GMT
Author: veithen
Date: Sat Nov 12 10:16:11 2011
New Revision: 1201241

URL: http://svn.apache.org/viewvc?rev=1201241&view=rev
Log:
Clarified some details of the OMElement#writeTextTo API.

Added:
    webservices/commons/trunk/modules/axiom/modules/axiom-testutils/src/main/java/org/apache/axiom/testutils/io/CloseSensorWriter.java
  (with props)
Modified:
    webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMElement.java
    webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestWriteTextTo.java

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMElement.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMElement.java?rev=1201241&r1=1201240&r2=1201241&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMElement.java
(original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMElement.java
Sat Nov 12 10:16:11 2011
@@ -438,10 +438,11 @@ public interface OMElement extends OMNod
      * <pre>out.write(element.getText())</pre>
      * <p>
      * The difference is that this method is guaranteed to have constant memory usage and
is
-     * optimized for performance.
+     * optimized for performance (with the same restrictions that apply to
+     * {@link #getTextAsStream(boolean)}).
+     * <p>
+     * The method does <b>not</b> call {@link Writer#close()}.
      * 
-     * @param element
-     *            the element to read the text nodes from
      * @param out
      *            the stream to write the content to
      * @param cache

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestWriteTextTo.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestWriteTextTo.java?rev=1201241&r1=1201240&r2=1201241&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestWriteTextTo.java
(original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestWriteTextTo.java
Sat Nov 12 10:16:11 2011
@@ -19,14 +19,22 @@
 package org.apache.axiom.ts.om.element;
 
 import java.io.StringWriter;
+import java.io.Writer;
 
 import javax.xml.namespace.QName;
 
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMFactory;
 import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.om.OMText;
+import org.apache.axiom.testutils.io.CloseSensorWriter;
 import org.apache.axiom.ts.AxiomTestCase;
 
+/**
+ * Tests the behavior of {@link OMElement#writeTextTo(Writer, boolean)} in the simple case
with a
+ * single {@link OMText} child. The test case also checks that the method doesn't call
+ * {@link Writer#close()}.
+ */
 public class TestWriteTextTo extends AxiomTestCase {
     public TestWriteTextTo(OMMetaFactory metaFactory) {
         super(metaFactory);
@@ -36,8 +44,10 @@ public class TestWriteTextTo extends Axi
         OMFactory factory = metaFactory.getOMFactory();
         OMElement element = factory.createOMElement(new QName("a"));
         factory.createOMText(element, "test");
-        StringWriter out = new StringWriter();
+        StringWriter sw = new StringWriter();
+        CloseSensorWriter out = new CloseSensorWriter(sw);
         element.writeTextTo(out, true);
-        assertEquals(element.getText(), out.toString());
+        assertEquals(element.getText(), sw.toString());
+        assertFalse(out.isClosed());
     }
 }

Added: webservices/commons/trunk/modules/axiom/modules/axiom-testutils/src/main/java/org/apache/axiom/testutils/io/CloseSensorWriter.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testutils/src/main/java/org/apache/axiom/testutils/io/CloseSensorWriter.java?rev=1201241&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testutils/src/main/java/org/apache/axiom/testutils/io/CloseSensorWriter.java
(added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testutils/src/main/java/org/apache/axiom/testutils/io/CloseSensorWriter.java
Sat Nov 12 10:16:11 2011
@@ -0,0 +1,44 @@
+/*
+ * 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.testutils.io;
+
+import java.io.IOException;
+import java.io.Writer;
+
+import org.apache.commons.io.output.ProxyWriter;
+
+/**
+ * {@link Writer} wrapper that remembers if {@link Writer#close()} has been called.
+ */
+public class CloseSensorWriter extends ProxyWriter {
+    private boolean closed;
+    
+    public CloseSensorWriter(Writer parent) {
+        super(parent);
+    }
+
+    public void close() throws IOException {
+        closed = true;
+        super.close();
+    }
+
+    public boolean isClosed() {
+        return closed;
+    }
+}

Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-testutils/src/main/java/org/apache/axiom/testutils/io/CloseSensorWriter.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message