jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thom...@apache.org
Subject svn commit: r783347 - /jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/
Date Wed, 10 Jun 2009 13:08:53 GMT
Author: thomasm
Date: Wed Jun 10 13:08:53 2009
New Revision: 783347

URL: http://svn.apache.org/viewvc?rev=783347&view=rev
Log:
JCR-2134 Data Store: enable data store tests - fix and speed up tests

Modified:
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/CopyValueTest.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/DBDataStoreTest.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/DataStoreTest.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/ExportImportTest.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/GCConcurrentTest.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/GCEventListenerTest.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/GCThread.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/GarbageCollectorTest.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/NodeTypeTest.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/OpenFilesTest.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/PersistenceManagerIteratorTest.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/RandomInputStream.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/TestTwoGetStreams.java

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/CopyValueTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/CopyValueTest.java?rev=783347&r1=783346&r2=783347&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/CopyValueTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/CopyValueTest.java
Wed Jun 10 13:08:53 2009
@@ -23,6 +23,7 @@
 
 import javax.jcr.Node;
 import javax.jcr.Property;
+import javax.jcr.ValueFactory;
 
 /**
  * Tests copying binary values from one node to another.
@@ -58,10 +59,11 @@
         Node n = testRoot.addNode("a");
         superuser.save();
         byte[] data = new byte[length + 1];
-        n.setProperty("data", new ByteArrayInputStream(data));
+        ValueFactory vf = superuser.getValueFactory();
+        n.setProperty("data", vf.createBinary(new ByteArrayInputStream(data)));
         superuser.save();
         data = new byte[length];
-        n.setProperty("data", new ByteArrayInputStream(data));
+        n.setProperty("data", vf.createBinary(new ByteArrayInputStream(data)));
         Property p = testRoot.getNode("a").getProperty("data");
         assertEquals(length, p.getLength());
         superuser.getWorkspace().copy("/testCopy/a", "/testCopy/b");
@@ -105,7 +107,8 @@
                         .nextGaussian())));
                 byte[] data = new byte[dataLength];
                 log(node1 + " add len:" + dataLength);
-                n.setProperty("data", new ByteArrayInputStream(data));
+                ValueFactory vf = superuser.getValueFactory();
+                n.setProperty("data", vf.createBinary(new ByteArrayInputStream(data)));
                 n.setProperty("len", dataLength);
                 break;
             }

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/DBDataStoreTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/DBDataStoreTest.java?rev=783347&r1=783346&r2=783347&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/DBDataStoreTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/DBDataStoreTest.java
Wed Jun 10 13:08:53 2009
@@ -28,6 +28,9 @@
 import org.apache.commons.io.FileUtils;
 import org.apache.jackrabbit.core.data.db.DbDataStore;
 
+/**
+ * Test the Database Data Store.
+ */
 public class DBDataStoreTest extends TestCase {
 
     private DbDataStore store = new DbDataStore();

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/DataStoreTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/DataStoreTest.java?rev=783347&r1=783346&r2=783347&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/DataStoreTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/DataStoreTest.java
Wed Jun 10 13:08:53 2009
@@ -138,8 +138,8 @@
     }
     
     private void doTest(DataStore ds, int offset) throws Exception {
-        ArrayList list = new ArrayList();
-        HashMap map = new HashMap();
+        ArrayList<DataRecord> list = new ArrayList<DataRecord>();
+        HashMap<DataRecord, Integer> map = new HashMap<DataRecord, Integer>();
         for (int i = 0; i < 100; i++) {
             int size = 100 + i * 10;
             RandomInputStream in = new RandomInputStream(size + offset, size);
@@ -150,8 +150,8 @@
         Random random = new Random(1);
         for (int i = 0; i < list.size(); i++) {
             int pos = random.nextInt(list.size());
-            DataRecord rec = (DataRecord) list.get(pos);
-            int size = ((Integer) map.get(rec)).intValue();
+            DataRecord rec = list.get(pos);
+            int size = map.get(rec);
             rec = ds.getRecord(rec.getIdentifier());
             assertEquals(size, rec.getLength());
             InputStream in = rec.getStream();

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/ExportImportTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/ExportImportTest.java?rev=783347&r1=783346&r2=783347&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/ExportImportTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/ExportImportTest.java
Wed Jun 10 13:08:53 2009
@@ -28,6 +28,7 @@
 import javax.jcr.Node;
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
+import javax.jcr.ValueFactory;
 
 /**
  * Test importing and exporting large binary and text objects.
@@ -68,7 +69,6 @@
             session.save();
             String s = new String(chars);
             test.setProperty("text", s);
-            test.save();
             session.save();
             ByteArrayOutputStream out = new ByteArrayOutputStream();
             session.exportSystemView("/testText", out, false, false);
@@ -120,8 +120,8 @@
             byte[] data = new byte[len];
             Random random = new Random(1);
             random.nextBytes(data);
-            test.setProperty("data", new ByteArrayInputStream(data));
-            test.save();
+            ValueFactory vf = session.getValueFactory();
+            test.setProperty("data", vf.createBinary(new ByteArrayInputStream(data)));
             session.save();
             ByteArrayOutputStream out = new ByteArrayOutputStream();
             session.exportSystemView("/testBinary", out, false, false);
@@ -136,8 +136,8 @@
             test2 = test2.getNode("testBinary");
             test3 = root.getNode("testBinary3");
             test3 = test3.getNode("testBinary");
-            byte[] data2 = readFromStream(test2.getProperty("data").getStream());
-            byte[] data3 = readFromStream(test3.getProperty("data").getStream());
+            byte[] data2 = readFromStream(test2.getProperty("data").getBinary().getStream());
+            byte[] data3 = readFromStream(test3.getProperty("data").getBinary().getStream());
             assertEquals(data.length, data2.length);
             assertEquals(data.length, data3.length);
             for (int i = 0; i < len; i++) {

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/GCConcurrentTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/GCConcurrentTest.java?rev=783347&r1=783346&r2=783347&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/GCConcurrentTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/GCConcurrentTest.java
Wed Jun 10 13:08:53 2009
@@ -30,6 +30,7 @@
 import javax.jcr.Property;
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
+import javax.jcr.ValueFactory;
 
 /**
  * Test case for concurrent garbage collection
@@ -58,7 +59,8 @@
                 gcThread.start();
             }
             Node n = node(root, "test" + i);
-            n.setProperty("data", randomInputStream(i));
+            ValueFactory vf = session.getValueFactory();
+            n.setProperty("data", vf.createBinary(randomInputStream(i)));
             session.save();
             LOG.debug("saved: " + i);
         }
@@ -66,7 +68,7 @@
         for (int i = 0; i < len; i++) {
             Node n = root.getNode("test" + i);
             Property p = n.getProperty("data");
-            InputStream in = p.getStream();
+            InputStream in = p.getBinary().getStream();
             InputStream expected = randomInputStream(i);
             checkStreams(expected, in);
             n.remove();

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/GCEventListenerTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/GCEventListenerTest.java?rev=783347&r1=783346&r2=783347&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/GCEventListenerTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/GCEventListenerTest.java
Wed Jun 10 13:08:53 2009
@@ -27,6 +27,7 @@
 import javax.jcr.Node;
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
+import javax.jcr.ValueFactory;
 
 /**
  * Test the DataStore garbage collector.
@@ -60,10 +61,11 @@
         Node test = root.addNode(TEST_NODE_NAME);
         Random random = new Random();
         byte[] data = new byte[10000];
-        for (int i = 0; i < 20; i++) {
+        for (int i = 0; i < 10; i++) {
             Node n = test.addNode("x" + i);
             random.nextBytes(data);
-            n.setProperty("data", new ByteArrayInputStream(data));
+            ValueFactory vf = session.getValueFactory();
+            n.setProperty("data", vf.createBinary(new ByteArrayInputStream(data)));
             session.save();
             if (i % 2 == 0) {
                 n.remove();
@@ -92,6 +94,7 @@
             int deleted = gc.deleteUnused();
             LOG.debug("Deleted " + deleted);
             assertTrue("Should delete at least one item", deleted >= 0);
+            gc.close();
         }
     }
 

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/GCThread.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/GCThread.java?rev=783347&r1=783346&r2=783347&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/GCThread.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/GCThread.java
Wed Jun 10 13:08:53 2009
@@ -60,6 +60,7 @@
                 LOG.debug("Waiting...");
                 Thread.sleep(10);
             }
+            gc.close();
         } catch (Exception ex) {
             LOG.error("Error scanning", ex);
             exception = ex;
@@ -75,10 +76,10 @@
     }
 
     private int listIdentifiers(GarbageCollector gc) throws DataStoreException {
-        Iterator it = gc.getDataStore().getAllIdentifiers();
+        Iterator<DataIdentifier> it = gc.getDataStore().getAllIdentifiers();
         int count = 0;
         while (it.hasNext()) {
-            DataIdentifier id = (DataIdentifier) it.next();
+            DataIdentifier id = it.next();
             LOG.debug("  " + id);
             count++;
         }

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/GarbageCollectorTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/GarbageCollectorTest.java?rev=783347&r1=783346&r2=783347&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/GarbageCollectorTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/GarbageCollectorTest.java
Wed Jun 10 13:08:53 2009
@@ -18,7 +18,6 @@
 
 import org.apache.jackrabbit.core.RepositoryImpl;
 import org.apache.jackrabbit.core.SessionImpl;
-import org.apache.jackrabbit.core.state.ItemStateException;
 import org.apache.jackrabbit.test.AbstractJCRTest;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -32,6 +31,7 @@
 import javax.jcr.NodeIterator;
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
+import javax.jcr.ValueFactory;
 
 /**
  * Test cases for data store garbage collection.
@@ -51,16 +51,18 @@
         }
         final SynchronousChannel sync = new SynchronousChannel();
         final Node node = root.addNode("slowBlob");
+        final int blobLength = 1000;
+        final ValueFactory vf = session.getValueFactory();
         new Thread() {
             public void run() {
                 try {
-                    node.setProperty("slowBlob", new InputStream() {
+                    node.setProperty("slowBlob", vf.createBinary(new InputStream() {
                         int pos;
                         public int read() throws IOException {
                             pos++;
-                            if (pos < 10000) {
+                            if (pos < blobLength) {
                                 return pos % 80 == 0 ? '\n' : '.';
-                            } else if (pos == 10000) {
+                            } else if (pos == blobLength) {
                                 try {
                                     sync.put("x");
                                     // deleted
@@ -72,7 +74,7 @@
                             }
                             return -1;
                         }
-                    });
+                    }));
                     node.getSession().save();
                     sync.put("saved");
                 } catch (Exception e) {
@@ -87,13 +89,14 @@
         gc.deleteUnused();
         sync.put("deleted");
         assertEquals("saved", sync.take());
-        InputStream in = node.getProperty("slowBlob").getStream();
-        for (int pos = 1; pos < 10000; pos++) {
+        InputStream in = node.getProperty("slowBlob").getBinary().getStream();
+        for (int pos = 1; pos < blobLength; pos++) {
             int expected = pos % 80 == 0 ? '\n' : '.';
             assertEquals(expected, in.read());
         }
         assertEquals('x', in.read());
         in.close();
+        gc.close();
     }
 
     public void testGC() throws Exception {
@@ -108,23 +111,25 @@
 
         deleteMyNodes();
         runGC(session, true);
-        runGC(session, true);
 
         root.addNode("node1");
         Node node2 = root.addNode("node2");
         Node n = node2.addNode("nodeWithBlob");
-        n.setProperty("test", new RandomInputStream(10, 10000));
+        ValueFactory vf = session.getValueFactory();
+        n.setProperty("test", vf.createBinary(new RandomInputStream(10, 1000)));
         n = node2.addNode("nodeWithTemporaryBlob");
-        n.setProperty("test", new RandomInputStream(11, 10000));
+        n.setProperty("test", vf.createBinary(new RandomInputStream(11, 1000)));
         session.save();
 
         n.remove();
         session.save();
-        Thread.sleep(1000);
-
+        
         GarbageCollector gc = ((SessionImpl)session).createDataStoreGarbageCollector();
-        gc.setScanEventListener(this);
-        gc.setTestDelay(1000);
+
+        if (gc.getDataStore() instanceof FileDataStore) {
+            // make sure the file is old (access time resolution is 2 seconds)
+            Thread.sleep(2000);
+        }
 
         LOG.debug("scanning...");
         gc.scan();
@@ -138,26 +143,32 @@
         assertEquals(count - 1, count2);
 
         deleteMyNodes();
+
+        gc.close();
     }
 
-    private void runGC(Session session, boolean all) throws RepositoryException, IOException,
ItemStateException {
+    private void runGC(Session session, boolean all) throws Exception {
         GarbageCollector gc = ((SessionImpl)session).createDataStoreGarbageCollector();
         gc.setScanEventListener(this);
-        gc.setTestDelay(1000);
+        if (gc.getDataStore() instanceof FileDataStore) {
+            // make sure the file is old (access time resolution is 2 seconds)
+            Thread.sleep(2000);
+        }
         gc.scan();
         gc.stopScan();
         if (all) {
             gc.getDataStore().clearInUse();
         }
         gc.deleteUnused();
+        gc.close();
     }
 
     private int listIdentifiers(GarbageCollector gc) throws DataStoreException {
         LOG.debug("identifiers:");
-        Iterator it = gc.getDataStore().getAllIdentifiers();
         int count = 0;
+        Iterator<DataIdentifier> it = gc.getDataStore().getAllIdentifiers();
         while (it.hasNext()) {
-            DataIdentifier id = (DataIdentifier) it.next();
+            DataIdentifier id = it.next();
             LOG.debug("  " + id);
             count++;
         }
@@ -176,23 +187,21 @@
         }
 
         deleteMyNodes();
-        runGC(session, true);
-        runGC(session, true);
 
         Credentials cred = helper.getSuperuserCredentials();
         Session s2 = helper.getRepository().login(cred);
         root = s2.getRootNode();
         Node node2 = root.addNode("node3");
         Node n = node2.addNode("nodeWithBlob");
-        n.setProperty("test", new RandomInputStream(10, 10000));
-        Thread.sleep(1000);
+        ValueFactory vf = session.getValueFactory();
+        n.setProperty("test", vf.createBinary(new RandomInputStream(10, 1000)));
 
         runGC(session, false);
 
         s2.save();
 
-        InputStream in = n.getProperty("test").getStream();
-        InputStream in2 = new RandomInputStream(10, 10000);
+        InputStream in = n.getProperty("test").getBinary().getStream();
+        InputStream in2 = new RandomInputStream(10, 1000);
         while (true) {
             int a = in.read();
             int b = in2.read();

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/NodeTypeTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/NodeTypeTest.java?rev=783347&r1=783346&r2=783347&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/NodeTypeTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/NodeTypeTest.java
Wed Jun 10 13:08:53 2009
@@ -27,9 +27,11 @@
 import javax.jcr.RepositoryException;
 import javax.jcr.Value;
 
+/**
+ * Test node types with binary default values.
+ */
 public class NodeTypeTest extends AbstractJCRTest {
 
-
     /**
      * Test a node type with a binary default value
      * @throws RepositoryException

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/OpenFilesTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/OpenFilesTest.java?rev=783347&r1=783346&r2=783347&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/OpenFilesTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/OpenFilesTest.java
Wed Jun 10 13:08:53 2009
@@ -21,6 +21,7 @@
 import javax.jcr.Node;
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
+import javax.jcr.ValueFactory;
 
 import org.apache.jackrabbit.test.AbstractJCRTest;
 
@@ -36,7 +37,8 @@
         Session session = helper.getReadWriteSession();
         try {
             Node test = session.getRootNode().addNode("test");
-            test.setProperty("data", new ByteArrayInputStream(new byte[10 * 1024]));
+            ValueFactory vf = session.getValueFactory();
+            test.setProperty("data", vf.createBinary(new ByteArrayInputStream(new byte[10
* 1024])));
             session.save();
             for (int i = 0; i < 10000; i++) {
                 test.getProperty("data").getValue();

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/PersistenceManagerIteratorTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/PersistenceManagerIteratorTest.java?rev=783347&r1=783346&r2=783347&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/PersistenceManagerIteratorTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/PersistenceManagerIteratorTest.java
Wed Jun 10 13:08:53 2009
@@ -36,6 +36,9 @@
 import javax.jcr.Repository;
 import javax.jcr.Session;
 
+/**
+ * Test AbstractBundlePersistenceManager.getAllNodeIds
+ */
 public class PersistenceManagerIteratorTest extends AbstractJCRTest {
     /** logger instance */
     private static final Logger LOG = LoggerFactory.getLogger(PersistenceManagerIteratorTest.class);
@@ -58,20 +61,20 @@
 
         RepositoryImpl r = (RepositoryImpl) rep;
         RepositoryConfig conf = r.getConfig();
-        Collection coll = conf.getWorkspaceConfigs();
+        Collection<WorkspaceConfig> coll = conf.getWorkspaceConfigs();
         String[] names = new String[coll.size()];
-        Iterator wspIt = coll.iterator();
-        for(int i = 0; wspIt.hasNext(); i++) {
+        Iterator<WorkspaceConfig> wspIt = coll.iterator();
+        for (int i = 0; wspIt.hasNext(); i++) {
             WorkspaceConfig wsc = (WorkspaceConfig) wspIt.next();
             names[i] = wsc.getName();
         }
 
-        for (int i = 0; i < names.length; i++) {
+        for (int i = 0; i < names.length && i < 1; i++) {
             Session s = helper.getSuperuserSession(names[i]);
             try {
                 Method m = r.getClass().getDeclaredMethod("getWorkspaceInfo", new Class[]
{ String.class });
                 m.setAccessible(true);
-                Object info = m.invoke(r, new String[] { names[i] });
+                Object info = m.invoke(r, names[i]);
                 m = info.getClass().getDeclaredMethod("getPersistenceManager", new Class[0]);
                 m.setAccessible(true);
                 PersistenceManager pm = (PersistenceManager) m.invoke(info, new Object[0]);

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/RandomInputStream.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/RandomInputStream.java?rev=783347&r1=783346&r2=783347&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/RandomInputStream.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/RandomInputStream.java
Wed Jun 10 13:08:53 2009
@@ -20,6 +20,9 @@
 import java.io.IOException;
 import java.io.InputStream;
 
+/**
+ * An input stream that returns pseudo-random bytes.
+ */
 public class RandomInputStream extends InputStream {
 
     private static final long MUL = 0x5DEECE66DL;

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/TestTwoGetStreams.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/TestTwoGetStreams.java?rev=783347&r1=783346&r2=783347&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/TestTwoGetStreams.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/TestTwoGetStreams.java
Wed Jun 10 13:08:53 2009
@@ -37,7 +37,7 @@
 
     private static Logger log = LoggerFactory.getLogger(TestTwoGetStreams.class);
 
-    private static final int STREAM_LENGTH = 1 * 1024 * 1024;
+    private static final int STREAM_LENGTH = 256 * 1024;
     
     private boolean isDataStoreEnabled() throws RepositoryException {
         RepositoryImpl rep = (RepositoryImpl) superuser.getRepository();
@@ -78,9 +78,9 @@
         }
         superuser.save();
         time = System.currentTimeMillis() - time;
-        // streaming the value again and again takes about 4.3 seconds
+        // streaming 1 MB again and again takes about 4.3 seconds
         // on my computer; copying the data identifier takes about 16 ms
-        assertTrue(time < 500);
+        assertTrue(time < 100);
 
     }
     
@@ -94,12 +94,13 @@
         }
         
         Node root = superuser.getRootNode();
-        root.setProperty("p1", new RandomInputStream(1, STREAM_LENGTH));
-        root.setProperty("p2", new RandomInputStream(2, STREAM_LENGTH));
+        ValueFactory vf = superuser.getValueFactory();
+        root.setProperty("p1", vf.createBinary(new RandomInputStream(1, STREAM_LENGTH)));
+        root.setProperty("p2", vf.createBinary(new RandomInputStream(2, STREAM_LENGTH)));
         superuser.save();
 
-        InputStream i1 = root.getProperty("p1").getStream();
-        InputStream i2 = root.getProperty("p2").getStream();
+        InputStream i1 = root.getProperty("p1").getBinary().getStream();
+        InputStream i2 = root.getProperty("p2").getBinary().getStream();
         assertEquals("p1", i1, new RandomInputStream(1, STREAM_LENGTH));
         assertEquals("p2", i2, new RandomInputStream(2, STREAM_LENGTH));
         try {
@@ -124,12 +125,13 @@
         }
         
         Node root = superuser.getRootNode();
-        root.setProperty("p1", new RandomInputStream(1, STREAM_LENGTH));
-        root.setProperty("p2", new RandomInputStream(1, STREAM_LENGTH));
+        ValueFactory vf = superuser.getValueFactory();
+        root.setProperty("p1", vf.createBinary(new RandomInputStream(1, STREAM_LENGTH)));
+        root.setProperty("p2", vf.createBinary(new RandomInputStream(1, STREAM_LENGTH)));
         superuser.save();
 
-        InputStream i1 = root.getProperty("p1").getStream();
-        InputStream i2 = root.getProperty("p2").getStream();
+        InputStream i1 = root.getProperty("p1").getBinary().getStream();
+        InputStream i2 = root.getProperty("p2").getBinary().getStream();
         assertEquals("Streams are different", i1, i2);
         try {
             i1.close();
@@ -154,11 +156,12 @@
         }
         
         Node root = superuser.getRootNode();
-        root.setProperty("p1", new RandomInputStream(1, STREAM_LENGTH));
+        ValueFactory vf = superuser.getValueFactory();
+        root.setProperty("p1", vf.createBinary(new RandomInputStream(1, STREAM_LENGTH)));
         superuser.save();
 
-        InputStream i1 = root.getProperty("p1").getStream();
-        InputStream i2 = root.getProperty("p1").getStream();
+        InputStream i1 = root.getProperty("p1").getBinary().getStream();
+        InputStream i2 = root.getProperty("p1").getBinary().getStream();
         assertEquals("Streams are different", i1, i2);
         try {
             i1.close();



Mime
View raw message