jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tri...@apache.org
Subject svn commit: r1569209 - in /jackrabbit/commons/filevault/trunk/vault-core/src: main/java/org/apache/jackrabbit/vault/fs/io/ main/java/org/apache/jackrabbit/vault/packaging/ main/java/org/apache/jackrabbit/vault/packaging/impl/ test/java/org/apache/jackr...
Date Tue, 18 Feb 2014 06:19:43 GMT
Author: tripod
Date: Tue Feb 18 06:19:43 2014
New Revision: 1569209

URL: http://svn.apache.org/r1569209
Log:
JCRVLT-30 Allow package definition to specify recursive install behavior

Added:
    jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/packaging/SubPackageHandling.java
    jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/SubPackageHandlingTest.java
    jackrabbit/commons/filevault/trunk/vault-core/src/test/resources/org/apache/jackrabbit/vault/packaging/integration/testpackages/subtest_extract_a.zip
    jackrabbit/commons/filevault/trunk/vault-core/src/test/resources/org/apache/jackrabbit/vault/packaging/integration/testpackages/subtest_ignore_a.zip
Modified:
    jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/io/ImportOptions.java
    jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/packaging/PackageProperties.java
    jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/packaging/impl/JcrPackageImpl.java
    jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/packaging/impl/PackagePropertiesImpl.java
    jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/TestSubPackages.java

Modified: jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/io/ImportOptions.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/io/ImportOptions.java?rev=1569209&r1=1569208&r2=1569209&view=diff
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/io/ImportOptions.java
(original)
+++ jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/io/ImportOptions.java
Tue Feb 18 06:19:43 2014
@@ -152,10 +152,20 @@ public class ImportOptions {
         this.acHandling = acHandling;
     }
 
+    /**
+     * Defines the package installation should recursively install sub packages. Note that
if this flag is enabled,
+     * the {@link org.apache.jackrabbit.vault.packaging.SubPackageHandling} configuration
has no effect, as sub packages
+     * are not evaluated at all.
+     *
+     * @return {@code true} if package installation should not install sub packages.
+     */
     public boolean isNonRecursive() {
         return nonRecursive;
     }
 
+    /**
+     * @see #isNonRecursive()
+     */
     public void setNonRecursive(boolean nonRecursive) {
         this.nonRecursive = nonRecursive;
     }

