ws-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From veit...@apache.org
Subject svn commit: r1853727 - in /webservices/axiom/trunk/axiom-api/src: main/java/org/apache/axiom/blob/ test/java/org/apache/axiom/blob/suite/
Date Sat, 16 Feb 2019 20:49:24 GMT
Author: veithen
Date: Sat Feb 16 20:49:24 2019
New Revision: 1853727

URL: http://svn.apache.org/viewvc?rev=1853727&view=rev
Log:
AXIOM-495: Correct behavior of MemoryBlobInputStream when reset() is called without mark().

Added:
    webservices/axiom/trunk/axiom-api/src/test/java/org/apache/axiom/blob/suite/TestResetWithoutMark.java
  (with props)
Modified:
    webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/blob/MemoryBlobInputStreamImpl.java
    webservices/axiom/trunk/axiom-api/src/test/java/org/apache/axiom/blob/suite/WritableBlobTestSuiteBuilder.java

Modified: webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/blob/MemoryBlobInputStreamImpl.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/blob/MemoryBlobInputStreamImpl.java?rev=1853727&r1=1853726&r2=1853727&view=diff
==============================================================================
--- webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/blob/MemoryBlobInputStreamImpl.java
(original)
+++ webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/blob/MemoryBlobInputStreamImpl.java
Sat Feb 16 20:49:24 2019
@@ -25,7 +25,7 @@ final class MemoryBlobInputStreamImpl ex
     private int markIndex;
     
     MemoryBlobInputStreamImpl(MemoryBlobChunk firstChunk) {
-        chunk = firstChunk;
+        markChunk = chunk = firstChunk;
     }
 
     private void updateChunk() {

Added: webservices/axiom/trunk/axiom-api/src/test/java/org/apache/axiom/blob/suite/TestResetWithoutMark.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/axiom-api/src/test/java/org/apache/axiom/blob/suite/TestResetWithoutMark.java?rev=1853727&view=auto
==============================================================================
--- webservices/axiom/trunk/axiom-api/src/test/java/org/apache/axiom/blob/suite/TestResetWithoutMark.java
(added)
+++ webservices/axiom/trunk/axiom-api/src/test/java/org/apache/axiom/blob/suite/TestResetWithoutMark.java
Sat Feb 16 20:49:24 2019
@@ -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();
+        }
+    }
+}

Propchange: webservices/axiom/trunk/axiom-api/src/test/java/org/apache/axiom/blob/suite/TestResetWithoutMark.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: webservices/axiom/trunk/axiom-api/src/test/java/org/apache/axiom/blob/suite/WritableBlobTestSuiteBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/axiom-api/src/test/java/org/apache/axiom/blob/suite/WritableBlobTestSuiteBuilder.java?rev=1853727&r1=1853726&r2=1853727&view=diff
==============================================================================
--- webservices/axiom/trunk/axiom-api/src/test/java/org/apache/axiom/blob/suite/WritableBlobTestSuiteBuilder.java
(original)
+++ webservices/axiom/trunk/axiom-api/src/test/java/org/apache/axiom/blob/suite/WritableBlobTestSuiteBuilder.java
Sat Feb 16 20:49:24 2019
@@ -54,6 +54,7 @@ public class WritableBlobTestSuiteBuilde
         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));



Mime
View raw message