jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tri...@apache.org
Subject svn commit: r1726930 - in /jackrabbit/commons/filevault/trunk/vault-core/src/test: java/org/apache/jackrabbit/vault/packaging/integration/ resources/org/apache/jackrabbit/vault/packaging/integration/testpackages/
Date Wed, 27 Jan 2016 01:15:04 GMT
Author: tripod
Date: Wed Jan 27 01:15:04 2016
New Revision: 1726930

URL: http://svn.apache.org/viewvc?rev=1726930&view=rev
Log:
trivial: adding more test cases

Added:
    jackrabbit/commons/filevault/trunk/vault-core/src/test/resources/org/apache/jackrabbit/vault/packaging/integration/testpackages/tmp_binary.zip
Modified:
    jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/TestBinarylessExport.java
    jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/TestPackageInstall.java
    jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/TestUserContentPackage.java

Modified: jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/TestBinarylessExport.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/TestBinarylessExport.java?rev=1726930&r1=1726929&r2=1726930&view=diff
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/TestBinarylessExport.java
(original)
+++ jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/TestBinarylessExport.java
Wed Jan 27 01:15:04 2016
@@ -50,20 +50,28 @@ import static org.junit.Assert.assertTru
  */
 public class TestBinarylessExport extends IntegrationTestBase {
 
-    private final String BIG_TEXT = "Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Suspendisse vel dui in elit venenatis dictum sed nec arcu. Phasellus aliquam imperdiet tincidunt.
Vestibulum lacinia mollis mi. Cras non metus.";
-    private final String SMALL_TEXT = "Lorem ipsum";
-    private final String BINARY_NODE_PATH = "/tmp/binaryless/node";
-    private final String BIG_BINARY_PROPERTY = "bigbin";
-    private final String SMALL_BINARY_PROPERTY = "smallbin";
-
-    private final String FILE_NODE_PATH = "/tmp/binaryless/file";
-
-
+    private final static String SMALL_TEXT = "Lorem ipsum";
+    private final static String BINARY_NODE_PATH = "/tmp/binaryless/node";
+    private final static String BIG_BINARY_PROPERTY = "bigbin";
+    private final static String SMALL_BINARY_PROPERTY = "smallbin";
+
+    private final static String FILE_NODE_PATH = "/tmp/binaryless/file";
+
+
+    private final static int BIG_TEXT_LENGTH = 0x1000 * 64;
+    private final static String BIG_TEXT;
+    static {
+        StringBuilder buffer = new StringBuilder(BIG_TEXT_LENGTH);
+        buffer.append("0123456789abcdef");
+        while (buffer.length() < BIG_TEXT_LENGTH) {
+            buffer.append(buffer, 0, buffer.length());
+        }
+        BIG_TEXT = buffer.toString();
+    }
 
 
     @Before
     public void setup() throws RepositoryException, PackageException, IOException {
-
         Node binaryNode = JcrUtils.getOrCreateByPath(BINARY_NODE_PATH, "nt:unstructured",
admin);
 
         Binary bigBin = admin.getValueFactory().createBinary(IOUtils.toInputStream(BIG_TEXT,
"UTF-8"));

Modified: jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/TestPackageInstall.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/TestPackageInstall.java?rev=1726930&r1=1726929&r2=1726930&view=diff
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/TestPackageInstall.java
(original)
+++ jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/TestPackageInstall.java
Wed Jan 27 01:15:04 2016
@@ -20,7 +20,10 @@ package org.apache.jackrabbit.vault.pack
 import java.io.File;
 import java.io.IOException;
 
+import javax.jcr.Binary;
 import javax.jcr.NodeIterator;
+import javax.jcr.Property;
+import javax.jcr.PropertyType;
 import javax.jcr.RepositoryException;
 
 import org.apache.commons.io.FileUtils;
@@ -373,6 +376,20 @@ public class TestPackageInstall extends
         }
     }
 