Modified: jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/packaging/PackageProperties.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/packaging/PackageProperties.java?rev=1569209&r1=1569208&r2=1569209&view=diff
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/packaging/PackageProperties.java
(original)
+++ jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/packaging/PackageProperties.java
Tue Feb 18 06:19:43 2014
@@ -123,6 +123,12 @@ public interface PackageProperties {
     String NAME_DISABLE_INTERMEDIATE_SAVE = "noIntermediateSaves";
 
     /**
+     * Name of the flag that configures the sub package handling
+     * @since 3.1
+     */
+    String NAME_SUB_PACKAGE_HANDLING = "subPackageHandling";
+
+    /**
      * the prefix for an install hook property. eg:
      * 'installhook.test1.class = ....'
      */
@@ -199,6 +205,12 @@ public interface PackageProperties {
     AccessControlHandling getACHandling();
 
     /**
+     * Returns the sub package handling configuration
+     * @return the sub package handling configuration.
+     */
+    SubPackageHandling getSubPackageHandling();
+
+    /**
      * Returns the date property with the given name or {@code null} if it does not exist
or if the value cannot be
      * converted to a date.
      * @param name the property name

Added: jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/packaging/SubPackageHandling.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/packaging/SubPackageHandling.java?rev=1569209&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/packaging/SubPackageHandling.java
(added)
+++ jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/packaging/SubPackageHandling.java
Tue Feb 18 06:19:43 2014
@@ -0,0 +1,187 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.vault.packaging;
+
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.apache.jackrabbit.util.Text;
+
+/**
+ * The sub package handling specifies how sub package are handled during recursive package
installation. This
+ * configuration consists of a list of {@link org.apache.jackrabbit.vault.packaging.SubPackageHandling.Entry}s
that
+ * match against a given {@link org.apache.jackrabbit.vault.packaging.PackageId}. The version
of the package id is
+ * ignored.
+ * <p/>
+ * The sub package handling can be specified in the package properties as a string of the
following format:
+ * <xmp>
+ *     subPackageHandling := instruction { "," instruction };
+ *     instruction := packageIdFilter { ";" option }
+ *     packageIdFilter := packageNameFilter | groupNameFilter ":" packageNameFilter;
+ *     groupNameFilter := "*" | groupName;
+ *     packageNameFilter := "*" | packageName;
+ *     option := "install" | "extract" | "add" | "ignore";
+ * </xmp>
+ *
+ *  Note that 'ignore' is currently not really supported as sub packages are part of the
normal package content and
+ *  behaves the same as 'add'. Future implementations will transport the sub packages outside
of the normal package
+ *  content, e.g. in a META-INF/vault/subpackages/ folder (see JCRVLT-33).
+ */
+public class SubPackageHandling {
+
+    /**
+     * The sub package option
+     */
+    public enum Option {
+        /**
+         * adds and installs the package using {@link JcrPackage#install(org.apache.jackrabbit.vault.fs.io.ImportOptions)}
+         */
+        INSTALL,
+
+        /**
+         * adds and extracts the package using {@link JcrPackage#extract(org.apache.jackrabbit.vault.fs.io.ImportOptions)}
+         */
+        EXTRACT,
+
+        /**
+         * adds the package using {@link JcrPackageManager#upload}
+         */
+        ADD,
+
+        /**
+         * ignores the sub package completely
+         */
+        IGNORE
+    }
+
+    public static class Entry {
+
+        private final String groupName;
+
+        private final String packageName;
+
+        private final Option option;
+
+        public Entry(String groupName, String packageName, Option option) {
+            this.groupName = groupName == null || groupName.isEmpty() ? "*" : groupName;
+            this.packageName = packageName == null || packageName.isEmpty() ? "*" : packageName;
+            this.option = option;
+        }
+
+        public String getGroupName() {
+            return groupName;
+        }
+
+        public String getPackageName() {
+            return packageName;
+        }
+
+        public Option getOption() {
+            return option;
+        }
+    }
+
+    /**
+     * The default handling
+     */
+    public static final SubPackageHandling DEFAULT = new SubPackageHandling(Collections.<Entry>emptyList());
+
+    private final List<Entry> entries;
+
+    public SubPackageHandling() {
+        this(new LinkedList<Entry>());
+    }
+
+    private SubPackageHandling(List<Entry> entries) {
+        this.entries = entries;
+    }
+
+    /**
+     * Parses a options string as described above and returns a new SubPackageHandling instance.
+     * @param str the string to parse
+     * @return the configuration or {@code null} if the string is malformed.
+     */
+    public static SubPackageHandling fromString(String str) {
+        if (str == null || str.isEmpty()) {
+            return SubPackageHandling.DEFAULT;
+        }
+        SubPackageHandling sp = new SubPackageHandling();
+        for (String instruction: Text.explode(str, ',')) {
+            String[] opts = Text.explode(instruction.trim(), ';');
+            if (opts.length >  0) {
+                PackageId id = PackageId.fromString(opts[0]);
+                Option opt = Option.INSTALL;
+                if (opts.length > 1) {
+                    try {
+                        opt = Option.valueOf(opts[1].toUpperCase());
+                    } catch (IllegalArgumentException e) {
+                        // ignore
+                    }
+                }
+                sp.getEntries().add(new Entry(id.getGroup(), id.getName(), opt));
+            }
+        }
+        return sp;
+    }
+
+    /**
+     * Gets the option from the entries list that matches the package last. If no entry match,
it returns
+     * {@link org.apache.jackrabbit.vault.packaging.SubPackageHandling.Option#INSTALL}
+     * @param id the package id to match
+     * @return the option.
+     */
+    public Option getOption(PackageId id) {
+        Option opt = null;
+        for (Entry e: entries) {
+            if (!"*".equals(e.groupName) && !id.getGroup().equals(e.groupName)) {
+                continue;
+            }
+            if (!"*".equals(e.packageName) && !id.getName().equals(e.packageName))
{
+                continue;
+            }
+            opt = e.option;
+        }
+        return opt == null ? Option.INSTALL : opt;
+    }
+
+    /**
+     * Returns the modifiable list of entries.
+     * @return the list of entries
+     */
+    public List<Entry> getEntries() {
+        return entries;
+    }
+
+    /**
+     * Returns the parseable string representation of this configuration.
+     * @return the string representation.
+     */
+    public String getString() {
+        StringBuilder sb = new StringBuilder();
+        for (Entry e: entries) {
+            if (sb.length() > 0) {
+                sb.append(",");
+            }
+            sb.append(e.getGroupName()).append(":").append(e.getPackageName());
+            if (e.option != Option.INSTALL) {
+                sb.append(';').append(e.option.toString().toLowerCase());
+            }
+        }
+        return sb.toString();
+    }
+}
\ No newline at end of file

Modified: jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/packaging/impl/JcrPackageImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/packaging/impl/JcrPackageImpl.java?rev=1569209&r1=1569208&r2=1569209&view=diff
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/packaging/impl/JcrPackageImpl.java
(original)
+++ jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/packaging/impl/JcrPackageImpl.java
Tue Feb 18 06:19:43 2014
@@ -48,6 +48,7 @@ import org.apache.jackrabbit.vault.packa
 import org.apache.jackrabbit.vault.packaging.JcrPackageDefinition;
 import org.apache.jackrabbit.vault.packaging.PackageException;
 import org.apache.jackrabbit.vault.packaging.PackageId;
+import org.apache.jackrabbit.vault.packaging.SubPackageHandling;
 import org.apache.jackrabbit.vault.packaging.VaultPackage;
 import org.apache.jackrabbit.vault.util.JcrConstants;
 import org.apache.jackrabbit.vault.util.Text;
@@ -380,7 +381,7 @@ public class JcrPackageImpl implements J
         // get a copy of the import options (bug 35164)
         ImportOptions opts = options.copy();
         // check for disable intermediate saves (GRANITE-1047)
-        if ( this.getDefinition().getBoolean(JcrPackageDefinition.PN_DISABLE_INTERMEDIATE_SAVE)
) {
+        if (this.getDefinition().getBoolean(JcrPackageDefinition.PN_DISABLE_INTERMEDIATE_SAVE)
) {
             // MAX_VALUE disables saving completely, therefore we have to use a lower value!
             opts.setAutoSaveThreshold(Integer.MAX_VALUE - 1);
         }
@@ -427,10 +428,21 @@ public class JcrPackageImpl implements J
                     throw e;
                 }
             }
-            String[] subIds = new String[subPacks.size()];
-            int i=0;
+            List<String> subIds = new LinkedList<String>();
+            SubPackageHandling sb = pack.getSubPackageHandling();
             for (JcrPackageImpl p: subPacks) {
-                String msg = "Starting extraction of subpackage " + p.getPackage().getId();
+                boolean skip = false;
+                PackageId id = p.getPackage().getId();
+                SubPackageHandling.Option option = sb.getOption(id);
+                String msg;
+                if (option == SubPackageHandling.Option.ADD || option == SubPackageHandling.Option.IGNORE)
{
+                    msg = "skipping installation of subpackage " + id + " due to option "
+ option;
+                    skip = true;
+                } else if (option == SubPackageHandling.Option.INSTALL) {
+                    msg = "Starting installation of subpackage " + id;
+                } else {
+                    msg = "Starting extraction of subpackage " + id;
+                }
                 if (options.isDryRun()) {
                     msg = "Dry run: " + msg;
                 }
@@ -439,13 +451,19 @@ public class JcrPackageImpl implements J
                 } else {
                     log.info(msg);
                 }
-                p.extract(options, createSnapshot, true);
+                if (!skip) {
+                    if (createSnapshot && option == SubPackageHandling.Option.INSTALL)
{
+                        p.extract(options, true, true);
+                        subIds.add(id.toString());
+                    } else {
+                        p.extract(options, false, true);
+                    }
+                }
                 p.close();
-                subIds[i++] = p.getDefinition().getId().toString();
             }
             // register sub packages in snapshot for uninstall
             if (snap != null) {
-                snap.getDefinition().getNode().setProperty(JcrPackageDefinition.PN_SUB_PACKAGES,
subIds);
+                snap.getDefinition().getNode().setProperty(JcrPackageDefinition.PN_SUB_PACKAGES,
subIds.toArray(new String[subIds.size()]));
                 snap.getDefinition().getNode().save();
             }
         }

