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/05/28 19:53:47 UTC
svn commit: r1487019 - in /webservices/axiom/trunk/modules:
axiom-api/src/main/java/org/apache/axiom/util/base64/
axiom-api/src/main/java/org/apache/axiom/util/stax/
axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/serializer/push/sax/
a...
Author: veithen
Date: Tue May 28 17:53:46 2013
New Revision: 1487019
URL: http://svn.apache.org/r1487019
Log:
Fixed some SAX serialization test cases.
Modified:
webservices/axiom/trunk/modules/axiom-api/src/main/java/org/apache/axiom/util/base64/AbstractBase64EncodingOutputStream.java
webservices/axiom/trunk/modules/axiom-api/src/main/java/org/apache/axiom/util/base64/Base64EncodingWriterOutputStream.java
webservices/axiom/trunk/modules/axiom-api/src/main/java/org/apache/axiom/util/stax/XMLStreamWriterUtils.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-common-impl/src/main/java/org/apache/axiom/om/impl/common/serializer/push/sax/SAXSerializer.java
webservices/axiom/trunk/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/OMImplementationTest.java
webservices/axiom/trunk/modules/axiom-impl/src/test/java/org/apache/axiom/om/impl/llom/OMImplementationTest.java
Modified: webservices/axiom/trunk/modules/axiom-api/src/main/java/org/apache/axiom/util/base64/AbstractBase64EncodingOutputStream.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-api/src/main/java/org/apache/axiom/util/base64/AbstractBase64EncodingOutputStream.java?rev=1487019&r1=1487018&r2=1487019&view=diff
==============================================================================
--- webservices/axiom/trunk/modules/axiom-api/src/main/java/org/apache/axiom/util/base64/AbstractBase64EncodingOutputStream.java (original)
+++ webservices/axiom/trunk/modules/axiom-api/src/main/java/org/apache/axiom/util/base64/AbstractBase64EncodingOutputStream.java Tue May 28 17:53:46 2013
@@ -22,15 +22,43 @@ package org.apache.axiom.util.base64;
import java.io.IOException;
import java.io.OutputStream;
+import javax.activation.DataHandler;
+
/**
* Base class for {@link OutputStream} implementations that encode data in base64.
*/
public abstract class AbstractBase64EncodingOutputStream extends OutputStream {
+ private final boolean ignoreFlush;
private final byte[] in = new byte[3];
private final byte[] out = new byte[4];
private int rest; // Number of bytes remaining in the inBuffer
private boolean completed;
+ /**
+ * Constructor.
+ *
+ * @param ignoreFlush
+ * Specifies if calls to {@link #flush()} should be ignored. Setting this to
+ * <code>true</code> is particular useful in conjunction with
+ * {@link DataHandler#writeTo(OutputStream)}: that method may call {@link #flush()}
+ * after writing the data, but the call to {@link DataHandler#writeTo(OutputStream)}
+ * must be followed by a call to {@link #close()} or {@link #complete()} which would
+ * then output a single chunk with a few bytes. In some cases this may be
+ * inconvenient.
+ */
+ public AbstractBase64EncodingOutputStream(boolean ignoreFlush) {
+ this.ignoreFlush = ignoreFlush;
+ }
+
+ /**
+ * Default constructor. This constructor does the same as
+ * {@link #AbstractBase64EncodingOutputStream(boolean)} with <code>ignoreFlush</code> set to
+ * <code>false</code>.
+ */
+ public AbstractBase64EncodingOutputStream() {
+ this(false);
+ }
+
public final void write(byte[] b, int off, int len) throws IOException {
if (completed) {
throw new IOException("Attempt to write data after base64 encoding has been completed");
@@ -105,8 +133,10 @@ public abstract class AbstractBase64Enco
}
public final void flush() throws IOException {
- flushBuffer();
- doFlush();
+ if (!ignoreFlush) {
+ flushBuffer();
+ doFlush();
+ }
}
public final void close() throws IOException {
Modified: webservices/axiom/trunk/modules/axiom-api/src/main/java/org/apache/axiom/util/base64/Base64EncodingWriterOutputStream.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-api/src/main/java/org/apache/axiom/util/base64/Base64EncodingWriterOutputStream.java?rev=1487019&r1=1487018&r2=1487019&view=diff
==============================================================================
--- webservices/axiom/trunk/modules/axiom-api/src/main/java/org/apache/axiom/util/base64/Base64EncodingWriterOutputStream.java (original)
+++ webservices/axiom/trunk/modules/axiom-api/src/main/java/org/apache/axiom/util/base64/Base64EncodingWriterOutputStream.java Tue May 28 17:53:46 2013
@@ -35,12 +35,29 @@ public class Base64EncodingWriterOutputS
/**
* Constructor.
*
+ * @param writer
+ * the stream to write the encoded data to
+ * @param bufferSize
+ * the buffer size to use
+ * @param ignoreFlush
+ * specifies if calls to {@link #flush()} should be ignored; see
+ * {@link AbstractBase64EncodingOutputStream#AbstractBase64EncodingOutputStream(boolean)}
+ * for more information
+ */
+ public Base64EncodingWriterOutputStream(Writer writer, int bufferSize, boolean ignoreFlush) {
+ super(ignoreFlush);
+ this.writer = writer;
+ buffer = new char[bufferSize];
+ }
+
+ /**
+ * Constructor.
+ *
* @param writer the stream to write the encoded data to
* @param bufferSize the buffer size to use
*/
public Base64EncodingWriterOutputStream(Writer writer, int bufferSize) {
- this.writer = writer;
- buffer = new char[bufferSize];
+ this(writer, bufferSize, false);
}
/**
@@ -49,7 +66,7 @@ public class Base64EncodingWriterOutputS
* @param writer the stream to write the encoded data to
*/
public Base64EncodingWriterOutputStream(Writer writer) {
- this(writer, 4096);
+ this(writer, 4096, false);
}
protected void doWrite(byte[] b) throws IOException {
Modified: webservices/axiom/trunk/modules/axiom-api/src/main/java/org/apache/axiom/util/stax/XMLStreamWriterUtils.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-api/src/main/java/org/apache/axiom/util/stax/XMLStreamWriterUtils.java?rev=1487019&r1=1487018&r2=1487019&view=diff
==============================================================================
--- webservices/axiom/trunk/modules/axiom-api/src/main/java/org/apache/axiom/util/stax/XMLStreamWriterUtils.java (original)
+++ webservices/axiom/trunk/modules/axiom-api/src/main/java/org/apache/axiom/util/stax/XMLStreamWriterUtils.java Tue May 28 17:53:46 2013
@@ -57,7 +57,7 @@ public class XMLStreamWriterUtils {
throws IOException, XMLStreamException {
Base64EncodingWriterOutputStream out = new Base64EncodingWriterOutputStream(
- new XMLStreamWriterWriter(writer));
+ new XMLStreamWriterWriter(writer), 4096, true);
try {
dh.writeTo(out);
out.close();
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=1487019&r1=1487018&r2=1487019&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 May 28 17:53:46 2013
@@ -211,7 +211,7 @@ final class ContentHandlerXMLStreamWrite
public void writeDataHandler(DataHandler dataHandler, String contentID, boolean optimize)
throws IOException, XMLStreamException {
finishStartElementIfNecessary();
- Base64EncodingWriterOutputStream out = new Base64EncodingWriterOutputStream(new ContentHandlerWriter(contentHandler));
+ Base64EncodingWriterOutputStream out = new Base64EncodingWriterOutputStream(new ContentHandlerWriter(contentHandler), 4096, true);
dataHandler.writeTo(out);
out.complete();
}
Modified: webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/serializer/push/sax/SAXSerializer.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/SAXSerializer.java?rev=1487019&r1=1487018&r2=1487019&view=diff
==============================================================================
--- webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/serializer/push/sax/SAXSerializer.java (original)
+++ webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/serializer/push/sax/SAXSerializer.java Tue May 28 17:53:46 2013
@@ -178,7 +178,7 @@ public class SAXSerializer extends Seria
}
public void writeDataHandler(DataHandler dataHandler, String contentID, boolean optimize) throws OutputException {
- Base64EncodingWriterOutputStream out = new Base64EncodingWriterOutputStream(new ContentHandlerWriter(contentHandler));
+ Base64EncodingWriterOutputStream out = new Base64EncodingWriterOutputStream(new ContentHandlerWriter(contentHandler), 4096, true);
try {
dataHandler.writeTo(out);
out.complete();
Modified: webservices/axiom/trunk/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/OMImplementationTest.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/OMImplementationTest.java?rev=1487019&r1=1487018&r2=1487019&view=diff
==============================================================================
--- webservices/axiom/trunk/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/OMImplementationTest.java (original)
+++ webservices/axiom/trunk/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/OMImplementationTest.java Tue May 28 17:53:46 2013
@@ -57,8 +57,6 @@ public class OMImplementationTest extend
// TODO
builder.exclude(TestSerializationWithTwoNonBuiltOMElements.class);
- // TODO: not yet working
- builder.exclude(TestGetSAXSourceWithPushOMDataSource.class, "(|(scenario=writeDataHandler)(scenario=writeDataHandlerProvider))");
// TODO: need to evaluate if the test case is correct
builder.exclude(TestGetSAXSourceWithPushOMDataSource.class, "(&(scenario=getNamespaceContext)(serializeParent=false))");
Modified: webservices/axiom/trunk/modules/axiom-impl/src/test/java/org/apache/axiom/om/impl/llom/OMImplementationTest.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-impl/src/test/java/org/apache/axiom/om/impl/llom/OMImplementationTest.java?rev=1487019&r1=1487018&r2=1487019&view=diff
==============================================================================
--- webservices/axiom/trunk/modules/axiom-impl/src/test/java/org/apache/axiom/om/impl/llom/OMImplementationTest.java (original)
+++ webservices/axiom/trunk/modules/axiom-impl/src/test/java/org/apache/axiom/om/impl/llom/OMImplementationTest.java Tue May 28 17:53:46 2013
@@ -48,8 +48,6 @@ public class OMImplementationTest extend
// TODO: if there is a comment node surrounded by text, then these text nodes need to be merged
builder.exclude(TestDigest.class, "(|(file=digest3.xml)(file=digest4.xml))");
- // TODO: not yet working
- builder.exclude(TestGetSAXSourceWithPushOMDataSource.class, "(|(scenario=writeDataHandler)(scenario=writeDataHandlerProvider))");
// TODO: need to evaluate if the test case is correct
builder.exclude(TestGetSAXSourceWithPushOMDataSource.class, "(&(scenario=getNamespaceContext)(serializeParent=false))");