jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1564277 - in /jackrabbit/oak/trunk: oak-core/src/main/java/org/apache/jackrabbit/oak/api/ oak-core/src/main/java/org/apache/jackrabbit/oak/core/ oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/ oak-core/src/main/java/org/apache/jac...
Date Tue, 04 Feb 2014 12:53:43 GMT
Author: mduerig
Date: Tue Feb  4 12:53:42 2014
New Revision: 1564277

URL: http://svn.apache.org/r1564277
Log:
OAK-834: Efficient copying of binaries across repositories
If available use reference of underlying blob instance in ValueFactoryImpl to prevent copying
the actual binary.

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/Root.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/AbstractRoot.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ImmutableRoot.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeStore.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentBlob.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStore.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeStore.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStore.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/value/BinaryImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/value/ValueFactoryImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/NodeStore.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/ProxyNodeStore.java
    jackrabbit/oak/trunk/oak-jcr/pom.xml
    jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/RepositoryTest.java
    jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/ValueJcrTest.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/Root.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/Root.java?rev=1564277&r1=1564276&r2=1564277&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/Root.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/Root.java Tue
Feb  4 12:53:42 2014
@@ -21,6 +21,7 @@ package org.apache.jackrabbit.oak.api;
 import java.io.IOException;
 import java.io.InputStream;
 
+import javax.annotation.CheckForNull;
 import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
 