Modified: jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/packaging/impl/PackagePropertiesImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/packaging/impl/PackagePropertiesImpl.java?rev=1569209&r1=1569208&r2=1569209&view=diff
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/packaging/impl/PackagePropertiesImpl.java
(original)
+++ jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/packaging/impl/PackagePropertiesImpl.java
Tue Feb 18 06:19:43 2014
@@ -25,6 +25,7 @@ import org.apache.jackrabbit.vault.fs.io
 import org.apache.jackrabbit.vault.packaging.Dependency;
 import org.apache.jackrabbit.vault.packaging.PackageId;
 import org.apache.jackrabbit.vault.packaging.PackageProperties;
+import org.apache.jackrabbit.vault.packaging.SubPackageHandling;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -132,6 +133,13 @@ public abstract class PackagePropertiesI
     /**
      * {@inheritDoc}
      */
+    public SubPackageHandling getSubPackageHandling() {
+        return SubPackageHandling.fromString(getProperty(NAME_SUB_PACKAGE_HANDLING));
+    }
+
+    /**
+     * {@inheritDoc}
+     */
     public boolean requiresRoot() {
         return "true".equals(getProperty(NAME_REQUIRES_ROOT));
     }

Added: jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/SubPackageHandlingTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/SubPackageHandlingTest.java?rev=1569209&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/SubPackageHandlingTest.java
(added)
+++ jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/SubPackageHandlingTest.java
Tue Feb 18 06:19:43 2014
@@ -0,0 +1,93 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jackrabbit.vault.packaging;
+
+import junit.framework.TestCase;
+
+/**
+ * <code>SubPackageHandlingTest</code>...
+ */
+public class SubPackageHandlingTest extends TestCase {
+
+    public void testDefault() {
+        SubPackageHandling sp = new SubPackageHandling();
+        assertEquals(SubPackageHandling.Option.INSTALL, sp.getOption(PackageId.fromString("foo:bar")));
+        assertEquals(SubPackageHandling.Option.INSTALL, sp.getOption(PackageId.fromString("foo:bar:1.0")));
+    }
+
+    public void testStaticDefault() {
+        SubPackageHandling sp = SubPackageHandling.DEFAULT;
+        assertEquals(SubPackageHandling.Option.INSTALL, sp.getOption(PackageId.fromString("foo:bar")));
+        assertEquals(SubPackageHandling.Option.INSTALL, sp.getOption(PackageId.fromString("foo:bar:1.0")));
+    }
+
+    public void testMatchAll() {
+        SubPackageHandling sp = new SubPackageHandling();
+        sp.getEntries().add(new SubPackageHandling.Entry("*", "*", SubPackageHandling.Option.ADD));
+        assertEquals(SubPackageHandling.Option.ADD, sp.getOption(PackageId.fromString("foo:bar")));
+        assertEquals(SubPackageHandling.Option.ADD, sp.getOption(PackageId.fromString("foo:bar:1.0")));
+    }
+
+    public void testMatchAllGroup() {
+        SubPackageHandling sp = new SubPackageHandling();
+        sp.getEntries().add(new SubPackageHandling.Entry("foo", "*", SubPackageHandling.Option.ADD));
+        assertEquals(SubPackageHandling.Option.ADD, sp.getOption(PackageId.fromString("foo:bar")));
+        assertEquals(SubPackageHandling.Option.ADD, sp.getOption(PackageId.fromString("foo:baz")));
+        assertEquals(SubPackageHandling.Option.INSTALL, sp.getOption(PackageId.fromString("noo:bar:1.0")));
+    }
+
+    public void testMatchAllPackage() {
+        SubPackageHandling sp = new SubPackageHandling();
+        sp.getEntries().add(new SubPackageHandling.Entry("*", "bar", SubPackageHandling.Option.ADD));
+        assertEquals(SubPackageHandling.Option.ADD, sp.getOption(PackageId.fromString("foo:bar")));
+        assertEquals(SubPackageHandling.Option.ADD, sp.getOption(PackageId.fromString("loo:bar")));
+        assertEquals(SubPackageHandling.Option.INSTALL, sp.getOption(PackageId.fromString("foo:baz:1.0")));
+    }
+
+    public void testMatchSpecific() {
+        SubPackageHandling sp = new SubPackageHandling();
+        sp.getEntries().add(new SubPackageHandling.Entry("foo", "bar", SubPackageHandling.Option.ADD));
+        assertEquals(SubPackageHandling.Option.ADD, sp.getOption(PackageId.fromString("foo:bar")));
+        assertEquals(SubPackageHandling.Option.INSTALL, sp.getOption(PackageId.fromString("zoo:bar")));
+        assertEquals(SubPackageHandling.Option.INSTALL, sp.getOption(PackageId.fromString("foo:baz:1.0")));
+    }
+
+    public void testMatchOrder() {
+        SubPackageHandling sp = new SubPackageHandling();
+        sp.getEntries().add(new SubPackageHandling.Entry("foo", "*", SubPackageHandling.Option.ADD));
+        sp.getEntries().add(new SubPackageHandling.Entry("foo", "bar", SubPackageHandling.Option.EXTRACT));
+        assertEquals(SubPackageHandling.Option.ADD, sp.getOption(PackageId.fromString("foo:baz")));
+        assertEquals(SubPackageHandling.Option.EXTRACT, sp.getOption(PackageId.fromString("foo:bar")));
+    }
+
+    public void testParse() {
+        assertEquals("", SubPackageHandling.fromString("").getString());
+        assertEquals("foo:bar", SubPackageHandling.fromString("foo:bar").getString());
+        assertEquals("*:bar", SubPackageHandling.fromString("*:bar").getString());
+        assertEquals("*:bar", SubPackageHandling.fromString(":bar").getString());
+        assertEquals("*:bar", SubPackageHandling.fromString("bar").getString());
+        assertEquals("foo:*", SubPackageHandling.fromString("foo:*").getString());
+        assertEquals("*:*", SubPackageHandling.fromString("*:*").getString());
+        assertEquals("foo:bar;add", SubPackageHandling.fromString("foo:bar;add").getString());
+        assertEquals("foo:bar;extract", SubPackageHandling.fromString("foo:bar;extract").getString());
+        assertEquals("foo:bar;ignore", SubPackageHandling.fromString("foo:bar;ignore").getString());
+        assertEquals("foo:bar", SubPackageHandling.fromString("foo:bar;illegal").getString());
+        assertEquals("foo:bar", SubPackageHandling.fromString("foo:bar;install").getString());
+        assertEquals("*:*,foo:bar;add", SubPackageHandling.fromString("*;install,foo:bar;add").getString());
+    }
+}
\ No newline at end of file

