You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ws.apache.org by dk...@apache.org on 2019/10/31 14:51:55 UTC
[ws-axiom] 03/11: AXIOM-495: Merge r1853727 to the 1.2 branch (with
changes).
This is an automated email from the ASF dual-hosted git repository.
dkulp pushed a commit to branch 1.2.x
in repository https://gitbox.apache.org/repos/asf/ws-axiom.git
commit 2a1153e62d846edde410173b6c4a4c8b798e93f0
Author: Andreas Veithen <ve...@apache.org>
AuthorDate: Sat Feb 16 20:59:53 2019 +0000
AXIOM-495: Merge r1853727 to the 1.2 branch (with changes).
---
.../apache/axiom/blob/MemoryBlobInputStream.java | 2 +-
.../axiom/blob/suite/TestResetWithoutMark.java | 57 ++++++++++++++++++++++
.../blob/suite/WritableBlobTestSuiteBuilder.java | 1 +
3 files changed, 59 insertions(+), 1 deletion(-)
diff --git a/axiom-api/src/main/java/org/apache/axiom/blob/MemoryBlobInputStream.java b/axiom-api/src/main/java/org/apache/axiom/blob/MemoryBlobInputStream.java
index 6f2b1ae..f9764c8 100644
--- a/axiom-api/src/main/java/org/apache/axiom/blob/MemoryBlobInputStream.java
+++ b/axiom-api/src/main/java/org/apache/axiom/blob/MemoryBlobInputStream.java
@@ -28,7 +28,7 @@ final class MemoryBlobInputStream extends InputStream {
private int markIndex;
MemoryBlobInputStream(MemoryBlobChunk firstChunk) {
- chunk = firstChunk;
+ markChunk = chunk = firstChunk;
}
private void updateChunk() {
diff --git a/axiom-api/src/test/java/org/apache/axiom/blob/suite/TestResetWithoutMark.java b/axiom-api/src/test/java/org/apache/axiom/blob/suite/TestResetWithoutMark.java
new file mode 100644
index 0000000..0348816
--- /dev/null
+++ b/axiom-api/src/test/java/org/apache/axiom/blob/suite/TestResetWithoutMark.java
@@ -0,0 +1,57 @@
+/*
+ * 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 java.util.Random;
+
+import org.apache.axiom.blob.WritableBlob;
+import org.apache.axiom.blob.WritableBlobFactory;
+import org.apache.commons.io.IOUtils;
+
+public class TestResetWithoutMark extends WritableBlobTestCase {
+ public TestResetWithoutMark(WritableBlobFactory factory) {
+ super(factory, State.NEW);
+ }
+
+ @Override
+ protected void runTest(WritableBlob blob) throws Throwable {
+ Random random = new Random();
+ byte[] sourceData = new byte[1024];
+ random.nextBytes(sourceData);
+ OutputStream out = blob.getOutputStream();
+ out.write(sourceData);
+ out.close();
+ InputStream in = blob.getInputStream();
+ try {
+ byte[] data1 = new byte[sourceData.length];
+ byte[] data2 = new byte[sourceData.length];
+ IOUtils.readFully(in, data1);
+ in.reset();
+ IOUtils.readFully(in, data2);
+ assertThat(data1).isEqualTo(sourceData);
+ assertThat(data2).isEqualTo(sourceData);
+ } finally {
+ in.close();
+ }
+ }
+}
diff --git a/axiom-api/src/test/java/org/apache/axiom/blob/suite/WritableBlobTestSuiteBuilder.java b/axiom-api/src/test/java/org/apache/axiom/blob/suite/WritableBlobTestSuiteBuilder.java
index b3f45bb..66c3f09 100644
--- a/axiom-api/src/test/java/org/apache/axiom/blob/suite/WritableBlobTestSuiteBuilder.java
+++ b/axiom-api/src/test/java/org/apache/axiom/blob/suite/WritableBlobTestSuiteBuilder.java
@@ -57,6 +57,7 @@ public class WritableBlobTestSuiteBuilder extends MatrixTestSuiteBuilder {
addTest(new TestReadFromWithError(factory));
addTest(new TestReadZeroLength(factory));
addTest(new TestReleaseTwice(factory));
+ addTest(new TestResetWithoutMark(factory));
addTest(new TestSkip(factory));
addTest(new TestWriteAfterCommit(factory));
addTest(new TestWriteToIllegalState(factory, State.NEW));