@@ -174,6 +175,15 @@ public interface Root {
     Blob createBlob(@Nonnull InputStream stream) throws IOException;
 
     /**
+     * Get a blob by its reference.
+     * @param reference  reference to the blob
+     * @return  blob or {@code null} if the reference does not resolve to a blob.
+     * @see Blob#getReference()
+     */
+    @CheckForNull
+    Blob getBlob(@Nonnull String reference);
+
+    /**
      * Get the {@code ContentSession} from which this root was acquired
      * 
      * @return the associated ContentSession

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/AbstractRoot.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/AbstractRoot.java?rev=1564277&r1=1564276&r2=1564277&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/AbstractRoot.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/AbstractRoot.java
Tue Feb  4 12:53:42 2014
@@ -18,10 +18,18 @@
  */
 package org.apache.jackrabbit.oak.core;
 
+import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.collect.Lists.newArrayList;
+import static org.apache.jackrabbit.oak.commons.PathUtils.elements;
+import static org.apache.jackrabbit.oak.commons.PathUtils.getName;
+import static org.apache.jackrabbit.oak.commons.PathUtils.getParentPath;
+import static org.apache.jackrabbit.oak.commons.PathUtils.isAncestor;
+
 import java.io.IOException;
 import java.io.InputStream;
 import java.util.ArrayList;
 import java.util.List;
+
 import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
 import javax.security.auth.Subject;
@@ -61,14 +69,7 @@ import org.apache.jackrabbit.oak.spi.sta
 import org.apache.jackrabbit.oak.spi.state.NodeStore;
 import org.apache.jackrabbit.oak.util.LazyValue;
 
-import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.collect.Lists.newArrayList;
-import static org.apache.jackrabbit.oak.commons.PathUtils.elements;
-import static org.apache.jackrabbit.oak.commons.PathUtils.getName;
-import static org.apache.jackrabbit.oak.commons.PathUtils.getParentPath;
-import static org.apache.jackrabbit.oak.commons.PathUtils.isAncestor;
-
-abstract class AbstractRoot implements Root {
+public abstract class AbstractRoot implements Root {
 
     /**
      * The underlying store to which this root belongs
@@ -346,6 +347,11 @@ abstract class AbstractRoot implements R
         return store.createBlob(checkNotNull(inputStream));
     }
 
+    @Override
+    public Blob getBlob(@Nonnull String reference) {
+        return store.getBlob(reference);
+    }
+
     //-----------------------------------------------------------< internal >---
 
     /**

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ImmutableRoot.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ImmutableRoot.java?rev=1564277&r1=1564276&r2=1564277&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ImmutableRoot.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ImmutableRoot.java
Tue Feb  4 12:53:42 2014
@@ -124,6 +124,11 @@ public final class ImmutableRoot impleme
         throw new UnsupportedOperationException();
     }
 
+    @Override
+    public Blob getBlob(@Nonnull String reference) {
+        return null;
+    }
+
     @Nonnull
     @Override
     public ContentSession getContentSession() {

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeStore.java?rev=1564277&r1=1564276&r2=1564277&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeStore.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeStore.java
Tue Feb  4 12:53:42 2014
@@ -37,6 +37,7 @@ import com.google.common.util.concurrent
 import com.google.common.util.concurrent.SettableFuture;
 import org.apache.jackrabbit.mk.api.MicroKernel;
 import org.apache.jackrabbit.mk.api.MicroKernelException;
+import org.apache.jackrabbit.oak.api.Blob;
 import org.apache.jackrabbit.oak.api.CommitFailedException;
 import org.apache.jackrabbit.oak.cache.CacheLIRS;
 import org.apache.jackrabbit.oak.cache.CacheStats;
@@ -202,6 +203,16 @@ public class KernelNodeStore implements 
         }
     }
 
+    @Override
+    public Blob getBlob(@Nonnull String reference) {
+        try {
+            kernel.getLength(reference);  // throws if reference doesn't resolve
+            return new KernelBlob(reference, kernel);
+        } catch (MicroKernelException e) {
+            return null;
+        }
+    }
+
     @Override @Nonnull
     public String checkpoint(long lifetime) {
         checkArgument(lifetime > 0);

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentBlob.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentBlob.java?rev=1564277&r1=1564276&r2=1564277&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentBlob.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentBlob.java
Tue Feb  4 12:53:42 2014
@@ -55,7 +55,7 @@ public class DocumentBlob implements Blo
 
     @Override @CheckForNull
     public String getReference() {
-        return null;
+        return id;
     }
 
     //------------------------------------------------------------< Object >--

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStore.java?rev=1564277&r1=1564276&r2=1564277&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStore.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStore.java
Tue Feb  4 12:53:42 2014
@@ -1113,17 +1113,6 @@ public final class DocumentNodeStore
         }
     }
 
-    /**
-     * Returns the {@link Blob} with the given blobId.
-     *
-     * @param blobId the blobId of the blob.
-     * @return the blob.
-     */
-    @Nonnull
-    Blob getBlob(String blobId) {
-        return new DocumentBlob(blobStore, blobId);
-    }
-
     //------------------------< Observable >------------------------------------
 
     @Override
@@ -1172,6 +1161,18 @@ public final class DocumentNodeStore
         return new DocumentBlob(blobStore, id);
     }
 
+    /**
+     * Returns the {@link Blob} with the given blobId.
+     *
+     * @param blobId the blobId of the blob.
+     * @return the blob.
+     */
+    @Override
+    @Nonnull
+    public Blob getBlob(String blobId) {
+        return new DocumentBlob(blobStore, blobId);
+    }
+
     @Nonnull
     @Override
     public String checkpoint(long lifetime) {

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeStore.java?rev=1564277&r1=1564276&r2=1564277&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeStore.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeStore.java
Tue Feb  4 12:53:42 2014
@@ -33,6 +33,7 @@ import javax.annotation.Nullable;
 
 import com.google.common.io.ByteStreams;
 
+import org.apache.jackrabbit.oak.api.Blob;
 import org.apache.jackrabbit.oak.api.CommitFailedException;
 import org.apache.jackrabbit.oak.spi.commit.CommitHook;
 import org.apache.jackrabbit.oak.spi.commit.CommitInfo;
@@ -150,6 +151,11 @@ public class MemoryNodeStore implements 
         }
     }
 
+    @Override
+    public Blob getBlob(@Nonnull String reference) {
+        return null;
+    }
+
     @Override @Nonnull
     public synchronized String checkpoint(long lifetime) {
         checkArgument(lifetime > 0);

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStore.java?rev=1564277&r1=1564276&r2=1564277&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStore.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStore.java
Tue Feb  4 12:53:42 2014
@@ -189,6 +189,11 @@ public class SegmentNodeStore implements
         return store.getWriter().writeStream(stream);
     }
 
+    @Override
+    public Blob getBlob(@Nonnull String reference) {
+        return store.readBlob(reference);
+    }
+
     @Override @Nonnull
     public String checkpoint(long lifetime) {
         checkArgument(lifetime > 0);

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/value/BinaryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/value/BinaryImpl.java?rev=1564277&r1=1564276&r2=1564277&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/value/BinaryImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/value/BinaryImpl.java
Tue Feb  4 12:53:42 2014
@@ -16,6 +16,8 @@
  */
 package org.apache.jackrabbit.oak.plugins.value;
 
+import static com.google.common.base.Objects.toStringHelper;
+
 import java.io.IOException;
 import java.io.InputStream;
 
@@ -23,6 +25,7 @@ import javax.annotation.CheckForNull;
 import javax.jcr.PropertyType;
 import javax.jcr.RepositoryException;
 
+import com.google.common.base.Objects;
 import org.apache.jackrabbit.api.ReferenceBinary;
 
 /**
@@ -84,4 +87,22 @@ class BinaryImpl implements ReferenceBin
         return value.getBlob().getReference();
     }
 
+    @Override
+    public boolean equals(Object other) {
+        if (other instanceof ReferenceBinary) {
+            return Objects.equal(getReference(), ((ReferenceBinary) other).getReference());
+        } else {
+            return false;
+        }
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hashCode(getReference());
+    }
+
+    @Override
+    public String toString() {
+        return toStringHelper(this).addValue(value).toString();
+    }
 }
\ No newline at end of file

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/value/ValueFactoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/value/ValueFactoryImpl.java?rev=1564277&r1=1564276&r2=1564277&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/value/ValueFactoryImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/value/ValueFactoryImpl.java
Tue Feb  4 12:53:42 2014
@@ -37,7 +37,7 @@ import javax.jcr.ValueFormatException;
 import javax.jcr.nodetype.NodeType;
 
 import com.google.common.collect.Lists;
-
+import org.apache.jackrabbit.api.ReferenceBinary;
 import org.apache.jackrabbit.oak.api.Blob;
 import org.apache.jackrabbit.oak.api.PropertyState;
 import org.apache.jackrabbit.oak.api.PropertyValue;
@@ -152,9 +152,14 @@ public class ValueFactoryImpl implements
             if (value instanceof BinaryImpl) {
                 // No need to create the value again if we have it already underlying the
binary
                 return ((BinaryImpl) value).getBinaryValue();
-            } else {
-                return createBinaryValue(value.getStream());
+            } else if (value instanceof ReferenceBinary) {
+                String reference = ((ReferenceBinary) value).getReference();
+                Blob blob = root.getBlob(reference);
+                if (blob != null) {
+                    return createBinaryValue(blob);
+                }
             }
+            return createBinaryValue(value.getStream());
         } catch (RepositoryException e) {
             return new ErrorValue(e, PropertyType.BINARY);
         } catch (IOException e) {
@@ -278,7 +283,10 @@ public class ValueFactoryImpl implements
     }
 
     private ValueImpl createBinaryValue(InputStream value) throws IOException {
-        Blob blob = root.createBlob(value);
+        return createBinaryValue(root.createBlob(value));
+    }
+
+    private ValueImpl createBinaryValue(Blob blob) {
         return new ValueImpl(BinaryPropertyState.binaryProperty("", blob), namePathMapper);
     }
 

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/NodeStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/NodeStore.java?rev=1564277&r1=1564276&r2=1564277&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/NodeStore.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/NodeStore.java
Tue Feb  4 12:53:42 2014
@@ -93,9 +93,19 @@ public interface NodeStore {
      * @return  The {@code Blob} representing {@code inputStream}
      * @throws IOException  If an error occurs while reading from the stream
      */
+    @Nonnull
     Blob createBlob(InputStream inputStream) throws IOException;
 
     /**
+     * Get a blob by its reference.
+     * @param reference  reference to the blob
+     * @return  blob or {@code null} if the reference does not resolve to a blob.
+     * @see Blob#getReference()
+     */
+    @CheckForNull
+    Blob getBlob(@Nonnull String reference);
+
+    /**
      * Creates a new checkpoint of the latest root of the tree. The checkpoint
      * remains valid for at least as long as requested and allows that state
      * of the repository to be retrieved using the returned opaque string

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/ProxyNodeStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/ProxyNodeStore.java?rev=1564277&r1=1564276&r2=1564277&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/ProxyNodeStore.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/ProxyNodeStore.java
Tue Feb  4 12:53:42 2014
@@ -19,6 +19,8 @@ package org.apache.jackrabbit.oak.spi.st
 import java.io.IOException;
 import java.io.InputStream;
 
+import javax.annotation.Nonnull;
+
 import org.apache.jackrabbit.oak.api.Blob;
 import org.apache.jackrabbit.oak.api.CommitFailedException;
 import org.apache.jackrabbit.oak.spi.commit.CommitHook;
@@ -56,6 +58,11 @@ public abstract class ProxyNodeStore imp
     }
 
     @Override
+    public Blob getBlob(@Nonnull String reference) {
+        return getNodeStore().getBlob(reference);
+    }
+
+    @Override
     public String checkpoint(long lifetime) {
         return getNodeStore().checkpoint(lifetime);
     }

Modified: jackrabbit/oak/trunk/oak-jcr/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/pom.xml?rev=1564277&r1=1564276&r2=1564277&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/pom.xml (original)
+++ jackrabbit/oak/trunk/oak-jcr/pom.xml Tue Feb  4 12:53:42 2014
@@ -174,8 +174,6 @@
 
       <!-- RDB persistence -->
       org.apache.jackrabbit.core.query.QueryResultTest#testGetSize <!-- OAK-1355 -->
-
-      org.apache.jackrabbit.core.value.ReferenceBinaryTest <!-- OAK-834 -->
     </known.issues>
   </properties>
 

Modified: jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/RepositoryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/RepositoryTest.java?rev=1564277&r1=1564276&r2=1564277&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/RepositoryTest.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/RepositoryTest.java
Tue Feb  4 12:53:42 2014
@@ -26,6 +26,7 @@ import static org.junit.Assert.assertNot
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
+import static org.junit.Assume.assumeTrue;
 
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
@@ -68,8 +69,11 @@ import javax.jcr.nodetype.NodeTypeTempla
 import org.apache.jackrabbit.JcrConstants;
 import org.apache.jackrabbit.api.JackrabbitNode;
 import org.apache.jackrabbit.api.JackrabbitRepository;
+import org.apache.jackrabbit.api.ReferenceBinary;
 import org.apache.jackrabbit.commons.cnd.CndImporter;
 import org.apache.jackrabbit.commons.cnd.ParseException;
+import org.apache.jackrabbit.commons.jackrabbit.SimpleReferenceBinary;
+import org.apache.jackrabbit.core.data.RandomInputStream;
 import org.apache.jackrabbit.oak.jcr.repository.RepositoryImpl;
 import org.junit.Before;
 import org.junit.Ignore;
@@ -2044,6 +2048,26 @@ public class RepositoryTest extends Abst
         assertFalse(uuid.equals(node.getIdentifier()));
     }
 
+    @Test
+    public void testReferenceBinary() throws RepositoryException {
+        ValueFactory valueFactory = getAdminSession().getValueFactory();
+        Binary binary = valueFactory.createBinary(new RandomInputStream(1, 256*1024));
+
+        String reference = binary instanceof ReferenceBinary
+            ? ((ReferenceBinary) binary).getReference()
+            : null;
+
+        assumeTrue(reference != null);
+        Session session = createAdminSession();
+        try {
+            valueFactory = session.getValueFactory();
+            assertEquals(binary, valueFactory.createValue(
+                    new SimpleReferenceBinary(reference)).getBinary());
+        } finally {
+            session.logout();
+        }
+    }
+
     //------------------------------------------------------------< private >---
 
     private Node getNode(String path) throws RepositoryException {

Modified: jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/ValueJcrTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/ValueJcrTest.java?rev=1564277&r1=1564276&r2=1564277&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/ValueJcrTest.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/ValueJcrTest.java
Tue Feb  4 12:53:42 2014
@@ -21,7 +21,6 @@ import junit.framework.TestCase;
 import junit.framework.TestSuite;
 import org.apache.jackrabbit.core.value.BinaryValueTest;
 import org.apache.jackrabbit.core.value.PathTest;
-import org.apache.jackrabbit.core.value.ReferenceBinaryTest;
 
 public class ValueJcrTest extends TestCase {
 
@@ -34,7 +33,6 @@ public class ValueJcrTest extends TestCa
 
         suite.addTestSuite(BinaryValueTest.class);
         suite.addTestSuite(PathTest.class);
-        suite.addTestSuite(ReferenceBinaryTest.class);
 
         return suite;
     }



Mime
View raw message