Modified: jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/TestSubPackages.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/TestSubPackages.java?rev=1569209&r1=1569208&r2=1569209&view=diff
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/TestSubPackages.java
(original)
+++ jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/TestSubPackages.java
Tue Feb 18 06:19:43 2014
@@ -51,11 +51,62 @@ public class TestSubPackages extends Int
         assertNodeExists("/etc/packages/my_packages/sub_a.zip");
         assertNodeExists("/etc/packages/my_packages/sub_b.zip");
 
+        // check for snapshots
+        assertNodeMissing("/etc/packages/my_packages/.snapshot/sub_a.zip");
+        assertNodeMissing("/etc/packages/my_packages/.snapshot/sub_b.zip");
+
         assertNodeMissing("/tmp/a");
         assertNodeMissing("/tmp/b");
     }
 
     /**
+     * Installs a package that contains sub packages recursive but has a sub package handling
that ignores A
+     */
+    @Test
+    public void testRecursiveIgnoreA() throws RepositoryException, IOException, PackageException
{
+        JcrPackage pack = packMgr.upload(getStream("testpackages/subtest_ignore_a.zip"),
false);
+        assertNotNull(pack);
+
+        // install
+        ImportOptions opts = getDefaultOptions();
+        opts.setNonRecursive(false);
+        pack.install(opts);
+
+        // check for sub packages
+        assertNodeExists("/etc/packages/my_packages/sub_a.zip"); // todo: ignore should ignore
A completely
+        assertNodeExists("/etc/packages/my_packages/sub_b.zip");
+
+        assertNodeMissing("/tmp/a");
+        assertNodeExists("/tmp/b");
+    }
+
+    /**
+     * Installs a package that contains sub packages recursive but has a sub package handling
that only extracts A
+     */
+    @Test
+    public void testRecursiveExtractA() throws RepositoryException, IOException, PackageException
{
+        JcrPackage pack = packMgr.upload(getStream("testpackages/subtest_extract_a.zip"),
false);
+        assertNotNull(pack);
+
+        // install
+        ImportOptions opts = getDefaultOptions();
+        opts.setNonRecursive(false);
+        pack.install(opts);
+
+        // check for sub packages
+        assertNodeExists("/etc/packages/my_packages/sub_a.zip");
+        assertNodeExists("/etc/packages/my_packages/sub_b.zip");
+
+        // check for snapshots
+        assertNodeMissing("/etc/packages/my_packages/.snapshot/sub_a.zip");
+        assertNodeExists("/etc/packages/my_packages/.snapshot/sub_b.zip");
+
+        assertNodeExists("/tmp/a");
+        assertNodeExists("/tmp/b");
+    }
+
+
+    /**
      * Installs a package that contains sub packages recursive
      */
     @Test
