[exo-jcr-commits] exo-jcr SVN: r1491 - jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/lab/cluster/test.
do-not-reply at jboss.org
do-not-reply at jboss.org
Tue Jan 19 17:29:24 EST 2010
Author: pnedonosko
Date: 2010-01-19 17:29:23 -0500 (Tue, 19 Jan 2010)
New Revision: 1491
Modified:
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/lab/cluster/test/TestBLOBValue.java
Log:
EXOJCR-404 test read usecase
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/lab/cluster/test/TestBLOBValue.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/lab/cluster/test/TestBLOBValue.java 2010-01-19 22:01:26 UTC (rev 1490)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/lab/cluster/test/TestBLOBValue.java 2010-01-19 22:29:23 UTC (rev 1491)
@@ -12,22 +12,32 @@
public class TestBLOBValue extends JcrAPIBaseTest
{
+ private static final String TEST_ROOT_NAME = "TestBLOBValue";
+
+ private static final int FILE_SIZE_KB = 1024;
+ private static File testFile;
+
private Node testRoot;
- private static File testFile;
-
@Override
public void setUp() throws Exception
{
super.setUp();
- testRoot = root.addNode("TestBLOBValue");
- root.save();
+ if (root.hasNode(TEST_ROOT_NAME))
+ {
+ testRoot = root.getNode(TEST_ROOT_NAME);
+ }
+ else
+ {
+ testRoot = root.addNode(TEST_ROOT_NAME);
+ root.save();
+ }
if (testFile == null)
{
- testFile = createBLOBTempFile(1020); // 1MB
+ testFile = createBLOBTempFile(FILE_SIZE_KB); // 1MB
}
}
@@ -50,13 +60,38 @@
testRoot.save();
fis.close();
-
+
// read
Session user1 = repository.login(credentials, root.getSession().getWorkspace().getName());
Node troot = user1.getRootNode().getNode("TestBLOBValue");
Property tblob = troot.getProperty("blob");
InputStream blobStream = tblob.getStream();
+
+ byte[] buff = new byte[1024];
+ int r = 0;
+ int size = 0;
+ while ((r = blobStream.read(buff))>=0) {
+ size += r;
+ }
+
+ assertEquals(FILE_SIZE_KB * 1024, size);
}
+
+ public void testReadProperty() throws Exception
+ {
+ // read
+ Property blob = testRoot.getProperty("blob");
+ InputStream blobStream = blob.getStream();
+
+ byte[] buff = new byte[1024];
+ int r = 0;
+ int size = 0;
+ while ((r = blobStream.read(buff))>=0) {
+ size += r;
+ }
+
+ assertEquals(FILE_SIZE_KB * 1024, size);
+ }
public void testUpdateProperty() throws Exception
{
More information about the exo-jcr-commits
mailing list