jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tomm...@apache.org
Subject svn commit: r1803252 - in /jackrabbit/commons/filevault/trunk/vault-core/src: main/java/org/apache/jackrabbit/vault/fs/api/ main/java/org/apache/jackrabbit/vault/fs/io/ test/java/org/apache/jackrabbit/vault/fs/api/ test/java/org/apache/jackrabbit/vault...
Date Fri, 28 Jul 2017 09:01:25 GMT
Author: tommaso
Date: Fri Jul 28 09:01:25 2017
New Revision: 1803252

URL: http://svn.apache.org/viewvc?rev=1803252&view=rev
Log:
JCRVLT-196 - this closes apache/jackrabbit-filevault#12

Added:
    jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/api/RegexpPathMapping.java
  (with props)
    jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/io/MappedArchive.java
  (with props)
Modified:
    jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/api/package-info.java
    jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/io/Importer.java
    jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/io/package-info.java
    jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/fs/api/PathMappingTest.java
    jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/TestMappedImport.java
    jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/TestPackageInstall.java

Added: jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/api/RegexpPathMapping.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/api/RegexpPathMapping.java?rev=1803252&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/api/RegexpPathMapping.java
(added)
+++ jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/api/RegexpPathMapping.java
Fri Jul 28 09:01:25 2017
@@ -0,0 +1,112 @@
+/*
+ * 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.fs.api;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.apache.jackrabbit.vault.fs.api.PathMapping;
+
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+
+/**
+ * Implements a path mapping that supports regular expressions, i.e. {@code /etc/(.*)=/dummy/$1/custom}
+ * @since 3.1.42
+ */
+public final class RegexpPathMapping implements PathMapping {
+
+    private final Map<Pattern, String> pathsMapping = new HashMap<Pattern, String>();
+
+    /**
+     * Allows importing mappings specified in data structure such as Map or Properties.
+     *
+     * All null entries (both keys and values) are ignored.
+     *
+     * @param pathsMappingMap the data structure containing the mapping
+     * @return this
+     */
+    public <K, V> RegexpPathMapping addAllMappings(@Nonnull Map<K, V> pathsMappingMap)
{
+        for (Entry<K, V> entry : pathsMappingMap.entrySet()) {
+            final K key = entry.getKey();
+            final V value = entry.getValue();
+            if (key != null && value != null) {
+                addMapping(String.valueOf(key), String.valueOf(value));
+            }
+        }
+        return this;
+    }
+
+    /**
+     * Add a new mapping based on regular expression.
+     *
+     * @param fromPattern the matching pattern, i.e. <code>/etc/(.*)</code>
+     * @param toPattern the replacing pattern, i.e. <code>/dummy/$1/custom</code>
+     * @return this
+     */
+    @Nonnull
+    public RegexpPathMapping addMapping(@Nonnull String fromPattern, @Nonnull String toPattern)
{
+        pathsMapping.put(Pattern.compile(fromPattern), toPattern);
+        return this;
+    }
+
+    /**
+     * Merges the regexp mapping from the given base mapping.
+     *
+     * @param base base mapping
+     * @return this
+     */
+    @Nonnull
+    public RegexpPathMapping merge(@Nullable RegexpPathMapping base) {
+        if (base != null) {
+            this.pathsMapping.putAll(base.pathsMapping);
+        }
+        return this;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    @Nonnull
+    public String map(@Nonnull String path) {
+        return map(path, false);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    @Nonnull
+    public String map(@Nonnull String path, boolean reverse) {
+        if (reverse) {
+            throw new IllegalArgumentException("path mapping cannot be reversed with the
regexp mapping");
+        } else {
+            for (Entry<Pattern, String> pathMapping : pathsMapping.entrySet()) {
+                Matcher matcher = pathMapping.getKey().matcher(path);
+                if (matcher.matches()) {
+                    return matcher.replaceAll(pathMapping.getValue());
+                }
+            }
+            return path;
+        }
+    }
+
+}

Propchange: jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/api/RegexpPathMapping.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/api/package-info.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/api/package-info.java?rev=1803252&r1=1803251&r2=1803252&view=diff
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/api/package-info.java
(original)
+++ jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/api/package-info.java
Fri Jul 28 09:01:25 2017
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-@Version("2.4.0")
+@Version("2.5.0")
 package org.apache.jackrabbit.vault.fs.api;
 
 import org.osgi.annotation.versioning.Version;
\ No newline at end of file

Modified: jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/io/Importer.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/io/Importer.java?rev=1803252&r1=1803251&r2=1803252&view=diff
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/io/Importer.java
(original)
+++ jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/io/Importer.java
Fri Jul 28 09:01:25 2017
@@ -227,11 +227,6 @@ public class Importer {
     private final ImportOptions opts;
 
     /**
-     * path mapping from the import options
-     */
-    private PathMapping pathMapping;
-
-    /**
      * the checkpoint state of the autosave. used for recovering from stale item errors during
install.
      */
     private AutoSave cpAutosave;
@@ -366,11 +361,11 @@ public class Importer {
         }
 
         // check path remapping
-        pathMapping = opts.getPathMapping();
+        PathMapping pathMapping = opts.getPathMapping();
         if (pathMapping != null) {
             filter = filter.translate(pathMapping);
-        } else {
-            pathMapping = PathMapping.IDENTITY;
+            this.archive = archive = new MappedArchive(archive, pathMapping);
+            this.archive.open(true);
         }
 
         // set import mode if possible
@@ -594,9 +589,7 @@ public class Importer {
     private void prepare(Archive.Entry directory, TxInfo parentInfo, NamespaceResolver resolver)
             throws IOException, RepositoryException {
         Collection<? extends Archive.Entry> files = directory.getChildren();
-        if (files == null) {
-            return;
-        }
+
         // first process the directories
         for (Archive.Entry file: files) {
             if (file.isDirectory()) {
@@ -612,19 +605,6 @@ public class Importer {
                     repoPath = parentInfo.path + "/" + repoName;
                 }
 
-                // remap if needed
-                String mappedPath = pathMapping.map(repoPath);
-                if (!mappedPath.equals(repoPath)) {
-                    String mappedParent = Text.getRelativeParent(mappedPath, 1);
-                    if (!mappedParent.equals(parentInfo.path)) {
-                        log.warn("remapping other than renames not supported yet ({} ->
{}).", repoPath, mappedPath);
-                    } else {
-                        log.debug("remapping detected {} -> {}", repoPath, mappedPath);
-                        repoPath = mappedPath;
-                        repoName = Text.getName(repoPath);
-                    }
-                }
-
                 TxInfo info = parentInfo.addChild(new TxInfo(parentInfo, repoPath));
                 log.trace("Creating directory artifact for {}", repoName);
                 Artifact parent = new DirectoryArtifact(repoName);
@@ -676,19 +656,6 @@ public class Importer {
                     subPackages.add(repoPath);
                 }
 
-                // remap if needed
-                String mappedPath = pathMapping.map(repoPath);
-                if (!mappedPath.equals(repoPath)) {
-                    String mappedParent = Text.getRelativeParent(mappedPath, 1);
-                    if (!mappedParent.equals(parentInfo.path)) {
-                        log.warn("remapping other than renames not supported yet ({} ->
{}).", repoPath, mappedPath);
-                    } else {
-                        log.debug("remapping detected {} -> {}", repoPath, mappedPath);
-                        repoPath = mappedPath;
-                        repoName = Text.getName(repoPath);
-                    }
-                }
-
                 String repoBase = repoName;
                 String ext = "";
                 int idx = repoName.lastIndexOf('.');

Added: jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/io/MappedArchive.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/io/MappedArchive.java?rev=1803252&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/io/MappedArchive.java
(added)
+++ jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/io/MappedArchive.java
Fri Jul 28 09:01:25 2017
@@ -0,0 +1,246 @@
+/*
+ * 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.fs.io;
+
+import org.apache.jackrabbit.vault.fs.api.PathMapping;
+import org.apache.jackrabbit.vault.fs.api.VaultInputSource;
+import org.apache.jackrabbit.vault.fs.config.MetaInf;
+import org.apache.jackrabbit.vault.util.Text;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.annotation.CheckForNull;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+/**
+ * Implements an archive that remaps the entries of an underlying archive using a {@link
PathMapping}.
+ */
+public class MappedArchive extends AbstractArchive {
+
+    /**
+     * default logger
+     */
+    private static final Logger log = LoggerFactory.getLogger(MappedArchive.class);
+
+    private final Archive base;
+
+    private final PathMapping mapping;
+
+    private final VirtualEntry root = new VirtualEntry();
+
+    private VirtualEntry jcrRoot;
+
+    public MappedArchive(Archive base, PathMapping mapping) {
+        this.base = base;
+        this.mapping = mapping;
+    }
+
+    @Override
+    public void open(boolean strict) throws IOException {
+        base.open(strict);
+        applyMapping(base.getRoot(), root);
+    }
+
+    /**
+     * Decorates the non jcr files without applying the mapping. this can be done with parallel
traversal.
+     * @param src source entry parent
+     * @param dst destination entry parent
+     */
+    private void applyMapping(@Nonnull Entry src, @Nonnull VirtualEntry dst) {
+        for (Entry child: src.getChildren()) {
+            VirtualEntry dstChild = dst.add(child.getName(), child);
+            if ("/jcr_root".equals(dstChild.getPath())) {
+                jcrRoot = dstChild;
+                applyMapping(child, "");
+            } else {
+                applyMapping(child, dstChild);
+            }
+        }
+    }
+
+    /**
+     * Decorates the jcr entries while applying the path mapping. this cannot be done with
parallel traversal, because
+     * the remapping could create holes in the entry tree.
+     *
+     * @param src the source entry
+     * @param jcrPath the jcr path of the source entry
+     */
+    private void applyMapping(@Nonnull Entry src, @Nonnull String jcrPath) {
+        for (Entry child: src.getChildren()) {
+            String path = jcrPath + "/" + child.getName();
+            String mappedPath = mapping.map(path);
+
+            // add entry to tree
+            String[] segments = Text.explode(mappedPath, '/');
+            VirtualEntry entry = jcrRoot;
+            for (String seg: segments) {
+                entry = entry.add(seg, null);
+            }
+            if (entry.baseEntry != null) {
+                log.warn("Path mapping maps multiple paths to the same destination: {} ->
{}. ignoring this source.", path, mappedPath);
+            } else {
+                entry.baseEntry = child;
+            }
+
+            applyMapping(child, path);
+        }
+    }
+
+    @Override
+    @CheckForNull
+    public InputStream openInputStream(@Nullable Entry entry) throws IOException {
+        if (entry == null) {
+            return null;
+        }
+        return base.openInputStream(((VirtualEntry) entry).baseEntry);
+    }
+
+    @Override
+    @CheckForNull
+    public VaultInputSource getInputSource(@Nullable Entry entry) throws IOException {
+        if (entry == null) {
+            return null;
+        }
+        return base.getInputSource(((VirtualEntry) entry).baseEntry);
+    }
+
+    @Override
+    @Nonnull
+    public Entry getRoot() throws IOException {
+        return root;
+    }
+
+    @Override
+    public Entry getJcrRoot() throws IOException {
+        return jcrRoot;
+    }
+
+    @Override
+    @Nonnull
+    public MetaInf getMetaInf() {
+        return base.getMetaInf();
+    }
+
+    @Override
+    public void close() {
+        base.close();
+    }
+
+    /**
+     * Implements a entry for this archive
+     */
+    private static class VirtualEntry implements Entry {
+
+        @Nullable
+        private final VirtualEntry parent;
+
+        @Nonnull
+        private final String name;
+
+        @Nullable
+        private Archive.Entry baseEntry;
+
+        @Nullable
+        private Map<String, VirtualEntry> children;
+
+        private VirtualEntry() {
+            this.parent = null;
+            this.name = "";
+            this.baseEntry = null;
+        }
+
+        private VirtualEntry(@Nonnull VirtualEntry parent, @Nonnull String name, @Nullable
Archive.Entry baseEntry) {
+            this.parent = parent;
+            this.name = name;
+            this.baseEntry = baseEntry;
+        }
+
+        /**
+         * {@inheritDoc}
+         */
+        @Override
+        @Nonnull
+        public String getName() {
+            return name;
+        }
+
+        @Nonnull
+        public String getPath() {
+            return getPath(new StringBuilder()).toString();
+        }
+
+        @Nonnull
+        private StringBuilder getPath(@Nonnull StringBuilder sb) {
+            return parent == null ? sb : parent.getPath(sb).append('/').append(name);
+        }
+
+        /**
+         * {@inheritDoc}
+         */
+        @Override
+        public boolean isDirectory() {
+            return baseEntry == null || baseEntry.isDirectory();
+        }
+
+        /**
+         * {@inheritDoc}
+         */
+        @Override
+        @Nonnull
+        public Collection<? extends Entry> getChildren() {
+            return children == null ? Collections.<Entry>emptyList() : children.values();
+        }
+
+        /**
+         * {@inheritDoc}
+         */
+        @Override
+        @Nullable
+        public Entry getChild(String name) {
+            return children == null ? null : children.get(name);
+        }
+
+        /**
+         * Adds a new child entry.
+         * @param name name
+         * @param baseEntry the base archive's entry or
+         * @return the new entry
+         */
+        @Nonnull
+        public VirtualEntry add(@Nonnull String name, @Nullable Archive.Entry baseEntry)
{
+            if (children != null) {
+                VirtualEntry ret = children.get(name);
+                if (ret != null) {
+                    return ret;
+                }
+            }
+            VirtualEntry ve = new VirtualEntry(this, name, baseEntry);
+            if (children == null) {
+                children = new LinkedHashMap<String, VirtualEntry>();
+            }
+            children.put(name, ve);
+            return ve;
+        }
+    }
+}
\ No newline at end of file

Propchange: jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/io/MappedArchive.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/io/package-info.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/io/package-info.java?rev=1803252&r1=1803251&r2=1803252&view=diff
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/io/package-info.java
(original)
+++ jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/io/package-info.java
Fri Jul 28 09:01:25 2017
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-@Version("2.5.0")
+@Version("2.6.0")
 package org.apache.jackrabbit.vault.fs.io;
 
 import org.osgi.annotation.versioning.Version;
\ No newline at end of file

Modified: jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/fs/api/PathMappingTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/fs/api/PathMappingTest.java?rev=1803252&r1=1803251&r2=1803252&view=diff
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/fs/api/PathMappingTest.java
(original)
+++ jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/fs/api/PathMappingTest.java
Fri Jul 28 09:01:25 2017
@@ -16,6 +16,8 @@
  */
 package org.apache.jackrabbit.vault.fs.api;
 
+import static org.junit.Assert.assertEquals;
+
 import org.junit.Test;
 
 import static junit.framework.Assert.assertEquals;
@@ -77,4 +79,19 @@ public class PathMappingTest {
         assertEquals("/dest/foo/1/top/flop", map.map("/test/flop", true));
 
     }
+
+    @Test
+    public void testRegexpIdentityMapping() {
+        RegexpPathMapping pathMapping = new RegexpPathMapping();
+        assertEquals("/etc/my/fake/data", pathMapping.map("/etc/my/fake/data"));
+    }
+
+    @Test
+    public void testRegexpCorrectMapping() {
+        RegexpPathMapping pathMapping = new RegexpPathMapping();
+        pathMapping.addMapping("/etc/(.*)", "/dummy/$1/custom");
+
+        assertEquals("/dummy/my/fake/data/custom", pathMapping.map("/etc/my/fake/data"));
+    }
+
 }
\ No newline at end of file

Modified: jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/TestMappedImport.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/TestMappedImport.java?rev=1803252&r1=1803251&r2=1803252&view=diff
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/TestMappedImport.java
(original)
+++ jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/TestMappedImport.java
Fri Jul 28 09:01:25 2017
@@ -22,6 +22,7 @@ import java.io.IOException;
 import javax.jcr.RepositoryException;
 
 import org.apache.jackrabbit.vault.fs.api.MultiPathMapping;
+import org.apache.jackrabbit.vault.fs.api.RegexpPathMapping;
 import org.apache.jackrabbit.vault.fs.io.ImportOptions;
 import org.apache.jackrabbit.vault.packaging.JcrPackage;
 import org.apache.jackrabbit.vault.packaging.PackageException;
@@ -29,6 +30,8 @@ import org.apache.jackrabbit.vault.packa
 import org.junit.Ignore;
 import org.junit.Test;
 
+import static org.junit.Assert.assertNotNull;
+
 /**
  */
 public class TestMappedImport extends IntegrationTestBase {
@@ -167,7 +170,6 @@ public class TestMappedImport extends In
      * Tests if a non-trivial rename remapping works.
      * This is currently not supported
      */
-    @Ignore("JCRVLT-78")
     @Test
     public void testNonRename() throws RepositoryException, IOException, PackageException
{
         JcrPackage pack = packMgr.upload(getStream("testpackages/tmp_foo.zip"), false);
@@ -178,7 +180,28 @@ public class TestMappedImport extends In
         opts.setPathMapping(mapping);
         pack.extract(opts);
 
-        assertNodeExists("/tmp/foo");
+        assertNodeMissing("/tmp/foo");
         assertNodeExists("/libs/foo");
     }
+
+    /**
+     * Tests if regexp remap works
+     */
+    @Test
+    public void  testInstallWithRegexp() throws RepositoryException, IOException, PackageException
{
+        JcrPackage pack = packMgr.upload(getStream("testpackages/test_version.zip"), false);
+        assertNotNull(pack);
+
+        ImportOptions opts = getDefaultOptions();
+        RegexpPathMapping pathMapping = new RegexpPathMapping();
+        pathMapping.addMapping("/testroot/(.*)", "/root/$1");
+        opts.setPathMapping(pathMapping);
+
+        pack.install(opts);
+
+        assertNodeExists("/root/a");
+        assertNodeMissing("/testroot/a");
+    }
+
+
 }
\ No newline at end of file

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=1803252&r1=1803251&r2=1803252&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
Fri Jul 28 09:01:25 2017
@@ -82,7 +82,7 @@ public class TestPackageInstall extends
      */
     @Test
     public void testUnwrapPreserveInstall() throws RepositoryException, IOException, PackageException
{
-        
+
         JcrPackage pack = packMgr.upload(getStream("testpackages/tmp.zip"), true, true);
         assertNotNull(pack);
         assertTrue(pack.isValid());
@@ -106,7 +106,7 @@ public class TestPackageInstall extends
         assertTrue(pack.isValid());
         assertTrue(pack.isInstalled());
         assertEquals(lastUnpacked, pack.getDefinition().getLastUnpacked().getTimeInMillis());
-        
+
         // a package with a different created date should not preserve the status!
         pack = packMgr.upload(getStream("testpackages/tmp_with_modified_created_date.zip"),
true, true);
         assertNotNull(pack);



Mime
View raw message