@@ -72,6 +123,10 @@ public class TestSubPackages extends Int
         assertNodeExists("/etc/packages/my_packages/sub_a.zip");
         assertNodeExists("/etc/packages/my_packages/sub_b.zip");
 
+        // check for snapshots
+        assertNodeExists("/etc/packages/my_packages/.snapshot/sub_a.zip");
+        assertNodeExists("/etc/packages/my_packages/.snapshot/sub_b.zip");
+
         assertNodeExists("/tmp/a");
         assertNodeExists("/tmp/b");
     }

Added: jackrabbit/commons/filevault/trunk/vault-core/src/test/resources/org/apache/jackrabbit/vault/packaging/integration/testpackages/subtest_extract_a.zip
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-core/src/test/resources/org/apache/jackrabbit/vault/packaging/integration/testpackages/subtest_extract_a.zip?rev=1569209&view=auto
==============================================================================
Files jackrabbit/commons/filevault/trunk/vault-core/src/test/resources/org/apache/jackrabbit/vault/packaging/integration/testpackages/subtest_extract_a.zip
(added) and jackrabbit/commons/filevault/trunk/vault-core/src/test/resources/org/apache/jackrabbit/vault/packaging/integration/testpackages/subtest_extract_a.zip
Tue Feb 18 06:19:43 2014 differ

Added: jackrabbit/commons/filevault/trunk/vault-core/src/test/resources/org/apache/jackrabbit/vault/packaging/integration/testpackages/subtest_ignore_a.zip
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-core/src/test/resources/org/apache/jackrabbit/vault/packaging/integration/testpackages/subtest_ignore_a.zip?rev=1569209&view=auto
==============================================================================
Files jackrabbit/commons/filevault/trunk/vault-core/src/test/resources/org/apache/jackrabbit/vault/packaging/integration/testpackages/subtest_ignore_a.zip
(added) and jackrabbit/commons/filevault/trunk/vault-core/src/test/resources/org/apache/jackrabbit/vault/packaging/integration/testpackages/subtest_ignore_a.zip
Tue Feb 18 06:19:43 2014 differ



Mime
View raw message