sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bdelacre...@apache.org
Subject svn commit: r1686378 - /sling/trunk/contrib/extensions/bgservlets/engine/src/test/java/org/apache/sling/bgservlets/impl/nodestream/NodeStreamTest.java
Date Fri, 19 Jun 2015 10:05:49 GMT
Author: bdelacretaz
Date: Fri Jun 19 10:05:49 2015
New Revision: 1686378

URL: http://svn.apache.org/r1686378
Log:
Use random test data

Modified:
    sling/trunk/contrib/extensions/bgservlets/engine/src/test/java/org/apache/sling/bgservlets/impl/nodestream/NodeStreamTest.java

Modified: sling/trunk/contrib/extensions/bgservlets/engine/src/test/java/org/apache/sling/bgservlets/impl/nodestream/NodeStreamTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/bgservlets/engine/src/test/java/org/apache/sling/bgservlets/impl/nodestream/NodeStreamTest.java?rev=1686378&r1=1686377&r2=1686378&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/bgservlets/engine/src/test/java/org/apache/sling/bgservlets/impl/nodestream/NodeStreamTest.java
(original)
+++ sling/trunk/contrib/extensions/bgservlets/engine/src/test/java/org/apache/sling/bgservlets/impl/nodestream/NodeStreamTest.java
Fri Jun 19 10:05:49 2015
@@ -21,6 +21,7 @@ package org.apache.sling.bgservlets.impl
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.InputStream;
+import java.util.Random;
 
 import javax.jcr.Node;
 import javax.jcr.NodeIterator;
@@ -144,14 +145,22 @@ public class NodeStreamTest extends Repo
         testNode.getSession().save();
         
         final NodeOutputStream nos = new NodeOutputStream(testNode);
-        nos.write(BIG_DATA);
+        try {
+            nos.write(BIG_DATA);
+        } finally {
+            nos.close();
+        }
      
         final ByteArrayOutputStream actual = new ByteArrayOutputStream(BIG_DATA.length);
         final byte [] buffer = new byte[7432];
         final NodeInputStream nis = new NodeInputStream(testNode);
-        int count = 0;
-        while((count = nis.read(buffer, 0, buffer.length)) > 0) {
-            actual.write(buffer, 0, count);
+        try {
+            int count = 0;
+            while((count = nis.read(buffer, 0, buffer.length)) > 0) {
+                actual.write(buffer, 0, count);
+            }
+        } finally {
+            nis.close();
         }
         
         assertStream(new ByteArrayInputStream(BIG_DATA), new ByteArrayInputStream(actual.toByteArray()));
@@ -169,8 +178,9 @@ public class NodeStreamTest extends Repo
     
     private static byte [] getBinaryData() {
         final ByteArrayOutputStream os = new ByteArrayOutputStream();
+        final Random random = new Random();
         for(int i=0;i  < 66000; i++) {
-            os.write(i);
+            os.write(random.nextInt());
         }
         return os.toByteArray();
     }



Mime
View raw message