+    /**
+     * Installs a package that and checks if snapshot is created
+     */
+    @Test
+    public void testBinaryProperties() throws RepositoryException, IOException, PackageException
{
+        JcrPackage pack = packMgr.upload(getStream("testpackages/tmp_binary.zip"), false);
+        assertNotNull(pack);
+        pack.install(getDefaultOptions());
+
+        Property p = admin.getProperty("/tmp/binary/test/jcr:data");
+        assertEquals(PropertyType.BINARY, p.getType());
+        assertEquals("this is binary data.\n", p.getString());
+    }
+
     // todo: upload with version
     // todo: rename
 

Modified: jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/TestUserContentPackage.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/TestUserContentPackage.java?rev=1726930&r1=1726929&r2=1726930&view=diff
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/TestUserContentPackage.java
(original)
+++ jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/TestUserContentPackage.java
Wed Jan 27 01:15:04 2016
@@ -299,7 +299,7 @@ public class TestUserContentPackage exte
         User u = mgr.createUser(ID_TEST_USER_A, "nonce");
         Node node = admin.getNode(u.getPath());
 
-        node.setProperty("mv", new String[]{"mv1"});
+        node.setProperty("mv", new String[]{"mv1", "mv2"});
         Property property = node.getProperty("mv");
         assertTrue(property.isMultiple());
         admin.save();
@@ -325,6 +325,35 @@ public class TestUserContentPackage exte
 
     }
 
+    @Test
+    public void install_single_mv_property() throws RepositoryException, IOException, PackageException
{
+        UserManager mgr = ((JackrabbitSession) admin).getUserManager();
+        User u = mgr.createUser(ID_TEST_USER_A, "nonce");
+        Node node = admin.getNode(u.getPath());
+
+        node.setProperty("mv", new String[]{"mv1"});
+        Property property = node.getProperty("mv");
+        assertTrue(property.isMultiple());
+        admin.save();
+
+        File tmpFile = createPackage("test", "test", u.getPath());
+        u.remove();
+        u = (User)  mgr.getAuthorizable(ID_TEST_USER_A);
+        assertNull(u);
+
+        JcrPackage pack = packMgr.upload(tmpFile, true, true, null);
+        assertNotNull(pack);
+        ImportOptions opts = getDefaultOptions();
+        pack.install(opts);
+
+        u = (User)  mgr.getAuthorizable(ID_TEST_USER_A);
+        assertNotNull(u);
+
+        node = admin.getNode(u.getPath());
+        property = node.getProperty("mv");
+        assertTrue(property.isMultiple());
+    }
+
 
     private User installUserA(ImportMode mode, boolean usePkgPath, boolean expectPkgPath)
throws RepositoryException, IOException, PackageException {
         UserManager mgr = ((JackrabbitSession) admin).getUserManager();
@@ -407,7 +436,7 @@ public class TestUserContentPackage exte
 
         opts.setMetaInf(inf);
 
-        File tmpFile = File.createTempFile("vaulttest", "zip");
+        File tmpFile = File.createTempFile("vaulttest", ".zip");
         VaultPackage pkg = packMgr.assemble(admin, opts, tmpFile);
 
         pkg.close();

Added: jackrabbit/commons/filevault/trunk/vault-core/src/test/resources/org/apache/jackrabbit/vault/packaging/integration/testpackages/tmp_binary.zip
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-core/src/test/resources/org/apache/jackrabbit/vault/packaging/integration/testpackages/tmp_binary.zip?rev=1726930&view=auto
==============================================================================
Binary files jackrabbit/commons/filevault/trunk/vault-core/src/test/resources/org/apache/jackrabbit/vault/packaging/integration/testpackages/tmp_binary.zip
(added) and jackrabbit/commons/filevault/trunk/vault-core/src/test/resources/org/apache/jackrabbit/vault/packaging/integration/testpackages/tmp_binary.zip
Wed Jan 27 01:15:04 2016 differ



Mime
View raw message