Author: veithen
Date: Sat Mar 7 16:32:06 2009
New Revision: 751290
URL: http://svn.apache.org/viewvc?rev=751290&view=rev
Log:
Added code to optimize text/plain and binary/octet-stream handling.
Added:
webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/format/ManagedDataSource.java
(with props)
webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/format/ManagedDataSourceFactory.java
(with props)
webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/format/WrappedTextNodeOMDataSource.java
(with props)
webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/format/WrappedTextNodeStreamReader.java
(contents, props changed)
- copied, changed from r750138,
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/util/WrappedTextNodeStreamReader.java
webservices/commons/trunk/modules/transport/modules/base/src/test/java/org/apache/axis2/format/ManagedDataSourceFactoryTest.java
(with props)
webservices/commons/trunk/modules/transport/modules/base/src/test/java/org/apache/axis2/format/WrappedTextNodeStreamReaderTest.java
(contents, props changed)
- copied, changed from r750138,
synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/util/WrappedTextNodeStreamReaderTest.java
Modified:
webservices/commons/trunk/modules/transport/modules/base/pom.xml
webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/format/DataSourceMessageBuilder.java
webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/format/PlainTextBuilder.java
Modified: webservices/commons/trunk/modules/transport/modules/base/pom.xml
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/transport/modules/base/pom.xml?rev=751290&r1=751289&r2=751290&view=diff
==============================================================================
--- webservices/commons/trunk/modules/transport/modules/base/pom.xml (original)
+++ webservices/commons/trunk/modules/transport/modules/base/pom.xml Sat Mar 7
16:32:06 2009
@@ -138,5 +138,11 @@
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>xmlunit</groupId>
+ <artifactId>xmlunit</artifactId>
+ <version>1.2</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
</project>
Modified:
webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/format/DataSourceMessageBuilder.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/format/DataSourceMessageBuilder.java?rev=751290&r1=751289&r2=751290&view=diff
==============================================================================
---
webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/format/DataSourceMessageBuilder.java
(original)
+++
webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/format/DataSourceMessageBuilder.java
Sat Mar 7 16:32:06 2009
@@ -37,19 +37,39 @@
* provide the message payload as a data source, then the method defined by
this
* interface should be preferred over the method defined by {...@link Builder}.
* <p>
- * When a message builder is invoked through the basic {...@link Builder}
interface,
- * it is the responsibility of the transport to close the input stream once the
- * message has been processed, and the builder is not required to consume the
input
- * stream immediately. On the other hand, when the builder is invoked through
this extension
- * interface, the transport is only responsible for ensuring that the
{...@link DataSource}
- * remains valid for the whole lifecycle of the message. It is the
responsibility of the
- * builder to acquire the input stream and to make sure that it is closed when
no longer
- * needed. This important difference is the reason why there is no
- * DataSourceMessageBuilderAdapter class.
- * <p>
* Implementing this interface helps optimizing message processing with
transports
* that use messaging providers that store messages in memory or on the file
system.
* Examples are JMS and VFS.
+ * <p>
+ * The builder will typically expose the data source directly or indirectly
through
+ * the returned {...@link OMElement}, e.g. by adding to the tree an {...@link
org.apache.axiom.om.OMText}
+ * or {...@link org.apache.axiom.om.OMDataSource} node referencing the data
source.
+ * This means that the builder will not be able to guarantee that all streams
requested
+ * from the data source are properly closed. Note that code accessing the
returned
+ * {...@link OMElement} can't be expected to take care of this since in many
cases the fact
+ * that a data source is being used is completely transparent to that code.
+ * It is therefore the responsibility of the transport to make sure that all
resources linked to
+ * the data source itself as well as any open stream requested from that data
source are properly
+ * released after the message has been processed. Depending on the type of
transport, there are
+ * three possible cases:
+ * <ol>
+ * <li>All resources allocated to the data source or streams requested from
it are
+ * memory based. In that case the garbage collector will take care of
freeing
+ * these resources and the transport should simply pass the data source
object
+ * to the builder.</li>
+ * <li>There are operation system resources linked to the data source and
open
+ * streams will become invalid when these resources are freed, i.e.
+ * it is not required that all streams be closed explicitly.
+ * In this case the transport only needs to take care to properly
dispose of
+ * the data source after the message has been processed by the Axis2
engine.</li>
+ * <li>Requesting a stream from the data source allocates operation system
resources
+ * (e.g. a network connection) that remain linked to the stream, i.e.
all streams requested
+ * from the data source must be closed properly. In that case the
transport should use
+ * {...@link ManagedDataSourceFactory#create(DataSource)} to wrap the
original data source
+ * before passing it to the builder. After the message has been
processed it should
+ * then call {...@link ManagedDataSource#destroy()} on the wrapper to
close all remaining
+ * open streams.</li>
+ * </ol>
*/
public interface DataSourceMessageBuilder extends Builder {
public OMElement processDocument(DataSource dataSource, String contentType,
Added:
webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/format/ManagedDataSource.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/format/ManagedDataSource.java?rev=751290&view=auto
==============================================================================
---
webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/format/ManagedDataSource.java
(added)
+++
webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/format/ManagedDataSource.java
Sat Mar 7 16:32:06 2009
@@ -0,0 +1,36 @@
+/*
+ * 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.axis2.format;
+
+import javax.activation.DataSource;
+
+/**
+ * Managed data source.
+ * This type of data source keeps track of the streams that have been
+ * requested using {...@link DataSource#getInputStream()} and allows to
+ * forcibly close these streams. Any existing data source can be converted
+ * to a managed data source using {...@link
ManagedDataSourceFactory#create(DataSource)}.
+ */
+public interface ManagedDataSource extends DataSource {
+ /**
+ * Close all streams that have been requested from this data source
+ * and that are not yet closed.
+ */
+ void destroy();
+}
Propchange:
webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/format/ManagedDataSource.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/format/ManagedDataSourceFactory.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/format/ManagedDataSourceFactory.java?rev=751290&view=auto
==============================================================================
---
webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/format/ManagedDataSourceFactory.java
(added)
+++
webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/format/ManagedDataSourceFactory.java
Sat Mar 7 16:32:06 2009
@@ -0,0 +1,131 @@
+/*
+ * 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.axis2.format;
+
+import java.io.FilterInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
+
+import javax.activation.DataSource;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Utility class to create {...@link ManagedDataSource} objects.
+ */
+public class ManagedDataSourceFactory {
+ private static class ManagedInputStream extends FilterInputStream {
+ private DataSourceManager manager;
+
+ public ManagedInputStream(DataSourceManager manager, InputStream
parent) {
+ super(parent);
+ this.manager = manager;
+ }
+
+ @Override
+ public void close() throws IOException {
+ if (manager != null) {
+ manager.notifyStreamClosed(this);
+ manager = null;
+ }
+ super.close();
+ }
+ }
+
+ private static class DataSourceManager implements InvocationHandler {
+ private static final Log log =
LogFactory.getLog(DataSourceManager.class);
+
+ private static final Method getInputStreamMethod;
+ private static final Method destroyMethod;
+
+ static {
+ try {
+ getInputStreamMethod =
DataSource.class.getMethod("getInputStream");
+ destroyMethod = ManagedDataSource.class.getMethod("destroy");
+ } catch (NoSuchMethodException ex) {
+ throw new NoSuchMethodError(ex.getMessage());
+ }
+ }
+
+ private final DataSource dataSource;
+ private final List<ManagedInputStream> openStreams =
Collections.synchronizedList(
+ new LinkedList<ManagedInputStream>());
+
+ public DataSourceManager(DataSource dataSource) {
+ this.dataSource = dataSource;
+ }
+
+ public void notifyStreamClosed(ManagedInputStream managedInputStream) {
+ if (!openStreams.remove(managedInputStream)) {
+ throw new IllegalStateException();
+ }
+ }
+
+ public Object invoke(Object proxy, Method method, Object[] args)
throws Throwable {
+ try {
+ if (method.equals(getInputStreamMethod)) {
+ InputStream in = (InputStream)method.invoke(dataSource,
args);
+ ManagedInputStream in2 = new ManagedInputStream(this, in);
+ openStreams.add(in2);
+ return in2;
+ } else if (method.equals(destroyMethod)) {
+ while (!openStreams.isEmpty()) {
+ try {
+ openStreams.get(0).close();
+ } catch (IOException ex) {
+ log.warn("Exception when closing open stream from
managed data source", ex);
+ }
+ }
+ return null;
+ } else {
+ return method.invoke(dataSource, args);
+ }
+ } catch (InvocationTargetException ex) {
+ throw ex.getCause();
+ }
+ }
+
+ }
+
+ /**
+ * Create a {...@link ManagedDataSource} proxy for an existing data source.
+ * This will create a dynamic proxy implementing the same interfaces as
+ * the original data source.
+ *
+ * @param ds the original data source
+ * @return a data source proxy implementing {...@link ManagedDataSource}
+ */
+ public static ManagedDataSource create(DataSource ds) {
+ Class<?>[] orgIfaces = ds.getClass().getInterfaces();
+ Class<?>[] ifaces = new Class[orgIfaces.length+1];
+ ifaces[0] = ManagedDataSource.class;
+ System.arraycopy(orgIfaces, 0, ifaces, 1, orgIfaces.length);
+ return (ManagedDataSource)Proxy.newProxyInstance(
+ ManagedDataSourceFactory.class.getClassLoader(), ifaces,
+ new DataSourceManager(ds));
+ }
+}
Propchange:
webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/format/ManagedDataSourceFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified:
webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/format/PlainTextBuilder.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/format/PlainTextBuilder.java?rev=751290&r1=751289&r2=751290&view=diff
==============================================================================
---
webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/format/PlainTextBuilder.java
(original)
+++
webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/format/PlainTextBuilder.java
Sat Mar 7 16:32:06 2009
@@ -21,12 +21,15 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
+import java.nio.charset.Charset;
+import javax.activation.DataSource;
import javax.xml.namespace.QName;
import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.impl.llom.OMSourcedElementImpl;
import org.apache.axis2.AxisFault;
import org.apache.axis2.builder.BuilderUtil;
import org.apache.axis2.context.MessageContext;
@@ -49,8 +52,8 @@
* is specified on the content type, the default charset encoding specified by
* {...@link MessageContext#DEFAULT_CHAR_SET_ENCODING} is used.
*/
-public class PlainTextBuilder implements TextMessageBuilder {
- private OMElement buildMessage(String textPayload, MessageContext
msgContext) {
+public class PlainTextBuilder implements TextMessageBuilder,
DataSourceMessageBuilder {
+ private static QName getWrapperQName(MessageContext msgContext) {
QName wrapperQName = BaseConstants.DEFAULT_TEXT_WRAPPER;
if (msgContext.getAxisService() != null) {
Parameter wrapperParam
@@ -58,10 +61,13 @@
if (wrapperParam != null) {
wrapperQName =
BaseUtils.getQNameFromString(wrapperParam.getValue());
}
- }
-
+ }
+ return wrapperQName;
+ }
+
+ private OMElement buildMessage(String textPayload, MessageContext
msgContext) {
OMFactory factory = OMAbstractFactory.getOMFactory();
- OMElement wrapper = factory.createOMElement(wrapperQName, null);
+ OMElement wrapper =
factory.createOMElement(getWrapperQName(msgContext), null);
wrapper.addChild(factory.createOMText(textPayload));
return wrapper;
}
@@ -93,4 +99,15 @@
MessageContext msgContext) throws
AxisFault {
return buildMessage(content, msgContext);
}
+
+ public OMElement processDocument(DataSource dataSource,
+ String contentType,
+ MessageContext msgContext) throws
AxisFault {
+
+ OMFactory factory = OMAbstractFactory.getOMFactory();
+ Charset cs =
Charset.forName(BuilderUtil.getCharSetEncoding(contentType));
+ QName wrapperQName = getWrapperQName(msgContext);
+ return new OMSourcedElementImpl(wrapperQName, factory,
+ new WrappedTextNodeOMDataSource(wrapperQName, dataSource, cs));
+ }
}
Added:
webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/format/WrappedTextNodeOMDataSource.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/format/WrappedTextNodeOMDataSource.java?rev=751290&view=auto
==============================================================================
---
webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/format/WrappedTextNodeOMDataSource.java
(added)
+++
webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/format/WrappedTextNodeOMDataSource.java
Sat Mar 7 16:32:06 2009
@@ -0,0 +1,114 @@
+/*
+ * 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.axis2.format;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.io.UnsupportedEncodingException;
+import java.io.Writer;
+import java.nio.charset.Charset;
+
+import javax.activation.DataSource;
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.axiom.om.OMDataSourceExt;
+import org.apache.axiom.om.OMOutputFormat;
+import org.apache.axiom.om.ds.OMDataSourceExtBase;
+import org.apache.axiom.om.impl.MTOMXMLStreamWriter;
+import org.apache.axiom.om.impl.serialize.StreamingOMSerializer;
+import org.apache.axiom.om.util.StAXUtils;
+
+/**
+ * {...@link org.apache.axiom.om.OMDataSource} implementation that represents
a text node wrapped
+ * inside an element. The text data is provided by a {...@link DataSource}
object.
+ */
+public class WrappedTextNodeOMDataSource extends OMDataSourceExtBase {
+ private final QName wrapperElementName;
+ private final DataSource binaryData;
+ private final Charset charset;
+
+ public WrappedTextNodeOMDataSource(QName wrapperElementName, DataSource
binaryData,
+ Charset charset) {
+ this.wrapperElementName = wrapperElementName;
+ this.binaryData = binaryData;
+ this.charset = charset;
+ }
+
+ @Override
+ public void serialize(OutputStream out, OMOutputFormat format) throws
XMLStreamException {
+ XMLStreamWriter writer = new MTOMXMLStreamWriter(out, format);
+ serialize(writer);
+ writer.flush();
+ }
+
+ @Override
+ public void serialize(Writer writer, OMOutputFormat format) throws
XMLStreamException {
+ MTOMXMLStreamWriter xmlWriter =
+ new MTOMXMLStreamWriter(StAXUtils.createXMLStreamWriter(writer));
+ xmlWriter.setOutputFormat(format);
+ serialize(xmlWriter);
+ xmlWriter.flush();
+ }
+
+ @Override
+ public void serialize(XMLStreamWriter xmlWriter) throws XMLStreamException
{
+ StreamingOMSerializer serializer = new StreamingOMSerializer();
+ serializer.serialize(getReader(), xmlWriter);
+ }
+
+ public XMLStreamReader getReader() throws XMLStreamException {
+ InputStream is;
+ try {
+ is = binaryData.getInputStream();
+ }
+ catch (IOException ex) {
+ throw new XMLStreamException(ex);
+ }
+ return new WrappedTextNodeStreamReader(wrapperElementName, new
InputStreamReader(is, charset));
+ }
+
+ public Object getObject() {
+ return binaryData;
+ }
+
+ public boolean isDestructiveRead() {
+ return false;
+ }
+
+ public boolean isDestructiveWrite() {
+ return false;
+ }
+
+ public byte[] getXMLBytes(String encoding) throws
UnsupportedEncodingException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void close() {
+ }
+
+ public OMDataSourceExt copy() {
+ return new WrappedTextNodeOMDataSource(wrapperElementName, binaryData,
charset);
+ }
+}
Propchange:
webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/format/WrappedTextNodeOMDataSource.java
------------------------------------------------------------------------------
svn:eol-style = native
Copied:
webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/format/WrappedTextNodeStreamReader.java
(from r750138,
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/util/WrappedTextNodeStreamReader.java)
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/format/WrappedTextNodeStreamReader.java?p2=webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/format/WrappedTextNodeStreamReader.java&p1=synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/util/WrappedTextNodeStreamReader.java&r1=750138&r2=751290&rev=751290&view=diff
==============================================================================
---
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/util/WrappedTextNodeStreamReader.java
(original)
+++
webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/format/WrappedTextNodeStreamReader.java
Sat Mar 7 16:32:06 2009
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.synapse.util;
+package org.apache.axis2.format;
import java.io.IOException;
import java.io.Reader;
@@ -35,7 +35,7 @@
import org.apache.commons.io.IOUtils;
/**
- * {...@link javax.xml.stream.XMLStreamException XMLInputStreamReader}
implementation that
+ * {...@link XMLInputStreamReader} implementation that
* represents a text node wrapped inside an element. The text data is provided
by a
* {...@link java.io.Reader Reader}.
* <p>
@@ -66,6 +66,8 @@
* "parser" is not coalescing.
*
*/
+// TODO: This class has been copied from Synapse (package
org.apache.synapse.util).
+// Once it has been moved to Axis2 or Axiom, remove the duplicate from
Synapse.
public class WrappedTextNodeStreamReader implements XMLStreamReader {
/**
* Location object returned by {...@link #getLocation()}.
Propchange:
webservices/commons/trunk/modules/transport/modules/base/src/main/java/org/apache/axis2/format/WrappedTextNodeStreamReader.java
------------------------------------------------------------------------------
svn:mergeinfo =
Added:
webservices/commons/trunk/modules/transport/modules/base/src/test/java/org/apache/axis2/format/ManagedDataSourceFactoryTest.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/transport/modules/base/src/test/java/org/apache/axis2/format/ManagedDataSourceFactoryTest.java?rev=751290&view=auto
==============================================================================
---
webservices/commons/trunk/modules/transport/modules/base/src/test/java/org/apache/axis2/format/ManagedDataSourceFactoryTest.java
(added)
+++
webservices/commons/trunk/modules/transport/modules/base/src/test/java/org/apache/axis2/format/ManagedDataSourceFactoryTest.java
Sat Mar 7 16:32:06 2009
@@ -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.axis2.format;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import javax.activation.DataSource;
+
+import junit.framework.TestCase;
+
+public class ManagedDataSourceFactoryTest extends TestCase {
+ /**
+ * Test that exceptions thrown by {...@link DataSource#getInputStream()}
are
+ * correctly propagated. Since {...@link ManagedDataSourceFactory} uses
dynamic
+ * proxies this aspect needs particular attention.
+ */
+ public void testExceptionPropagation() {
+ ManagedDataSource ds = ManagedDataSourceFactory.create(new
DataSource() {
+ public String getContentType() {
+ return null;
+ }
+
+ public InputStream getInputStream() throws IOException {
+ throw new IOException("TEST");
+ }
+
+ public OutputStream getOutputStream() throws IOException {
+ return null;
+ }
+
+ public String getName() {
+ return null;
+ }
+ });
+ try {
+ ds.getInputStream();
+ } catch (IOException ex) {
+ assertEquals("TEST", ex.getMessage());
+ }
+ }
+}
Propchange:
webservices/commons/trunk/modules/transport/modules/base/src/test/java/org/apache/axis2/format/ManagedDataSourceFactoryTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Copied:
webservices/commons/trunk/modules/transport/modules/base/src/test/java/org/apache/axis2/format/WrappedTextNodeStreamReaderTest.java
(from r750138,
synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/util/WrappedTextNodeStreamReaderTest.java)
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/transport/modules/base/src/test/java/org/apache/axis2/format/WrappedTextNodeStreamReaderTest.java?p2=webservices/commons/trunk/modules/transport/modules/base/src/test/java/org/apache/axis2/format/WrappedTextNodeStreamReaderTest.java&p1=synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/util/WrappedTextNodeStreamReaderTest.java&r1=750138&r2=751290&rev=751290&view=diff
==============================================================================
---
synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/util/WrappedTextNodeStreamReaderTest.java
(original)
+++
webservices/commons/trunk/modules/transport/modules/base/src/test/java/org/apache/axis2/format/WrappedTextNodeStreamReaderTest.java
Sat Mar 7 16:32:06 2009
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.synapse.util;
+package org.apache.axis2.format;
import java.io.StringReader;
import java.io.StringWriter;
@@ -30,7 +30,6 @@
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.impl.builder.StAXOMBuilder;
import org.apache.axiom.om.impl.serialize.StreamingOMSerializer;
-import org.apache.synapse.util.WrappedTextNodeStreamReader;
import org.custommonkey.xmlunit.XMLTestCase;
public class WrappedTextNodeStreamReaderTest extends XMLTestCase {
Propchange:
webservices/commons/trunk/modules/transport/modules/base/src/test/java/org/apache/axis2/format/WrappedTextNodeStreamReaderTest.java
------------------------------------------------------------------------------
svn:mergeinfo =