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 2015/05/16 01:56:51 UTC
svn commit: r1679662 [3/3] - in /webservices/axiom/trunk:
modules/axiom-api/src/main/java/org/apache/axiom/attachments/
modules/axiom-api/src/main/java/org/apache/axiom/blob/
modules/axiom-api/src/main/java/org/apache/axiom/util/stax/
modules/axiom-api...
Added: webservices/axiom/trunk/modules/axiom-api/src/test/java/org/apache/axiom/blob/suite/TestReleaseTwice.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-api/src/test/java/org/apache/axiom/blob/suite/TestReleaseTwice.java?rev=1679662&view=auto
==============================================================================
--- webservices/axiom/trunk/modules/axiom-api/src/test/java/org/apache/axiom/blob/suite/TestReleaseTwice.java (added)
+++ webservices/axiom/trunk/modules/axiom-api/src/test/java/org/apache/axiom/blob/suite/TestReleaseTwice.java Fri May 15 23:56:49 2015
@@ -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.blob.suite;
+
+import org.apache.axiom.blob.WritableBlob;
+import org.apache.axiom.blob.WritableBlobFactory;
+
+public class TestReleaseTwice extends WritableBlobTestCase {
+ public TestReleaseTwice(WritableBlobFactory factory) {
+ super(factory, State.RELEASED);
+ }
+
+ @Override
+ protected void runTest(WritableBlob blob) throws Throwable {
+ // This should not trigger any exception
+ blob.release();
+ }
+}
Propchange: webservices/axiom/trunk/modules/axiom-api/src/test/java/org/apache/axiom/blob/suite/TestReleaseTwice.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: webservices/axiom/trunk/modules/axiom-api/src/test/java/org/apache/axiom/blob/suite/TestSkip.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-api/src/test/java/org/apache/axiom/blob/suite/TestSkip.java?rev=1679662&view=auto
==============================================================================
--- webservices/axiom/trunk/modules/axiom-api/src/test/java/org/apache/axiom/blob/suite/TestSkip.java (added)
+++ webservices/axiom/trunk/modules/axiom-api/src/test/java/org/apache/axiom/blob/suite/TestSkip.java Fri May 15 23:56:49 2015
@@ -0,0 +1,52 @@
+/*
+ * 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.blob.suite;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import org.apache.axiom.blob.WritableBlob;
+import org.apache.axiom.blob.WritableBlobFactory;
+import org.apache.commons.io.IOUtils;
+
+public class TestSkip extends WritableBlobTestCase {
+ public TestSkip(WritableBlobFactory factory) {
+ super(factory, State.NEW);
+ }
+
+ @Override
+ protected void runTest(WritableBlob blob) throws Throwable {
+ OutputStream out = blob.getOutputStream();
+ out.write(new byte[] { 2, 4, 6, 8, 9, 7, 5, 3, 1 });
+ out.close();
+ InputStream in = blob.getInputStream();
+ try {
+ assertThat(in.skip(4)).isEqualTo(4);
+ assertThat(IOUtils.toByteArray(in, 3)).isEqualTo(new byte[] { 9, 7, 5 });
+ // The skip method in FileInputStream returns 10 instead of 2
+ // (see http://bugs.java.com/bugdatabase/view_bug.do?bug_id=6294974).
+ assertThat(in.skip(10)).isAnyOf(2L, 10L);
+ assertThat(in.read()).isEqualTo(-1);
+ } finally {
+ in.close();
+ }
+ }
+}
Propchange: webservices/axiom/trunk/modules/axiom-api/src/test/java/org/apache/axiom/blob/suite/TestSkip.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: webservices/axiom/trunk/modules/axiom-api/src/test/java/org/apache/axiom/blob/suite/TestWriteAfterCommit.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-api/src/test/java/org/apache/axiom/blob/suite/TestWriteAfterCommit.java?rev=1679662&view=auto
==============================================================================
--- webservices/axiom/trunk/modules/axiom-api/src/test/java/org/apache/axiom/blob/suite/TestWriteAfterCommit.java (added)
+++ webservices/axiom/trunk/modules/axiom-api/src/test/java/org/apache/axiom/blob/suite/TestWriteAfterCommit.java Fri May 15 23:56:49 2015
@@ -0,0 +1,73 @@
+/*
+ * 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.blob.suite;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+import org.apache.axiom.blob.WritableBlob;
+import org.apache.axiom.blob.WritableBlobFactory;
+import org.apache.axiom.ext.io.ReadFromSupport;
+import org.apache.commons.io.input.NullInputStream;
+
+public class TestWriteAfterCommit extends WritableBlobTestCase {
+ public TestWriteAfterCommit(WritableBlobFactory factory) {
+ super(factory, State.NEW);
+ }
+
+ @Override
+ protected void runTest(WritableBlob blob) throws Throwable {
+ OutputStream out = blob.getOutputStream();
+ out.close();
+ try {
+ out.write(new byte[10]);
+ fail("Expected exception");
+ } catch (IllegalStateException ex) {
+ // OK
+ } catch (IOException ex) {
+ // OK
+ }
+ try {
+ out.write(new byte[10], 3, 5);
+ fail("Expected exception");
+ } catch (IllegalStateException ex) {
+ // OK
+ } catch (IOException ex) {
+ // OK
+ }
+ try {
+ out.write(0);
+ fail("Expected exception");
+ } catch (IllegalStateException ex) {
+ // OK
+ } catch (IOException ex) {
+ // OK
+ }
+ if (out instanceof ReadFromSupport) {
+ try {
+ ((ReadFromSupport)out).readFrom(new NullInputStream(10), -1);
+ fail("Expected exception");
+ } catch (IllegalStateException ex) {
+ // OK
+ } catch (IOException ex) {
+ // OK
+ }
+ }
+ }
+}
Propchange: webservices/axiom/trunk/modules/axiom-api/src/test/java/org/apache/axiom/blob/suite/TestWriteAfterCommit.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: webservices/axiom/trunk/modules/axiom-api/src/test/java/org/apache/axiom/blob/suite/TestWriteTo.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-api/src/test/java/org/apache/axiom/blob/suite/TestWriteTo.java?rev=1679662&view=auto
==============================================================================
--- webservices/axiom/trunk/modules/axiom-api/src/test/java/org/apache/axiom/blob/suite/TestWriteTo.java (added)
+++ webservices/axiom/trunk/modules/axiom-api/src/test/java/org/apache/axiom/blob/suite/TestWriteTo.java Fri May 15 23:56:49 2015
@@ -0,0 +1,55 @@
+/*
+ * 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.blob.suite;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import java.io.OutputStream;
+import java.util.Random;
+
+import org.apache.axiom.blob.WritableBlob;
+import org.apache.axiom.blob.WritableBlobFactory;
+import org.apache.axiom.testutils.io.CloseSensorOutputStream;
+
+public class TestWriteTo extends SizeSensitiveWritableBlobTestCase {
+ private final boolean usesReadFromSupport;
+
+ public TestWriteTo(WritableBlobFactory factory, int size, boolean usesReadFromSupport) {
+ super(factory, State.NEW, size);
+ this.usesReadFromSupport = usesReadFromSupport;
+ }
+
+ @Override
+ protected void runTest(WritableBlob blob) throws Throwable {
+ Random random = new Random();
+ byte[] data = new byte[size];
+ random.nextBytes(data);
+ OutputStream out = blob.getOutputStream();
+ out.write(data);
+ out.close();
+ ByteArrayOutputStreamWithReadFromSupport baos = new ByteArrayOutputStreamWithReadFromSupport();
+ CloseSensorOutputStream closeSensor = new CloseSensorOutputStream(baos);
+ blob.writeTo(baos);
+ assertThat(closeSensor.isClosed()).isFalse();
+ assertThat(baos.toByteArray()).isEqualTo(data);
+ if (usesReadFromSupport) {
+ assertThat(baos.isReadFromCalled()).isTrue();
+ }
+ }
+}
Propchange: webservices/axiom/trunk/modules/axiom-api/src/test/java/org/apache/axiom/blob/suite/TestWriteTo.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: webservices/axiom/trunk/modules/axiom-api/src/test/java/org/apache/axiom/blob/suite/TestWriteToIllegalState.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-api/src/test/java/org/apache/axiom/blob/suite/TestWriteToIllegalState.java?rev=1679662&view=auto
==============================================================================
--- webservices/axiom/trunk/modules/axiom-api/src/test/java/org/apache/axiom/blob/suite/TestWriteToIllegalState.java (added)
+++ webservices/axiom/trunk/modules/axiom-api/src/test/java/org/apache/axiom/blob/suite/TestWriteToIllegalState.java Fri May 15 23:56:49 2015
@@ -0,0 +1,40 @@
+/*
+ * 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.blob.suite;
+
+import org.apache.axiom.blob.WritableBlob;
+import org.apache.axiom.blob.WritableBlobFactory;
+import org.apache.commons.io.output.NullOutputStream;
+
+public class TestWriteToIllegalState extends WritableBlobTestCase {
+ public TestWriteToIllegalState(WritableBlobFactory factory, State state) {
+ super(factory, state);
+ state.addTestParameters(this);
+ }
+
+ @Override
+ protected void runTest(WritableBlob blob) throws Throwable {
+ try {
+ blob.writeTo(new NullOutputStream());
+ fail("Expected IllegalStateException");
+ } catch (IllegalStateException ex) {
+ // Expected
+ }
+ }
+}
Propchange: webservices/axiom/trunk/modules/axiom-api/src/test/java/org/apache/axiom/blob/suite/TestWriteToIllegalState.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: webservices/axiom/trunk/modules/axiom-api/src/test/java/org/apache/axiom/blob/suite/TestWriteToWithError.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-api/src/test/java/org/apache/axiom/blob/suite/TestWriteToWithError.java?rev=1679662&view=auto
==============================================================================
--- webservices/axiom/trunk/modules/axiom-api/src/test/java/org/apache/axiom/blob/suite/TestWriteToWithError.java (added)
+++ webservices/axiom/trunk/modules/axiom-api/src/test/java/org/apache/axiom/blob/suite/TestWriteToWithError.java Fri May 15 23:56:49 2015
@@ -0,0 +1,46 @@
+/*
+ * 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.blob.suite;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import org.apache.axiom.blob.WritableBlob;
+import org.apache.axiom.blob.WritableBlobFactory;
+import org.apache.axiom.ext.io.StreamCopyException;
+import org.apache.axiom.testutils.io.ExceptionOutputStream;
+import org.apache.commons.io.input.NullInputStream;
+
+public class TestWriteToWithError extends SizeSensitiveWritableBlobTestCase {
+ public TestWriteToWithError(WritableBlobFactory factory, int size) {
+ super(factory, State.NEW, size);
+ }
+
+ @Override
+ protected void runTest(WritableBlob blob) throws Throwable {
+ blob.readFrom(new NullInputStream(size));
+ ExceptionOutputStream out = new ExceptionOutputStream(size/2);
+ try {
+ blob.writeTo(out);
+ fail("Expected StreamCopyException");
+ } catch (StreamCopyException ex) {
+ assertThat(ex.getOperation()).isEqualTo(StreamCopyException.WRITE);
+ assertThat(ex.getCause()).isSameAs(out.getException());
+ }
+ }
+}
Propchange: webservices/axiom/trunk/modules/axiom-api/src/test/java/org/apache/axiom/blob/suite/TestWriteToWithError.java
------------------------------------------------------------------------------
svn:eol-style = native
Copied: webservices/axiom/trunk/modules/axiom-api/src/test/java/org/apache/axiom/blob/suite/WritableBlobTestCase.java (from r1678555, webservices/axiom/trunk/modules/axiom-api/src/test/java/org/apache/axiom/blob/WritableBlobTestCase.java)
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-api/src/test/java/org/apache/axiom/blob/suite/WritableBlobTestCase.java?p2=webservices/axiom/trunk/modules/axiom-api/src/test/java/org/apache/axiom/blob/suite/WritableBlobTestCase.java&p1=webservices/axiom/trunk/modules/axiom-api/src/test/java/org/apache/axiom/blob/WritableBlobTestCase.java&r1=1678555&r2=1679662&rev=1679662&view=diff
==============================================================================
--- webservices/axiom/trunk/modules/axiom-api/src/test/java/org/apache/axiom/blob/WritableBlobTestCase.java (original)
+++ webservices/axiom/trunk/modules/axiom-api/src/test/java/org/apache/axiom/blob/suite/WritableBlobTestCase.java Fri May 15 23:56:49 2015
@@ -16,25 +16,31 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.axiom.blob;
+package org.apache.axiom.blob.suite;
import org.apache.axiom.blob.WritableBlob;
+import org.apache.axiom.blob.WritableBlobFactory;
import org.apache.axiom.testutils.suite.MatrixTestCase;
public abstract class WritableBlobTestCase extends MatrixTestCase {
private final WritableBlobFactory factory;
+ private final State initialState;
- public WritableBlobTestCase(WritableBlobFactory factory) {
+ public WritableBlobTestCase(WritableBlobFactory factory, State initialState) {
this.factory = factory;
+ this.initialState = initialState;
}
@Override
protected final void runTest() throws Throwable {
WritableBlob blob = factory.createBlob();
+ CleanupCallback cleanupCallback = initialState.transition(blob);
try {
runTest(blob);
} finally {
- blob.release();
+ if (cleanupCallback != null) {
+ cleanupCallback.cleanup();
+ }
}
}
Copied: webservices/axiom/trunk/modules/axiom-api/src/test/java/org/apache/axiom/blob/suite/WritableBlobTestSuiteBuilder.java (from r1678555, webservices/axiom/trunk/modules/axiom-api/src/test/java/org/apache/axiom/blob/WritableBlobTestSuiteBuilder.java)
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-api/src/test/java/org/apache/axiom/blob/suite/WritableBlobTestSuiteBuilder.java?p2=webservices/axiom/trunk/modules/axiom-api/src/test/java/org/apache/axiom/blob/suite/WritableBlobTestSuiteBuilder.java&p1=webservices/axiom/trunk/modules/axiom-api/src/test/java/org/apache/axiom/blob/WritableBlobTestSuiteBuilder.java&r1=1678555&r2=1679662&rev=1679662&view=diff
==============================================================================
--- webservices/axiom/trunk/modules/axiom-api/src/test/java/org/apache/axiom/blob/WritableBlobTestSuiteBuilder.java (original)
+++ webservices/axiom/trunk/modules/axiom-api/src/test/java/org/apache/axiom/blob/suite/WritableBlobTestSuiteBuilder.java Fri May 15 23:56:49 2015
@@ -16,30 +16,62 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.axiom.blob;
+package org.apache.axiom.blob.suite;
+import org.apache.axiom.blob.WritableBlobFactory;
import org.apache.axiom.testutils.suite.MatrixTestSuiteBuilder;
public class WritableBlobTestSuiteBuilder extends MatrixTestSuiteBuilder {
private final WritableBlobFactory factory;
+ private final int[] sizes;
+ private final boolean outputStreamHasReadFromSupport;
+ private final boolean writeToUsesReadFromSupport;
- public WritableBlobTestSuiteBuilder(WritableBlobFactory factory) {
+ public WritableBlobTestSuiteBuilder(WritableBlobFactory factory, int[] sizes,
+ boolean outputStreamHasReadFromSupport, boolean writeToUsesReadFromSupport) {
this.factory = factory;
+ this.sizes = sizes;
+ this.outputStreamHasReadFromSupport = outputStreamHasReadFromSupport;
+ this.writeToUsesReadFromSupport = writeToUsesReadFromSupport;
}
@Override
protected void addTests() {
- addTest(new TestGetInputStreamNew(factory));
- addTest(new TestGetInputStreamUncommitted(factory));
- addTest(new TestGetOutputStreamCommitted(factory));
- addTest(new TestGetOutputStreamUncommitted(factory));
- addTest(new TestMarkReset(factory));
- addTest(new TestReadFrom(factory, 10000));
- addTest(new TestReadFrom(factory, 100000));
- addTest(new TestReadFromCommitted(factory, null));
- addTest(new TestReadFromCommitted(factory, Boolean.FALSE));
- addTest(new TestReadFromCommitted(factory, Boolean.TRUE));
- addTest(new TestRandomReadWrite(factory, 10000));
- addTest(new TestRandomReadWrite(factory, 100000));
+ addTest(new TestAvailable(factory));
+ addTest(new TestGetInputStreamIllegalState(factory, State.NEW));
+ addTest(new TestGetInputStreamIllegalState(factory, State.UNCOMMITTED));
+ addTest(new TestGetInputStreamIllegalState(factory, State.RELEASED));
+ addTest(new TestGetOutputStreamIllegalState(factory, State.UNCOMMITTED));
+ addTest(new TestGetOutputStreamIllegalState(factory, State.COMMITTED));
+ addTest(new TestGetOutputStreamIllegalState(factory, State.RELEASED));
+ addTest(new TestGetSizeIllegalState(factory, State.NEW));
+ addTest(new TestGetSizeIllegalState(factory, State.UNCOMMITTED));
+ addTest(new TestGetSizeIllegalState(factory, State.RELEASED));
+ addTest(new TestReadEOF(factory));
+ addTest(new TestReadFromIllegalState(factory, State.UNCOMMITTED));
+ addTest(new TestReadFromIllegalState(factory, State.COMMITTED));
+ addTest(new TestReadFromIllegalState(factory, State.RELEASED));
+ if (outputStreamHasReadFromSupport) {
+ addTest(new TestReadFromSupport(factory));
+ }
+ addTest(new TestReadFromWithError(factory));
+ addTest(new TestReadZeroLength(factory));
+ addTest(new TestReleaseTwice(factory));
+ addTest(new TestSkip(factory));
+ addTest(new TestWriteAfterCommit(factory));
+ addTest(new TestWriteToIllegalState(factory, State.NEW));
+ addTest(new TestWriteToIllegalState(factory, State.UNCOMMITTED));
+ addTest(new TestWriteToIllegalState(factory, State.RELEASED));
+ for (int size : sizes) {
+ addTests(size);
+ }
};
+
+ private void addTests(int size) {
+ addTest(new TestMarkReset(factory, size));
+ addTest(new TestReadFrom(factory, size));
+ addTest(new TestRandomReadWrite(factory, size));
+ addTest(new TestWriteTo(factory, size, writeToUsesReadFromSupport));
+ addTest(new TestWriteToWithError(factory, size));
+ }
}
Modified: webservices/axiom/trunk/modules/axiom-compat/src/main/java/org/apache/axiom/util/blob/BlobOutputStream.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-compat/src/main/java/org/apache/axiom/util/blob/BlobOutputStream.java?rev=1679662&r1=1679661&r2=1679662&view=diff
==============================================================================
--- webservices/axiom/trunk/modules/axiom-compat/src/main/java/org/apache/axiom/util/blob/BlobOutputStream.java (original)
+++ webservices/axiom/trunk/modules/axiom-compat/src/main/java/org/apache/axiom/util/blob/BlobOutputStream.java Fri May 15 23:56:49 2015
@@ -29,7 +29,7 @@ import org.apache.axiom.ext.io.StreamCop
* Output stream that is used to write to a blob. Instances of this class are returned by the
* {@link WritableBlob#getOutputStream()} method.
*
- * @deprecated Use {@link org.apache.axiom.blob.BlobOutputStream} instead.
+ * @deprecated
*/
public abstract class BlobOutputStream extends OutputStream implements ReadFromSupport {
/**
Modified: webservices/axiom/trunk/modules/axiom-compat/src/main/java/org/apache/axiom/util/blob/OverflowBlob.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-compat/src/main/java/org/apache/axiom/util/blob/OverflowBlob.java?rev=1679662&r1=1679661&r2=1679662&view=diff
==============================================================================
--- webservices/axiom/trunk/modules/axiom-compat/src/main/java/org/apache/axiom/util/blob/OverflowBlob.java (original)
+++ webservices/axiom/trunk/modules/axiom-compat/src/main/java/org/apache/axiom/util/blob/OverflowBlob.java Fri May 15 23:56:49 2015
@@ -38,7 +38,7 @@ import org.apache.commons.logging.LogFac
* that are allocated on demand. Since a temporary file may be created it is mandatory to call
* {@link #release()} to discard the blob.
*
- * @deprecated Use {@link org.apache.axiom.blob.OverflowBlob} instead.
+ * @deprecated Use {@link org.apache.axiom.blob.OverflowableBlob} instead.
*/
public class OverflowBlob implements WritableBlob {
private static final Log log = LogFactory.getLog(OverflowBlob.class);
Modified: webservices/axiom/trunk/systests/integration-tests/src/test/java/org/apache/axiom/om/impl/builder/JAXBCustomBuilderTest.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/systests/integration-tests/src/test/java/org/apache/axiom/om/impl/builder/JAXBCustomBuilderTest.java?rev=1679662&r1=1679661&r2=1679662&view=diff
==============================================================================
--- webservices/axiom/trunk/systests/integration-tests/src/test/java/org/apache/axiom/om/impl/builder/JAXBCustomBuilderTest.java (original)
+++ webservices/axiom/trunk/systests/integration-tests/src/test/java/org/apache/axiom/om/impl/builder/JAXBCustomBuilderTest.java Fri May 15 23:56:49 2015
@@ -33,6 +33,7 @@ import javax.xml.namespace.QName;
import junit.framework.Assert;
import org.apache.axiom.attachments.Attachments;
+import org.apache.axiom.blob.Blobs;
import org.apache.axiom.blob.MemoryBlob;
import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.om.OMElement;
@@ -81,7 +82,7 @@ public class JAXBCustomBuilderTest {
@Test
public void testPlain() throws Exception {
DataHandler dh = new DataHandler(new RandomDataSource(10000));
- MemoryBlob blob = new MemoryBlob();
+ MemoryBlob blob = Blobs.createMemoryBlob();
OutputStream out = blob.getOutputStream();
createTestDocument(dh).serialize(out);
out.close();
@@ -98,7 +99,7 @@ public class JAXBCustomBuilderTest {
@Test
public void testWithXOP() throws Exception {
DataHandler dh = new DataHandler(new RandomDataSource(10000));
- MemoryBlob blob = new MemoryBlob();
+ MemoryBlob blob = Blobs.createMemoryBlob();
OutputStream out = blob.getOutputStream();
OMOutputFormat format = new OMOutputFormat();
format.setDoOptimize(true);
Added: webservices/axiom/trunk/testing/testutils/src/main/java/org/apache/axiom/testutils/io/CloseSensorOutputStream.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/testing/testutils/src/main/java/org/apache/axiom/testutils/io/CloseSensorOutputStream.java?rev=1679662&view=auto
==============================================================================
--- webservices/axiom/trunk/testing/testutils/src/main/java/org/apache/axiom/testutils/io/CloseSensorOutputStream.java (added)
+++ webservices/axiom/trunk/testing/testutils/src/main/java/org/apache/axiom/testutils/io/CloseSensorOutputStream.java Fri May 15 23:56:49 2015
@@ -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.testutils.io;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+import org.apache.commons.io.output.ProxyOutputStream;
+
+public class CloseSensorOutputStream extends ProxyOutputStream {
+ private boolean closed;
+
+ public CloseSensorOutputStream(OutputStream proxy) {
+ super(proxy);
+ }
+
+ public void close() throws IOException {
+ closed = true;
+ super.close();
+ }
+
+ public boolean isClosed() {
+ return closed;
+ }
+}
Propchange: webservices/axiom/trunk/testing/testutils/src/main/java/org/apache/axiom/testutils/io/CloseSensorOutputStream.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: webservices/axiom/trunk/testing/testutils/src/main/java/org/apache/axiom/testutils/io/ExceptionInputStream.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/testing/testutils/src/main/java/org/apache/axiom/testutils/io/ExceptionInputStream.java?rev=1679662&r1=1679661&r2=1679662&view=diff
==============================================================================
--- webservices/axiom/trunk/testing/testutils/src/main/java/org/apache/axiom/testutils/io/ExceptionInputStream.java (original)
+++ webservices/axiom/trunk/testing/testutils/src/main/java/org/apache/axiom/testutils/io/ExceptionInputStream.java Fri May 15 23:56:49 2015
@@ -30,6 +30,7 @@ import org.apache.commons.io.input.Proxy
*/
public class ExceptionInputStream extends ProxyInputStream {
private int remaining;
+ private IOException exception;
public ExceptionInputStream(InputStream in) {
this(in, Integer.MAX_VALUE);
@@ -42,11 +43,11 @@ public class ExceptionInputStream extend
public int read() throws IOException {
if (remaining == 0) {
- throw new IOException("Maximum number of bytes read");
+ throw exception = new IOException("Maximum number of bytes read");
}
int b = super.read();
if (b == -1) {
- throw new IOException("End of stream reached");
+ throw exception = new IOException("End of stream reached");
}
remaining--;
return b;
@@ -58,7 +59,7 @@ public class ExceptionInputStream extend
public int read(byte[] b, int off, int len) throws IOException {
if (remaining == 0) {
- throw new IOException("Maximum number of bytes read");
+ throw exception = new IOException("Maximum number of bytes read");
}
// Note: We use a sort of throttling mechanism here where we reduce the
// number of bytes read if we approach the point where we throw an
@@ -66,9 +67,13 @@ public class ExceptionInputStream extend
// read too much in advance.
int c = super.read(b, off, Math.min(Math.max(1, remaining/2), len));
if (c == -1) {
- throw new IOException("End of stream reached");
+ throw exception = new IOException("End of stream reached");
}
remaining -= c;
return c;
}
+
+ public IOException getException() {
+ return exception;
+ }
}
Added: webservices/axiom/trunk/testing/testutils/src/main/java/org/apache/axiom/testutils/io/ExceptionOutputStream.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/testing/testutils/src/main/java/org/apache/axiom/testutils/io/ExceptionOutputStream.java?rev=1679662&view=auto
==============================================================================
--- webservices/axiom/trunk/testing/testutils/src/main/java/org/apache/axiom/testutils/io/ExceptionOutputStream.java (added)
+++ webservices/axiom/trunk/testing/testutils/src/main/java/org/apache/axiom/testutils/io/ExceptionOutputStream.java Fri May 15 23:56:49 2015
@@ -0,0 +1,42 @@
+/*
+ * 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.OutputStream;
+
+public class ExceptionOutputStream extends OutputStream {
+ private int remaining;
+ private IOException exception;
+
+ public ExceptionOutputStream(int maxBytes) {
+ remaining = maxBytes;
+ }
+
+ @Override
+ public void write(int b) throws IOException {
+ if (--remaining == 0) {
+ throw exception = new IOException("Maximum number of bytes written");
+ }
+ }
+
+ public IOException getException() {
+ return exception;
+ }
+}
Propchange: webservices/axiom/trunk/testing/testutils/src/main/java/org/apache/axiom/testutils/io/ExceptionOutputStream.java
------------------------------------------------------------------------------
svn:eol-style = native