jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tri...@apache.org
Subject svn commit: r1512568 [29/39] - in /jackrabbit/commons/filevault/trunk: ./ parent/ vault-cli/ vault-cli/src/ vault-cli/src/main/ vault-cli/src/main/appassembler/ vault-cli/src/main/assembly/ vault-cli/src/main/java/ vault-cli/src/main/java/org/ vault-cl...
Date Sat, 10 Aug 2013 05:53:54 GMT
Added: jackrabbit/commons/filevault/trunk/vault-core/src/main/resources/org/apache/jackrabbit/vault/packaging/impl/nodetypes.cnd
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-core/src/main/resources/org/apache/jackrabbit/vault/packaging/impl/nodetypes.cnd?rev=1512568&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-core/src/main/resources/org/apache/jackrabbit/vault/packaging/impl/nodetypes.cnd (added)
+++ jackrabbit/commons/filevault/trunk/vault-core/src/main/resources/org/apache/jackrabbit/vault/packaging/impl/nodetypes.cnd Sat Aug 10 05:53:42 2013
@@ -0,0 +1,78 @@
+/*
+ * 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.
+ */
+<'vlt'='http://www.day.com/jcr/vault/1.0'>
+<'nt'='http://www.jcp.org/jcr/nt/1.0'>
+<'mix'='http://www.jcp.org/jcr/mix/1.0'>
+<'jcr'='http://www.jcp.org/jcr/1.0'>
+
+// -----------------------------------------------------------------------------
+// P A C K A G E S
+// -----------------------------------------------------------------------------
+// PACK_START
+/**
+ * Defines a file vault package. usually added to the jcr:content of a file node.
+ * @node vlt:definition package definition
+ */
+[vlt:Package] mixin
+  orderable
+  + vlt:definition (nt:base) = vlt:PackageDefinition
+
+/**
+ * Package Definition
+ * @prop version
+ * @prop groupId package group id
+ * @prop artifactId package artifact id
+ * @prop lastUnpacked last unpack date
+ * @prop lastUnpackedBy last unpack user
+ * @prop dependencies maven style list of dependencies
+ * @prop jcr:created creation date
+ * @prop jcr:createdBy creation user
+ * @prop jcr:description description of the package
+ * @prop jcr:lastModified last modification date of the definition
+ * @prop jcr:lastModifiedBy last modification user
+ * @node filter list of package filters
+ * @node extended optional extended data (thumbnails, detailed description, etc)
+ */
+[vlt:PackageDefinition] > nt:unstructured
+  orderable
+  - version (String)
+  - groupId (String)
+  - artifactId (String)
+  - lastUnpacked (Date)
+  - lastUnpackedBy (String)
+  - dependencies (String) multiple
+  - jcr:created (Date)
+  - jcr:createdBy (String)
+  - jcr:lastModified (Date)
+  - jcr:lastModifiedBy (String)
+  - jcr:description (String)
+  + thumbnail (nt:base) = nt:unstructured
+  + filter (nt:base) = nt:unstructured
+
+/**
+ * Node type to use as a marker for folders
+ * e.g. decorate a nt:unstructured to prevent greedy aggregation
+ */
+[vlt:HierarchyNode] > nt:hierarchyNode mixin
+
+/**
+ * Marker node type that can be used to mark nodes for full coverage
+ * aggregation
+ */
+[vlt:FullCoverage] mixin
+
+ // PACK_END
\ No newline at end of file

Added: 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=1512568&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/fs/api/PathMappingTest.java (added)
+++ jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/fs/api/PathMappingTest.java Sat Aug 10 05:53:42 2013
@@ -0,0 +1,35 @@
+/*
+ * 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 org.junit.Test;
+
+import static junit.framework.Assert.assertEquals;
+
+/**
+ * <code>PathMappingTest</code>...
+ */
+public class PathMappingTest {
+
+    @Test
+    public void testSimple() {
+        PathMapping map = new SimplePathMapping("/tmp", "/content");
+        assertEquals("/content", map.map("/tmp"));
+        assertEquals("/content/products", map.map("/tmp/products"));
+        assertEquals("/foo", map.map("/foo"));
+    }
+}
\ No newline at end of file

Added: jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/fs/api/RepositoryAddressTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/fs/api/RepositoryAddressTest.java?rev=1512568&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/fs/api/RepositoryAddressTest.java (added)
+++ jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/fs/api/RepositoryAddressTest.java Sat Aug 10 05:53:42 2013
@@ -0,0 +1,367 @@
+/*
+ * 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 junit.framework.TestCase;
+
+/**
+ * <code>RepAddrTest</code>...
+ *
+ */
+public class RepositoryAddressTest extends TestCase {
+
+    public void testEmpty() throws Exception {
+        RepositoryAddress ra = new RepositoryAddress("url://localhost:1234/");
+        assertEquals("scheme", "url", ra.getSpecificURI().getScheme());
+        assertEquals("host", "localhost", ra.getSpecificURI().getHost());
+        assertEquals("port", 1234, ra.getSpecificURI().getPort());
+        assertEquals("prefix", "/", ra.getSpecificURI().getPath());
+        assertEquals("workspace", null, ra.getWorkspace());
+        assertEquals("path", "/", ra.getPath());
+        assertEquals("toString", "url://localhost:1234/-/jcr:root", ra.toString());
+    }
+
+    public void testSpaces() throws Exception {
+        RepositoryAddress ra = new RepositoryAddress("url://localhost:1234/-/jcr:root/etc/packages/a%20b");
+        assertEquals("scheme", "url", ra.getSpecificURI().getScheme());
+        assertEquals("host", "localhost", ra.getSpecificURI().getHost());
+        assertEquals("port", 1234, ra.getSpecificURI().getPort());
+        assertEquals("prefix", "/", ra.getSpecificURI().getPath());
+        assertEquals("workspace", null, ra.getWorkspace());
+        assertEquals("path", "/etc/packages/a b", ra.getPath());
+        assertEquals("toString", "url://localhost:1234/-/jcr:root/etc/packages/a%20b", ra.toString());
+    }
+
+    public void testReallyEmpty() throws Exception {
+        RepositoryAddress ra = new RepositoryAddress("url://localhost:1234");
+        assertEquals("scheme", "url", ra.getSpecificURI().getScheme());
+        assertEquals("host", "localhost", ra.getSpecificURI().getHost());
+        assertEquals("port", 1234, ra.getSpecificURI().getPort());
+        assertEquals("prefix", "/", ra.getSpecificURI().getPath());
+        assertEquals("workspace", null, ra.getWorkspace());
+        assertEquals("path", "/", ra.getPath());
+        assertEquals("toString", "url://localhost:1234/-/jcr:root", ra.toString());
+    }
+
+    public void testWspOnly() throws Exception {
+        RepositoryAddress ra = new RepositoryAddress("url://localhost:1234/workspace");
+        assertEquals("scheme", "url", ra.getSpecificURI().getScheme());
+        assertEquals("host", "localhost", ra.getSpecificURI().getHost());
+        assertEquals("port", 1234, ra.getSpecificURI().getPort());
+        assertEquals("prefix", "/", ra.getSpecificURI().getPath());
+        assertEquals("workspace", "workspace", ra.getWorkspace());
+        assertEquals("path", "/", ra.getPath());
+        assertEquals("toString", "url://localhost:1234/workspace/jcr:root", ra.toString());
+    }
+
+    public void testWspOnlyTrailingSlash() throws Exception {
+        RepositoryAddress ra = new RepositoryAddress("url://localhost:1234/workspace/");
+        assertEquals("scheme", "url", ra.getSpecificURI().getScheme());
+        assertEquals("host", "localhost", ra.getSpecificURI().getHost());
+        assertEquals("port", 1234, ra.getSpecificURI().getPort());
+        assertEquals("prefix", "/", ra.getSpecificURI().getPath());
+        assertEquals("workspace", "workspace", ra.getWorkspace());
+        assertEquals("path", "/", ra.getPath());
+        assertEquals("toString", "url://localhost:1234/workspace/jcr:root", ra.toString());
+    }
+
+    public void testPrefix() throws Exception {
+        RepositoryAddress ra = new RepositoryAddress("http://localhost:1234/pfx1/pfx2/workspace");
+        assertEquals("scheme", "http", ra.getSpecificURI().getScheme());
+        assertEquals("host", "localhost", ra.getSpecificURI().getHost());
+        assertEquals("port", 1234, ra.getSpecificURI().getPort());
+        assertEquals("prefix", "/pfx1/pfx2", ra.getSpecificURI().getPath());
+        assertEquals("workspace", "workspace", ra.getWorkspace());
+        assertEquals("path", "/", ra.getPath());
+        assertEquals("toString", "http://localhost:1234/pfx1/pfx2/workspace/jcr:root", ra.toString());
+    }
+
+    public void testRoot() throws Exception {
+        RepositoryAddress ra = new RepositoryAddress("http://localhost:1234/pfx1/pfx2/workspace/jcr:root");
+        assertEquals("scheme", "http", ra.getSpecificURI().getScheme());
+        assertEquals("host", "localhost", ra.getSpecificURI().getHost());
+        assertEquals("port", 1234, ra.getSpecificURI().getPort());
+        assertEquals("prefix", "/pfx1/pfx2", ra.getSpecificURI().getPath());
+        assertEquals("workspace", "workspace", ra.getWorkspace());
+        assertEquals("path", "/", ra.getPath());
+        assertEquals("toString", "http://localhost:1234/pfx1/pfx2/workspace/jcr:root", ra.toString());
+    }
+
+    public void testRootTrailingSlash() throws Exception {
+        RepositoryAddress ra = new RepositoryAddress("http://localhost:1234/pfx1/pfx2/workspace/jcr:root/");
+        assertEquals("scheme", "http", ra.getSpecificURI().getScheme());
+        assertEquals("host", "localhost", ra.getSpecificURI().getHost());
+        assertEquals("port", 1234, ra.getSpecificURI().getPort());
+        assertEquals("prefix", "/pfx1/pfx2", ra.getSpecificURI().getPath());
+        assertEquals("workspace", "workspace", ra.getWorkspace());
+        assertEquals("path", "/", ra.getPath());
+        assertEquals("toString", "http://localhost:1234/pfx1/pfx2/workspace/jcr:root", ra.toString());
+    }
+
+    public void testPath() throws Exception {
+        RepositoryAddress ra = new RepositoryAddress("http://localhost:1234/pfx1/pfx2/workspace/jcr:root/foo/bar");
+        assertEquals("scheme", "http", ra.getSpecificURI().getScheme());
+        assertEquals("host", "localhost", ra.getSpecificURI().getHost());
+        assertEquals("port", 1234, ra.getSpecificURI().getPort());
+        assertEquals("prefix", "/pfx1/pfx2", ra.getSpecificURI().getPath());
+        assertEquals("workspace", "workspace", ra.getWorkspace());
+        assertEquals("path", "/foo/bar", ra.getPath());
+        assertEquals("toString", "http://localhost:1234/pfx1/pfx2/workspace/jcr:root/foo/bar", ra.toString());
+    }
+
+    public void testPathTrailingSlash() throws Exception {
+        RepositoryAddress ra = new RepositoryAddress("http://localhost:1234/pfx1/pfx2/workspace/jcr:root/foo/bar/");
+        assertEquals("scheme", "http", ra.getSpecificURI().getScheme());
+        assertEquals("host", "localhost", ra.getSpecificURI().getHost());
+        assertEquals("port", 1234, ra.getSpecificURI().getPort());
+        assertEquals("prefix", "/pfx1/pfx2", ra.getSpecificURI().getPath());
+        assertEquals("workspace", "workspace", ra.getWorkspace());
+        assertEquals("path", "/foo/bar", ra.getPath());
+        assertEquals("toString", "http://localhost:1234/pfx1/pfx2/workspace/jcr:root/foo/bar", ra.toString());
+    }
+
+    public void testResolve() throws Exception {
+        RepositoryAddress ra = 
+                new RepositoryAddress("http://localhost:1234/pfx1/pfx2/workspace")
+                .resolve("/foo/bar");
+        assertEquals("scheme", "http", ra.getSpecificURI().getScheme());
+        assertEquals("host", "localhost", ra.getSpecificURI().getHost());
+        assertEquals("port", 1234, ra.getSpecificURI().getPort());
+        assertEquals("prefix", "/pfx1/pfx2", ra.getSpecificURI().getPath());
+        assertEquals("workspace", "workspace", ra.getWorkspace());
+        assertEquals("path", "/foo/bar", ra.getPath());
+        assertEquals("toString", "http://localhost:1234/pfx1/pfx2/workspace/jcr:root/foo/bar", ra.toString());
+    }
+
+    public void testResolveSpecial() throws Exception {
+        RepositoryAddress ra =
+                new RepositoryAddress("http://localhost:1234/pfx1/pfx2/workspace")
+                .resolve("/foo bar/bar");
+        assertEquals("scheme", "http", ra.getSpecificURI().getScheme());
+        assertEquals("host", "localhost", ra.getSpecificURI().getHost());
+        assertEquals("port", 1234, ra.getSpecificURI().getPort());
+        assertEquals("prefix", "/pfx1/pfx2", ra.getSpecificURI().getPath());
+        assertEquals("workspace", "workspace", ra.getWorkspace());
+        assertEquals("path", "/foo bar/bar", ra.getPath());
+        assertEquals("toString", "http://localhost:1234/pfx1/pfx2/workspace/jcr:root/foo%20bar/bar", ra.toString());
+    }
+
+    public void testResolveDefaultWsp() throws Exception {
+        RepositoryAddress ra =
+                new RepositoryAddress("http://localhost:1234/pfx1/pfx2/-")
+                .resolve("/foo/bar");
+        assertEquals("scheme", "http", ra.getSpecificURI().getScheme());
+        assertEquals("host", "localhost", ra.getSpecificURI().getHost());
+        assertEquals("port", 1234, ra.getSpecificURI().getPort());
+        assertEquals("prefix", "/pfx1/pfx2", ra.getSpecificURI().getPath());
+        assertEquals("workspace", null, ra.getWorkspace());
+        assertEquals("path", "/foo/bar", ra.getPath());
+        assertEquals("toString", "http://localhost:1234/pfx1/pfx2/-/jcr:root/foo/bar", ra.toString());
+    }
+
+    public void testResolveRel() throws Exception {
+        RepositoryAddress ra = 
+                new RepositoryAddress("http://localhost:1234/pfx1/pfx2/workspace/jcr:root/foo")
+                .resolve("bar");
+        assertEquals("scheme", "http", ra.getSpecificURI().getScheme());
+        assertEquals("host", "localhost", ra.getSpecificURI().getHost());
+        assertEquals("port", 1234, ra.getSpecificURI().getPort());
+        assertEquals("prefix", "/pfx1/pfx2", ra.getSpecificURI().getPath());
+        assertEquals("workspace", "workspace", ra.getWorkspace());
+        assertEquals("path", "/foo/bar", ra.getPath());
+        assertEquals("toString", "http://localhost:1234/pfx1/pfx2/workspace/jcr:root/foo/bar", ra.toString());
+    }
+
+    public void testResolveRelSpecial() throws Exception {
+        RepositoryAddress ra =
+                new RepositoryAddress("http://localhost:1234/pfx1/pfx2/workspace/jcr:root/foo%20bar")
+                .resolve("foo bar");
+        assertEquals("scheme", "http", ra.getSpecificURI().getScheme());
+        assertEquals("host", "localhost", ra.getSpecificURI().getHost());
+        assertEquals("port", 1234, ra.getSpecificURI().getPort());
+        assertEquals("prefix", "/pfx1/pfx2", ra.getSpecificURI().getPath());
+        assertEquals("workspace", "workspace", ra.getWorkspace());
+        assertEquals("path", "/foo bar/foo bar", ra.getPath());
+        assertEquals("toString", "http://localhost:1234/pfx1/pfx2/workspace/jcr:root/foo%20bar/foo%20bar", ra.toString());
+    }
+
+    public void testResolveRelDefaultWsp() throws Exception {
+        RepositoryAddress ra =
+                new RepositoryAddress("http://localhost:1234/pfx1/pfx2/-/jcr:root/foo")
+                .resolve("bar");
+        assertEquals("scheme", "http", ra.getSpecificURI().getScheme());
+        assertEquals("host", "localhost", ra.getSpecificURI().getHost());
+        assertEquals("port", 1234, ra.getSpecificURI().getPort());
+        assertEquals("prefix", "/pfx1/pfx2", ra.getSpecificURI().getPath());
+        assertEquals("workspace", null, ra.getWorkspace());
+        assertEquals("path", "/foo/bar", ra.getPath());
+        assertEquals("toString", "http://localhost:1234/pfx1/pfx2/-/jcr:root/foo/bar", ra.toString());
+    }
+
+    public void testDefaultWorkspace() throws Exception {
+        RepositoryAddress ra =
+                new RepositoryAddress("http://localhost:1234/pfx1/pfx2/-/jcr:root/foo");
+        assertEquals("scheme", "http", ra.getSpecificURI().getScheme());
+        assertEquals("host", "localhost", ra.getSpecificURI().getHost());
+        assertEquals("port", 1234, ra.getSpecificURI().getPort());
+        assertEquals("prefix", "/pfx1/pfx2", ra.getSpecificURI().getPath());
+        assertEquals("workspace", null, ra.getWorkspace());
+        assertEquals("path", "/foo", ra.getPath());
+        assertEquals("toString", "http://localhost:1234/pfx1/pfx2/-/jcr:root/foo", ra.toString());
+    }
+
+    public void testRmiBWC() throws Exception {
+        RepositoryAddress ra =
+                new RepositoryAddress("rmi://localhost:1234/crx");
+        assertEquals("scheme", "rmi", ra.getSpecificURI().getScheme());
+        assertEquals("host", "localhost", ra.getSpecificURI().getHost());
+        assertEquals("port", 1234, ra.getSpecificURI().getPort());
+        assertEquals("prefix", "/crx", ra.getSpecificURI().getPath());
+        assertEquals("workspace", null, ra.getWorkspace());
+        assertEquals("path", "/", ra.getPath());
+        assertEquals("toString", "rmi://localhost:1234/crx/-/jcr:root", ra.toString());
+    }
+
+    public void testRmiBWC2() throws Exception {
+        RepositoryAddress ra =
+                new RepositoryAddress("rmi://localhost:1234/crx/crx.default");
+        assertEquals("scheme", "rmi", ra.getSpecificURI().getScheme());
+        assertEquals("host", "localhost", ra.getSpecificURI().getHost());
+        assertEquals("port", 1234, ra.getSpecificURI().getPort());
+        assertEquals("prefix", "/crx", ra.getSpecificURI().getPath());
+        assertEquals("workspace", "crx.default", ra.getWorkspace());
+        assertEquals("path", "/", ra.getPath());
+        assertEquals("toString", "rmi://localhost:1234/crx/crx.default/jcr:root", ra.toString());
+    }
+
+    public void testRmiBWC3() throws Exception {
+        RepositoryAddress ra =
+                new RepositoryAddress("rmi://localhost:1234/crx/crx.default/foo/bar");
+        assertEquals("scheme", "rmi", ra.getSpecificURI().getScheme());
+        assertEquals("host", "localhost", ra.getSpecificURI().getHost());
+        assertEquals("port", 1234, ra.getSpecificURI().getPort());
+        assertEquals("prefix", "/crx", ra.getSpecificURI().getPath());
+        assertEquals("workspace", "crx.default", ra.getWorkspace());
+        assertEquals("path", "/foo/bar", ra.getPath());
+        assertEquals("toString", "rmi://localhost:1234/crx/crx.default/jcr:root/foo/bar", ra.toString());
+    }
+
+    public void testHttpConvenience1() throws Exception {
+        RepositoryAddress ra =
+                new RepositoryAddress("http://localhost:8080/");
+        assertEquals("scheme", "http", ra.getSpecificURI().getScheme());
+        assertEquals("host", "localhost", ra.getSpecificURI().getHost());
+        assertEquals("port", 8080, ra.getSpecificURI().getPort());
+        assertEquals("prefix", "/crx/server", ra.getSpecificURI().getPath());
+        assertEquals("workspace", null, ra.getWorkspace());
+        assertEquals("path", "/", ra.getPath());
+        assertEquals("toString", "http://localhost:8080/crx/server/-/jcr:root", ra.toString());
+    }
+
+    public void testHttpConvenience2() throws Exception {
+        RepositoryAddress ra =
+                new RepositoryAddress("http://localhost:8080/crx");
+        assertEquals("scheme", "http", ra.getSpecificURI().getScheme());
+        assertEquals("host", "localhost", ra.getSpecificURI().getHost());
+        assertEquals("port", 8080, ra.getSpecificURI().getPort());
+        assertEquals("prefix", "/crx/server", ra.getSpecificURI().getPath());
+        assertEquals("workspace", null, ra.getWorkspace());
+        assertEquals("path", "/", ra.getPath());
+        assertEquals("toString", "http://localhost:8080/crx/server/-/jcr:root", ra.toString());
+    }
+
+    public void testHttpConvenience3() throws Exception {
+        RepositoryAddress ra =
+                new RepositoryAddress("http://localhost:8080/crx/server");
+        assertEquals("scheme", "http", ra.getSpecificURI().getScheme());
+        assertEquals("host", "localhost", ra.getSpecificURI().getHost());
+        assertEquals("port", 8080, ra.getSpecificURI().getPort());
+        assertEquals("prefix", "/crx/server", ra.getSpecificURI().getPath());
+        assertEquals("workspace", null, ra.getWorkspace());
+        assertEquals("path", "/", ra.getPath());
+        assertEquals("toString", "http://localhost:8080/crx/server/-/jcr:root", ra.toString());
+    }
+
+    public void testHttpConvenience4() throws Exception {
+        RepositoryAddress ra =
+                new RepositoryAddress("http://localhost:8080/-/jcr:root");
+        assertEquals("scheme", "http", ra.getSpecificURI().getScheme());
+        assertEquals("host", "localhost", ra.getSpecificURI().getHost());
+        assertEquals("port", 8080, ra.getSpecificURI().getPort());
+        assertEquals("prefix", "/", ra.getSpecificURI().getPath());
+        assertEquals("workspace", null, ra.getWorkspace());
+        assertEquals("path", "/", ra.getPath());
+        assertEquals("toString", "http://localhost:8080/-/jcr:root", ra.toString());
+    }
+
+    public void testRelative() throws Exception {
+        RepositoryAddress ra = new RepositoryAddress("/");
+        assertEquals("scheme", null, ra.getSpecificURI().getScheme());
+        assertEquals("host", null, ra.getSpecificURI().getHost());
+        assertEquals("port", -1, ra.getSpecificURI().getPort());
+        assertEquals("prefix", "/", ra.getSpecificURI().getPath());
+        assertEquals("workspace", null, ra.getWorkspace());
+        assertEquals("path", "/", ra.getPath());
+        assertEquals("toString", "/-/jcr:root", ra.toString());
+    }
+
+    public void testRelative1() throws Exception {
+        RepositoryAddress ra = new RepositoryAddress("/wsp/");
+        assertEquals("scheme", null, ra.getSpecificURI().getScheme());
+        assertEquals("host", null, ra.getSpecificURI().getHost());
+        assertEquals("port", -1, ra.getSpecificURI().getPort());
+        assertEquals("prefix", "/", ra.getSpecificURI().getPath());
+        assertEquals("workspace", "wsp", ra.getWorkspace());
+        assertEquals("path", "/", ra.getPath());
+        assertEquals("toString", "/wsp/jcr:root", ra.toString());
+    }
+
+    public void testRelative2() throws Exception {
+        RepositoryAddress ra = new RepositoryAddress("/wsp/bar");
+        assertEquals("scheme", null, ra.getSpecificURI().getScheme());
+        assertEquals("host", null, ra.getSpecificURI().getHost());
+        assertEquals("port", -1, ra.getSpecificURI().getPort());
+        assertEquals("prefix", "/", ra.getSpecificURI().getPath());
+        assertEquals("workspace", "wsp", ra.getWorkspace());
+        assertEquals("path", "/bar", ra.getPath());
+        assertEquals("toString", "/wsp/jcr:root/bar", ra.toString());
+    }
+
+    public void testRelative3() throws Exception {
+        RepositoryAddress ra = new RepositoryAddress("/wsp/foo/bar");
+        assertEquals("scheme", null, ra.getSpecificURI().getScheme());
+        assertEquals("host", null, ra.getSpecificURI().getHost());
+        assertEquals("port", -1, ra.getSpecificURI().getPort());
+        assertEquals("prefix", "/", ra.getSpecificURI().getPath());
+        assertEquals("workspace", "wsp", ra.getWorkspace());
+        assertEquals("path", "/foo/bar", ra.getPath());
+        assertEquals("toString", "/wsp/jcr:root/foo/bar", ra.toString());
+    }
+
+    public void testRelative4() throws Exception {
+        RepositoryAddress ra = new RepositoryAddress("/-/foo/bar");
+        assertEquals("scheme", null, ra.getSpecificURI().getScheme());
+        assertEquals("host", null, ra.getSpecificURI().getHost());
+        assertEquals("port", -1, ra.getSpecificURI().getPort());
+        assertEquals("prefix", "/", ra.getSpecificURI().getPath());
+        assertEquals("workspace", null, ra.getWorkspace());
+        assertEquals("path", "/foo/bar", ra.getPath());
+        assertEquals("toString", "/-/jcr:root/foo/bar", ra.toString());
+    }
+
+}
\ No newline at end of file

Added: jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/fs/filter/DefaultPathFiterTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/fs/filter/DefaultPathFiterTest.java?rev=1512568&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/fs/filter/DefaultPathFiterTest.java (added)
+++ jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/fs/filter/DefaultPathFiterTest.java Sat Aug 10 05:53:42 2013
@@ -0,0 +1,67 @@
+/*
+ * 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.filter;
+
+import junit.framework.TestCase;
+
+/**
+ * <code>PathFiterTest</code>...
+ *
+ */
+public class DefaultPathFiterTest extends TestCase {
+
+    public void testExact() {
+        test("/foo\\.bar", "/foo.bar", true);
+        test("/foo\\.bar", "/foo_bar", false);
+    }
+
+    public void testFiles() {
+        test("/foo/bar\\.[^/]*$", "/foo/bar.txt", true);
+        test("/foo/bar\\.[^/]*$", "/foo/bar.zip", true);
+        test("/foo/bar\\.[^/]*$", "/foo/bar1.txt", false);
+        test("/foo/bar.[^/]*$", "/foo/bar.dir/readme", false);
+        test("^.*/bar\\.[^/]*$", "/foo/bar.txt", true);
+        test("^.*/bar\\.[^/]*$", "/foo/bar1.txt", false);
+        test("^.*/bar\\.[^/]*$", "/foo/bar.dir/readme", false);
+        test("^.*/bar\\.[^/]*$", "foobar.txt", false);
+    }
+
+    public void testDirectChildren() {
+        test("/foo/[^/]*$", "/foo/bar", true);
+        test("/foo/[^/]*$", "/foo/bar/readme", false);
+    }
+
+    public void testDeepChildren() {
+        test("/foo/.*", "/foo/bar", true);
+        test("/foo/.*", "/foo/bar/readme.txt", true);
+        test("/foo/.*", "/bar/bar/readme.txt", false);
+    }
+    
+    public void testSelfAndDeepChildren() {
+        test("/foo(/.*)?", "/foo", true);
+        test("/foo(/.*)?", "/foo/bar/readme.txt", true);
+        test("/foo(/.*)?", "/foobar", false);
+        test("/foo(/.*)?", "/foobar/foo", false);
+    }
+
+    private void test(String pattern, String path, boolean result) {
+        DefaultPathFilter f = new DefaultPathFilter(pattern);
+        assertEquals("Pattern '" + pattern + "' matches '" + path + "'", result, f.matches(path));
+    }
+
+}
\ No newline at end of file

Added: jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/fs/filter/WorkspaceFilterTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/fs/filter/WorkspaceFilterTest.java?rev=1512568&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/fs/filter/WorkspaceFilterTest.java (added)
+++ jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/fs/filter/WorkspaceFilterTest.java Sat Aug 10 05:53:42 2013
@@ -0,0 +1,104 @@
+/*
+ * 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.filter;
+
+import org.apache.jackrabbit.vault.fs.api.PathFilterSet;
+import org.apache.jackrabbit.vault.fs.api.PathMapping;
+import org.apache.jackrabbit.vault.fs.api.SimplePathMapping;
+import org.apache.jackrabbit.vault.fs.api.WorkspaceFilter;
+import org.apache.jackrabbit.vault.fs.config.DefaultWorkspaceFilter;
+import org.junit.Test;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * <code>WorkspaceFilterTest</code>...
+ */
+public class WorkspaceFilterTest {
+
+    @Test
+    public void testMatching() {
+        DefaultWorkspaceFilter filter = new DefaultWorkspaceFilter();
+        PathFilterSet set1 = new PathFilterSet("/foo");
+        filter.add(set1);
+        PathFilterSet set2 = new PathFilterSet("/tmp");
+        set2.addInclude(new DefaultPathFilter("/tmp(/.*)?"));
+        set2.addExclude(new DefaultPathFilter("/tmp/foo(/.*)?"));
+        filter.add(set2);
+        assertTrue(filter.contains("/foo"));
+        assertTrue(filter.contains("/foo/bar"));
+        assertTrue(filter.contains("/tmp"));
+        assertTrue(filter.contains("/tmp/bar"));
+        assertFalse(filter.contains("/tmp/foo"));
+        assertFalse(filter.contains("/tmp/foo/bar"));
+        assertFalse(filter.contains("/"));
+        assertFalse(filter.contains("/bar"));
+
+        assertTrue(filter.covers("/foo"));
+        assertTrue(filter.covers("/tmp"));
+        assertTrue(filter.covers("/tmp/foo"));
+    }
+
+    @Test
+    public void testMapping1() {
+        DefaultWorkspaceFilter filter = new DefaultWorkspaceFilter();
+        PathFilterSet set1 = new PathFilterSet("/tmp/stage/products");
+        filter.add(set1);
+        PathMapping map = new SimplePathMapping("/tmp/stage", "/content/geometrixx/en");
+        WorkspaceFilter mapped = filter.translate(map);
+        assertFalse(mapped.contains("/content/geometrixx/en"));
+        assertTrue(mapped.contains("/content/geometrixx/en/products"));
+    }
+
+    @Test
+    public void testMapping2() {
+        DefaultWorkspaceFilter filter = new DefaultWorkspaceFilter();
+        PathFilterSet set1 = new PathFilterSet("/tmp/stage");
+        set1.addInclude(new DefaultPathFilter("/tmp/stage/products(/.*)?"));
+        set1.addExclude(new DefaultPathFilter("/tmp/stage/products/triangle(/.*)?"));
+        set1.addExclude(new DefaultPathFilter(".*/foo"));
+        filter.add(set1);
+        PathMapping map = new SimplePathMapping("/tmp/stage", "/content/geometrixx/en");
+        WorkspaceFilter mapped = filter.translate(map);
+        assertFalse(mapped.contains("/content/geometrixx/en"));
+        assertTrue(mapped.contains("/content/geometrixx/en/products"));
+        assertFalse(mapped.contains("/content/geometrixx/en/products/triangle"));
+        assertFalse(mapped.contains("/content/geometrixx/en/products/foo"));
+    }
+
+    @Test
+    public void testRelativePatterns() {
+        PathFilterSet set1 = new PathFilterSet("/foo");
+        set1.addInclude(new DefaultPathFilter("/foo/.*"));
+        set1.addInclude(new DefaultPathFilter("/bar/.*"));
+        set1.seal();
+        assertFalse(set1.hasOnlyRelativePatterns());
+
+        PathFilterSet set2 = new PathFilterSet("/foo");
+        set2.addInclude(new DefaultPathFilter(".*/foo/.*"));
+        set2.addInclude(new DefaultPathFilter(".*/bar/.*"));
+        set2.seal();
+        assertTrue(set2.hasOnlyRelativePatterns());
+
+        PathFilterSet set3 = new PathFilterSet("/foo");
+        set3.addInclude(new DefaultPathFilter(".*/foo/.*"));
+        set3.addInclude(new DefaultPathFilter("/.*/bar/.*"));
+        set3.seal();
+        assertFalse(set3.hasOnlyRelativePatterns());
+    }
+}
\ No newline at end of file

Added: jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/DepResolverTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/DepResolverTest.java?rev=1512568&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/DepResolverTest.java (added)
+++ jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/DepResolverTest.java Sat Aug 10 05:53:42 2013
@@ -0,0 +1,125 @@
+/*
+ * 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.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+/**
+ * <code>DepResolverTest</code>...
+ */
+public class DepResolverTest extends TestCase {
+
+    public static PackageId P1 = PackageId.fromString("foo:pack1:1.0");
+    public static PackageId P2 = PackageId.fromString("foo:pack2:1.0");
+    public static PackageId P3 = PackageId.fromString("foo:pack3:1.0");
+    public static PackageId P4 = PackageId.fromString("foo:pack4:1.0");
+    public static PackageId P5 = PackageId.fromString("foo:pack5:1.0");
+
+    public static Dependency D1 = Dependency.fromString("foo:pack1:1.0");
+    public static Dependency D2 = Dependency.fromString("foo:pack2:1.0");
+    public static Dependency D3 = Dependency.fromString("foo:pack3:1.0");
+    public static Dependency D4 = Dependency.fromString("foo:pack4:1.0");
+    public static Dependency D5 = Dependency.fromString("foo:pack5:1.0");
+
+    public void testLinear() throws CyclicDependencyException {
+        Map<PackageId, Dependency[]> deps = new LinkedHashMap<PackageId, Dependency[]>();
+        // p1 -> p2, p3
+        deps.put(P1, new Dependency[]{D2, D3});
+        // p2 -> p4
+        deps.put(P2, new Dependency[]{D4});
+        // p3 -> p5
+        deps.put(P3, new Dependency[]{D5});
+        // p4 -> p5
+        deps.put(P4, new Dependency[]{D5});
+        // p5
+        deps.put(P5, Dependency.EMPTY);
+        
+        // expect: p5, p4, p2, p3, p1
+        PackageId[] expect = new PackageId[]{P5, P4, P2, P3, P1};
+        List<PackageId> result = DependencyUtil.resolve(deps);
+        assertEquals("package list", expect, result);
+    }
+
+    public void testLinear2() throws CyclicDependencyException {
+        Map<PackageId, Dependency[]> deps = new LinkedHashMap<PackageId, Dependency[]>();
+        // p3 -> p4, p5
+        deps.put(P3, new Dependency[]{D4, D5});
+        // p4 -> p2, p5
+        deps.put(P4, new Dependency[]{D2, D5});
+        // p1 -> p2, p3, p4
+        deps.put(P1, new Dependency[]{D2, D3, D4});
+        // p2
+        deps.put(P2, Dependency.EMPTY);
+        // p5
+        deps.put(P5, Dependency.EMPTY);
+
+        // expect: p5, p4, p2, p3, p1
+        PackageId[] expect = new PackageId[]{P2, P5, P4, P3, P1};
+        List<PackageId> result = DependencyUtil.resolve(deps);
+        assertEquals("package list", expect, result);
+    }
+
+    public void testMissing() throws Exception {
+        Map<PackageId, Dependency[]> deps = new LinkedHashMap<PackageId, Dependency[]>();
+        // p3 -> p4, p5
+        deps.put(P3, new Dependency[]{D4, D5});
+        // p4 -> p2, p5
+        deps.put(P4, new Dependency[]{D2, D5});
+        // p1 -> p2, p3, p4
+        deps.put(P1, new Dependency[]{D2, D3, D4});
+        // p2
+        deps.put(P2, Dependency.EMPTY);
+
+        // expect: p4, p2, p3, p1
+        PackageId[] expect = new PackageId[]{P2, P4, P3, P1};
+        List<PackageId> result = DependencyUtil.resolve(deps);
+        assertEquals("package list", expect, result);
+    }
+
+    public void testCircular() throws Exception {
+        Map<PackageId, Dependency[]> deps = new LinkedHashMap<PackageId, Dependency[]>();
+        // p1 -> p2
+        deps.put(P1, new Dependency[]{D2});
+        // p2 -> p3, p4
+        deps.put(P2, new Dependency[]{D3, D4});
+        // p4 -> p1, p5
+        deps.put(P4, new Dependency[]{D1, D5});
+        try {
+            DependencyUtil.resolve(deps);
+            fail("Expected cyclic dep exception.");
+        } catch (CyclicDependencyException e) {
+            // ignore
+        }
+    }
+
+    private void assertEquals(String msg, PackageId[] expect, List<PackageId> result) {
+        String expStr = "";
+        for (PackageId pid: expect) {
+            expStr+=pid.toString() + "\n";
+        }
+        String resStr = "";
+        for (PackageId pid: result) {
+            resStr+=pid.toString() + "\n";
+        }
+        assertEquals(msg, expStr, resStr);
+    }
+}
\ No newline at end of file

Added: jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/DependencyTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/DependencyTest.java?rev=1512568&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/DependencyTest.java (added)
+++ jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/DependencyTest.java Sat Aug 10 05:53:42 2013
@@ -0,0 +1,104 @@
+/*
+ * 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>DependencyTest</code>...
+ */
+public class DependencyTest extends TestCase {
+
+    public void testFromString() {
+        Dependency d = Dependency.fromString("group:name:[1.0,2.0]");
+        assertEquals("group", d.getGroup());
+        assertEquals("name", d.getName());
+        assertEquals("[1.0,2.0]", d.getRange().toString());
+    }
+
+    public void testFromString2() {
+        Dependency d = Dependency.fromString("name");
+        assertEquals("", d.getGroup());
+        assertEquals("name", d.getName());
+        assertEquals(VersionRange.INFINITE, d.getRange());
+    }
+
+    public void testFromString3() {
+        Dependency d = Dependency.fromString("group:name");
+        assertEquals("group", d.getGroup());
+        assertEquals("name", d.getName());
+        assertEquals(VersionRange.INFINITE, d.getRange());
+    }
+
+    public void testFromString4() {
+        Dependency d = Dependency.fromString("foo/bar/group/name");
+        assertEquals("foo/bar/group", d.getGroup());
+        assertEquals("name", d.getName());
+        assertEquals(VersionRange.INFINITE, d.getRange());
+    }
+
+    public void testFromString41() {
+        Dependency d = Dependency.fromString("foo/bar/group:name");
+        assertEquals("foo/bar/group", d.getGroup());
+        assertEquals("name", d.getName());
+        assertEquals(VersionRange.INFINITE, d.getRange());
+    }
+
+    public void testFromString5() {
+        Dependency d = Dependency.fromString("foo/bar/group/name:[1.0,2.0]");
+        assertEquals("foo/bar/group", d.getGroup());
+        assertEquals("name", d.getName());
+        assertEquals("[1.0,2.0]", d.getRange().toString());
+    }
+
+    public void testToString() {
+        Dependency d = new Dependency("group", "name", VersionRange.fromString("[1.0, 2.0]"));
+        assertEquals("group:name:[1.0,2.0]", d.toString());
+    }
+
+    public void testToString2() {
+        Dependency d = new Dependency("", "name", VersionRange.fromString("[1.0, 2.0]"));
+        assertEquals(":name:[1.0,2.0]", d.toString());
+    }
+
+    public void testToString3() {
+        Dependency d = new Dependency("", "name", null);
+        assertEquals("name", d.toString());
+    }
+
+    public void testToString4() {
+        Dependency d = new Dependency("group", "name", null);
+        assertEquals("group:name", d.toString());
+    }
+
+    public void testParse() {
+        Dependency[] d = Dependency.parse("name1,group2:name2,group3:name3:1.0,group4:name4:[1.0,2.0],:name5:[1.0,2.0]");
+        assertEquals(5,d.length);
+        assertEquals("name1", d[0].toString());
+        assertEquals("group2:name2", d[1].toString());
+        assertEquals("group3:name3:1.0", d[2].toString());
+        assertEquals("group4:name4:[1.0,2.0]", d[3].toString());
+        assertEquals(":name5:[1.0,2.0]", d[4].toString());
+    }
+
+    public void testMatches() {
+        PackageId id = PackageId.fromString("apache/jackrabbit/product:jcr-content:5.5.0-SNAPSHOT.20111116");
+        Dependency d = Dependency.fromString("apache/jackrabbit/product:jcr-content:[5.5.0,)");
+        assertTrue(d.matches(id));
+    }
+}
\ No newline at end of file

Added: jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/PackageIdTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/PackageIdTest.java?rev=1512568&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/PackageIdTest.java (added)
+++ jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/PackageIdTest.java Sat Aug 10 05:53:42 2013
@@ -0,0 +1,173 @@
+/*
+ * 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>PackageIdTest</code>...
+ */
+public class PackageIdTest extends TestCase {
+
+    public void testToString() {
+        PackageId packId = new PackageId("group", "name", "version");
+        assertEquals("group:name:version", packId.toString());
+    }
+
+    public void testToInstallPath() {
+        PackageId packId = new PackageId("group", "name", "version");
+        assertEquals("/etc/packages/group/name-version", packId.getInstallationPath());
+    }
+
+    public void testToInstallPath1() {
+        PackageId packId = new PackageId("group", "name", "");
+        assertEquals("/etc/packages/group/name", packId.getInstallationPath());
+    }
+
+    public void testFromPath() {
+        PackageId packId = new PackageId("/etc/packages/apache/jackrabbit/hotfix/name.zip", "1.0");
+        assertEquals("apache/jackrabbit/hotfix:name:1.0", packId.toString());
+    }
+
+    public void testFromPath1() {
+        PackageId packId = new PackageId("/etc/packages/name-1.0.zip", "1.0");
+        assertEquals(":name:1.0", packId.toString());
+    }
+
+    public void testFromPath2() {
+        PackageId packId = new PackageId("apache/jackrabbit/hotfix/name", "1.0");
+        assertEquals("apache/jackrabbit/hotfix:name:1.0", packId.toString());
+    }
+
+    public void testFromPath3() {
+        PackageId packId = new PackageId("name.zip", "1.0");
+        assertEquals(":name:1.0", packId.toString());
+    }
+
+    public void testFromPath4() {
+        PackageId packId = new PackageId("name", (Version) null);
+        assertEquals(":name", packId.toString());
+    }
+
+    public void testFromPath5() {
+        PackageId packId = new PackageId("hotfix/name-1.0", "2.0");
+        assertEquals("hotfix:name-1.0:2.0", packId.toString());
+    }
+
+    public void testFromVPath() {
+        PackageId packId = new PackageId("/etc/packages/apache/jackrabbit/hotfix/name.zip");
+        assertEquals("apache/jackrabbit/hotfix:name", packId.toString());
+    }
+
+    public void testFromVPath1() {
+        PackageId packId = new PackageId("hotfix/name-1.0");
+        assertEquals("hotfix:name:1.0", packId.toString());
+    }
+
+    public void testFromVPath2() {
+        PackageId packId = new PackageId("hotfix/name-1.0-SNAPSHOT");
+        assertEquals("hotfix:name:1.0-SNAPSHOT", packId.toString());
+    }
+
+    public void testFromVPath3() {
+        PackageId packId = new PackageId("hotfix/cq-name-1.0-SNAPSHOT");
+        assertEquals("hotfix:cq-name:1.0-SNAPSHOT", packId.toString());
+    }
+
+    public void testFromVPath4() {
+        PackageId packId = new PackageId("hotfix/cq-5.3.0-hotfix-12345-1.0-SNAPSHOT");
+        assertEquals("hotfix:cq-5.3.0-hotfix-12345:1.0-SNAPSHOT", packId.toString());
+    }
+
+    public void testFromVPath5() {
+        PackageId packId = new PackageId("hotfix/cq-5.3.0-hotfix-12345-1.0-R1234");
+        assertEquals("hotfix:cq-5.3.0-hotfix-12345:1.0-R1234", packId.toString());
+    }
+
+    public void testFromVPath6() {
+        PackageId packId = new PackageId("hotfix/cq-5.3.0-RG12");
+        assertEquals("hotfix:cq-5.3.0-RG12", packId.toString());
+    }
+
+    public void testEquals() {
+        PackageId pack1 = new PackageId("group", "name", "version");
+        PackageId pack2 = new PackageId("group", "name", "version");
+        assertEquals(pack1, pack2);
+    }
+    public void testFromString() {
+        PackageId packId = PackageId.fromString("group:name:version");
+        assertEquals(packId.getGroup(), "group");
+        assertEquals(packId.getName(), "name");
+        assertEquals(packId.getVersion().toString(), "version");
+    }
+
+    public void testFromString2() {
+        PackageId packId = PackageId.fromString("group:name");
+        assertEquals(packId.getGroup(), "group");
+        assertEquals(packId.getName(), "name");
+        assertEquals(packId.getVersionString(), "");
+    }
+
+    public void testFromString3() {
+        PackageId packId = PackageId.fromString("name");
+        assertEquals(packId.getGroup(), "");
+        assertEquals(packId.getName(), "name");
+        assertEquals(packId.getVersionString(), "");
+    }
+
+    public void testFromString4() {
+        PackageId packId = PackageId.fromString(":name:version");
+        assertEquals(packId.getGroup(), "");
+        assertEquals(packId.getName(), "name");
+        assertEquals(packId.getVersionString(), "version");
+    }
+
+    public void testRoundtrip() {
+        PackageId p1 = new PackageId("", "name", "");
+        PackageId p2 = PackageId.fromString(p1.toString());
+        assertEquals(p1.getName(), p2.getName());
+        assertEquals(p1.getGroup(), p2.getGroup());
+        assertEquals(p1.getVersion(), p2.getVersion());
+    }
+
+    public void testRoundtrip2() {
+        PackageId p1 = new PackageId("", "name", "version");
+        PackageId p2 = PackageId.fromString(p1.toString());
+        assertEquals(p1.getName(), p2.getName());
+        assertEquals(p1.getGroup(), p2.getGroup());
+        assertEquals(p1.getVersion(), p2.getVersion());
+    }
+
+    public void testRoundtrip3() {
+        PackageId p1 = new PackageId("group", "name", "");
+        PackageId p2 = PackageId.fromString(p1.toString());
+        assertEquals(p1.getName(), p2.getName());
+        assertEquals(p1.getGroup(), p2.getGroup());
+        assertEquals(p1.getVersion(), p2.getVersion());
+    }
+
+    public void testRoundtrip4() {
+        PackageId p1 = new PackageId("group", "name", "version");
+        PackageId p2 = PackageId.fromString(p1.toString());
+        assertEquals(p1.getName(), p2.getName());
+        assertEquals(p1.getGroup(), p2.getGroup());
+        assertEquals(p1.getVersion(), p2.getVersion());
+    }
+
+
+}
\ No newline at end of file

Added: jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/VersionRangeTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/VersionRangeTest.java?rev=1512568&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/VersionRangeTest.java (added)
+++ jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/VersionRangeTest.java Sat Aug 10 05:53:42 2013
@@ -0,0 +1,192 @@
+/*
+ * 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>VersionRangeTest</code>...
+ */
+public class VersionRangeTest extends TestCase {
+
+    private final Version v09 = Version.create("0.9");
+    private final Version v1 = Version.create("1.0");
+    private final Version v11 = Version.create("1.1");
+    private final Version v2 = Version.create("2.0");
+    private final Version v21 = Version.create("2.1");
+    private final Version v1s = Version.create("1.0-SNAPSHOT");
+
+
+    public void testInfinite() {
+        assertTrue("Infinite range includes all versions", VersionRange.INFINITE.isInRange(v1));
+    }
+
+    public void testLowerBoundIncl() {
+        VersionRange vr = new VersionRange(v1, true, null, false);
+        assertTrue("[1.0,] includes 1.0", vr.isInRange(v1));
+        assertTrue("[1.0,] includes 2.0", vr.isInRange(v2));
+        assertFalse("[1.0,] excludes 0.9", vr.isInRange(v09));
+    }
+
+    public void testLowerBoundExcl() {
+        VersionRange vr = new VersionRange(v1, false, null, false);
+        assertFalse("(1.0,] excludes 1.0", vr.isInRange(v1));
+        assertTrue("(1.0,] includes 2.0", vr.isInRange(v2));
+        assertFalse("(1.0,] excludes 0.9", vr.isInRange(v09));
+    }
+
+    public void testUpperBoundIncl() {
+        VersionRange vr = new VersionRange(null, false, v2, true);
+        assertTrue("[,2.0] includes 1.0", vr.isInRange(v1));
+        assertTrue("[,2.0] includes 2.0", vr.isInRange(v2));
+        assertFalse("[,2.0] excludes 2.1", vr.isInRange(v21));
+    }
+
+    public void testUpperBoundExcl() {
+        VersionRange vr = new VersionRange(null, false, v2, false);
+        assertTrue("[,2.0) includes 1.0", vr.isInRange(v1));
+        assertFalse("[,2.0) excludes 2.0", vr.isInRange(v2));
+        assertFalse("[,2.0) excludes 2.1", vr.isInRange(v21));
+    }
+
+    public void testRangeInclIncl() {
+        VersionRange vr = new VersionRange(v1, true, v2, true);
+        assertFalse("[1.0,2.0] excludes 0.9", vr.isInRange(v09));
+        assertTrue("[1.0,2.0] includes 1.0", vr.isInRange(v1));
+        assertTrue("[1.0,2.0] includes 1.1", vr.isInRange(v11));
+        assertTrue("[1.0,2.0] includes 2.0", vr.isInRange(v2));
+        assertFalse("[1.0,2.0] excludes 2.1", vr.isInRange(v21));
+    }
+
+    public void testRangeExclIncl() {
+        VersionRange vr = new VersionRange(v1, false, v2, true);
+        assertFalse("(1.0,2.0] excludes 0.9", vr.isInRange(v09));
+        assertFalse("(1.0,2.0] includes 1.0", vr.isInRange(v1));
+        assertTrue("(1.0,2.0] includes 1.1", vr.isInRange(v11));
+        assertTrue("(1.0,2.0] includes 2.0", vr.isInRange(v2));
+        assertFalse("(1.0,2.0] excludes 2.1", vr.isInRange(v21));
+    }
+
+    public void testRangeInclExcl() {
+        VersionRange vr = new VersionRange(v1, true, v2, false);
+        assertFalse("[1.0,2.0) excludes 0.9", vr.isInRange(v09));
+        assertTrue("[1.0,2.0) includes 1.0", vr.isInRange(v1));
+        assertTrue("[1.0,2.0) includes 1.1", vr.isInRange(v11));
+        assertFalse("[1.0,2.0) includes 2.0", vr.isInRange(v2));
+        assertFalse("[1.0,2.0) excludes 2.1", vr.isInRange(v21));
+    }
+
+    public void testRangeExclExcl() {
+        VersionRange vr = new VersionRange(v1, false, v2, false);
+        assertFalse("(1.0,2.0) excludes 0.9", vr.isInRange(v09));
+        assertFalse("(1.0,2.0) includes 1.0", vr.isInRange(v1));
+        assertTrue("(1.0,2.0) includes 1.1", vr.isInRange(v11));
+        assertFalse("(1.0,2.0) includes 2.0", vr.isInRange(v2));
+        assertFalse("(1.0,2.0) excludes 2.1", vr.isInRange(v21));
+    }
+
+    public void testRangeSnapshots() {
+        VersionRange vr = VersionRange.fromString("[1.0,2.0)");
+        assertTrue("[1.0,2.0) includes 1.0-SNAPSHOT", vr.isInRange(v1s));
+    }
+
+    public void testRangeInvalid() {
+        try {
+            new VersionRange(v2, false, v1, false);
+            fail("invalid range (2.0,1.0) must fail");
+        } catch (Exception e) {
+            // ignore
+        }
+    }
+
+    public void testRangeInvalid2() {
+        try {
+            new VersionRange(v1, false, v1, false);
+            fail("invalid range (1.0,1.0) must fail");
+        } catch (Exception e) {
+            // ignore
+        }
+    }
+
+    public void testParse() {
+        VersionRange vr = VersionRange.fromString("[1.0,2.0]");
+        assertEquals(v1, vr.getLow());
+        assertEquals(v2, vr.getHigh());
+        assertEquals(true, vr.isLowInclusive());
+        assertEquals(true, vr.isHighInclusive());
+    }
+
+    public void testParse2() {
+        VersionRange vr = VersionRange.fromString("(1.0,2.0)");
+        assertEquals(v1, vr.getLow());
+        assertEquals(v2, vr.getHigh());
+        assertEquals(false, vr.isLowInclusive());
+        assertEquals(false, vr.isHighInclusive());
+    }
+
+    public void testParse3() {
+        VersionRange vr = VersionRange.fromString("1.0");
+        assertEquals(v1, vr.getLow());
+        assertEquals(null, vr.getHigh());
+        assertEquals(true, vr.isLowInclusive());
+    }
+
+    public void testParse4() {
+        VersionRange vr = VersionRange.fromString("(1.0,]");
+        assertEquals(v1, vr.getLow());
+        assertEquals(null, vr.getHigh());
+        assertEquals(false, vr.isLowInclusive());
+    }
+
+    public void testParse5() {
+        VersionRange vr = VersionRange.fromString("[,2.0]");
+        assertEquals(null, vr.getLow());
+        assertEquals(v2, vr.getHigh());
+        assertEquals(true, vr.isHighInclusive());
+    }
+
+    public void testToString() {
+        VersionRange vr = new VersionRange(v1, true, v2, true);
+        assertEquals("[1.0,2.0]", vr.toString());
+    }
+
+    public void testToString2() {
+        VersionRange vr = new VersionRange(v1, false, v2, false);
+        assertEquals("(1.0,2.0)", vr.toString());
+    }
+
+    public void testToString3() {
+        VersionRange vr = new VersionRange(v1, false, null, false);
+        assertEquals("(1.0,)", vr.toString());
+    }
+
+    public void testToString4() {
+        VersionRange vr = new VersionRange(v1, true, null, false);
+        assertEquals("1.0", vr.toString());
+    }
+
+    public void testToString5() {
+        VersionRange vr = new VersionRange(null, false, v2, true);
+        assertEquals("[,2.0]", vr.toString());
+    }
+
+    public void testToString6() {
+        VersionRange vr = new VersionRange(null, false, v2, false);
+        assertEquals("[,2.0)", vr.toString());
+    }
+}
\ No newline at end of file

Added: jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/VersionTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/VersionTest.java?rev=1512568&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/VersionTest.java (added)
+++ jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/VersionTest.java Sat Aug 10 05:53:42 2013
@@ -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>VersionTest</code>...
+ */
+public class VersionTest extends TestCase {
+
+    public void testFromSegments() {
+        String[] segs = {"1", "2", "3-SNAPSHOT"};
+        Version v = Version.create(segs);
+        assertEquals("1.2.3-SNAPSHOT", v.toString());
+    }
+
+    public void testCompare() {
+        compare("1.0.0", "1.0.0", 0);
+        compare("1.0.1", "1.0.0", 1);
+        compare("1.1", "1.0.0", 1);
+        compare("1.11", "1.9", 1);
+        compare("1.1-SNAPSHOT", "1.0.0", 1);
+        compare("2.0", "2.0-beta-8", 1);
+        compare("2.0", "2.0-SNAPSHOT", 1);
+        compare("1.11", "1.9-SNAPSHOT", 1);
+        compare("1.11-SNAPSHOT", "1.9-SNAPSHOT", 1);
+        compare("1.11-SNAPSHOT", "1.9", 1);
+        compare("1.1", "1.1-SNAPSHOT", 1);
+        compare("1.1-SNAPSHOT", "1.1-R12345", 1);
+    }
+
+    public void testOsgiCompare() {
+        osgiCompare("1.0.0", "1.0.0", 0);
+        osgiCompare("1.0.1", "1.0.0", 1);
+        osgiCompare("1.1", "1.0.0", 1);
+        osgiCompare("1.11", "1.9", 1);
+        osgiCompare("1.1-SNAPSHOT", "1.0.0", 1);
+        osgiCompare("2.0", "2.0-beta-8", -1);
+        osgiCompare("2.0", "2.0-SNAPSHOT", -1);
+        osgiCompare("1.11", "1.9-SNAPSHOT", 1);
+        osgiCompare("1.11-SNAPSHOT", "1.9-SNAPSHOT", 1);
+        osgiCompare("1.11-SNAPSHOT", "1.9", 1);
+        osgiCompare("1.1", "1.1-SNAPSHOT", -1);
+        osgiCompare("1.1-SNAPSHOT", "1.1-R12345", 1);
+    }
+
+    private void compare(String v1, String v2, int comp) {
+        Version vv1 = Version.create(v1);
+        Version vv2 = Version.create(v2);
+        int ret = vv1.compareTo(vv2);
+        if (ret == comp) {
+            return;
+        }
+        if (ret < 0 && comp < 0) {
+            return;
+        }
+        if (ret > 0 && comp > 0) {
+            return;
+        }
+        fail(v1 + " compare to " + v2 + " must return " + comp);
+    }
+    private void osgiCompare(String v1, String v2, int comp) {
+        Version vv1 = Version.create(v1);
+        Version vv2 = Version.create(v2);
+        int ret = vv1.osgiCompareTo(vv2);
+        if (ret == comp) {
+            return;
+        }
+        if (ret < 0 && comp < 0) {
+            return;
+        }
+        if (ret > 0 && comp > 0) {
+            return;
+        }
+        fail(v1 + " osgi compare to " + v2 + " must return " + comp);
+    }
+}
\ No newline at end of file

Added: jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/impl/AdminPermissionCheckerTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/impl/AdminPermissionCheckerTest.java?rev=1512568&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/impl/AdminPermissionCheckerTest.java (added)
+++ jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/impl/AdminPermissionCheckerTest.java Sat Aug 10 05:53:42 2013
@@ -0,0 +1,74 @@
+/*
+ * 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.impl;
+
+import javax.jcr.SimpleCredentials;
+
+import org.apache.jackrabbit.api.JackrabbitSession;
+import org.apache.jackrabbit.api.security.user.Authorizable;
+import org.apache.jackrabbit.api.security.user.Group;
+import org.apache.jackrabbit.vault.packaging.integration.IntegrationTestBase;
+import org.junit.Test;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * Testcase for {@link AdminPermissionChecker}
+ */
+public class AdminPermissionCheckerTest extends IntegrationTestBase {
+
+    @Test
+    public void testAdminUser() throws Exception {
+        assertTrue("user admin should have admin permissions", AdminPermissionChecker.hasAdministrativePermissions(admin));
+    }
+
+    @Test
+    public void testNotAdminUser() throws Exception {
+        JackrabbitSession jackrabbitSession = (JackrabbitSession) admin;
+        Authorizable vip = jackrabbitSession.getUserManager().getAuthorizable("who");
+        if (vip == null) {
+            jackrabbitSession.getUserManager().createUser("who", "who");
+        }
+        jackrabbitSession.save();
+        admin.save();
+        admin.logout();
+        admin = repository.login(new SimpleCredentials("who", "who".toCharArray()));
+        assertFalse("\"who\" is not admin/system and doesn't belong to administrators thus shouldn't have admin permissions",
+                AdminPermissionChecker.hasAdministrativePermissions(admin));
+    }
+
+    @Test
+    public void testAdminGroup() throws Exception {
+        JackrabbitSession jackrabbitSession = (JackrabbitSession) admin;
+        Authorizable admins = jackrabbitSession.getUserManager().getAuthorizable("administrators");
+        if (admins == null) {
+            admins = jackrabbitSession.getUserManager().createGroup("administrators");
+        }
+        Group adminsGroup = (Group) admins;
+        adminsGroup.addMember(jackrabbitSession.getUserManager().getAuthorizable("anonymous"));
+        jackrabbitSession.save();
+        admin.save();
+        admin.logout();
+        admin = repository.login(new SimpleCredentials("anonymous", "anonymous".toCharArray()));
+        assertTrue("user \"anonymous\" has been added to administrators group thus should have admin permissions",
+                AdminPermissionChecker.hasAdministrativePermissions(admin));
+    }
+
+
+}

Added: jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/impl/JcrPackageManagerImplTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/impl/JcrPackageManagerImplTest.java?rev=1512568&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/impl/JcrPackageManagerImplTest.java (added)
+++ jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/impl/JcrPackageManagerImplTest.java Sat Aug 10 05:53:42 2013
@@ -0,0 +1,113 @@
+/*
+ * 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.impl;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import javax.jcr.Node;
+import javax.jcr.NodeIterator;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.SimpleCredentials;
+
+import org.apache.jackrabbit.vault.packaging.integration.IntegrationTestBase;
+import org.junit.Test;
+
+import static org.junit.Assert.fail;
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+/**
+ * Testcase for {@link JcrPackageManagerImpl}
+ */
+public class JcrPackageManagerImplTest extends IntegrationTestBase {
+
+    private List<String> visitedPaths = new LinkedList<String>();
+
+    @Test
+    public void testMkdDirWithUnauthorizedSession() throws Exception {
+        Session session = mock(Session.class);
+        when(session.nodeExists(anyString())).thenReturn(false);
+        when(session.getWorkspace()).thenReturn(admin.getWorkspace());
+        JcrPackageManagerImpl jcrPackageManager = new JcrPackageManagerImpl(session);
+        String path = "/etc/packages";
+        try {
+            jcrPackageManager.mkdir(path, true);
+            fail("this should've thrown RepositoryException as the session always tells nodes don't exist");
+        }
+        catch (RepositoryException e) {
+            // everything it's ok
+        }
+
+    }
+
+    @Test
+    public void testMkDirWithAnonymousSession() throws Exception {
+        Session session = repository.login(new SimpleCredentials("anonymous", "anonymous".toCharArray()));
+        JcrPackageManagerImpl jcrPackageManager = new JcrPackageManagerImpl(session);
+        jcrPackageManager.mkdir("/something/that/is/not/going/to/be/found/anywhere/in/this/repository/even/if/searching/in/very/long/paths/like/this", false);
+        jcrPackageManager.mkdir("/something/that/is/not/going/to/be/found/anywhere/in/this/repository/even/if/searching/in/very/long/paths/like/this", false);
+        jcrPackageManager.mkdir("/something/that/is/not/going/to/be/found/anywhere/in/this/repository/even/if/searching/in/very/long/paths/like/this", false);
+    }
+
+    @Test
+    public void mkdDirStressTest() throws Exception {
+        JcrPackageManagerImpl jcrPackageManager = new JcrPackageManagerImpl(admin);
+        String path = admin.getRootNode().getPath();
+        while (path != null) {
+            jcrPackageManager.mkdir(path, true);
+            jcrPackageManager.mkdir(path, false);
+            path = getNextPath(path);
+        }
+    }
+
+    private String getNextPath(String path) throws RepositoryException {
+        Node currentNode = admin.getNode(path);
+        if (currentNode.hasNodes()) {
+            NodeIterator nodes = currentNode.getNodes();
+            while (nodes.hasNext()) {
+                Node node = nodes.nextNode();
+                String nodePath = node.getPath();
+                if (visitedPaths.contains(nodePath)) {
+                    continue;
+                } else {
+                    visitedPaths.add(nodePath);
+                }
+                return nodePath;
+            }
+            return getParentPath(path);
+        } else {
+            return getParentPath(path);
+        }
+    }
+
+    private String getParentPath(String path) throws RepositoryException {
+        Node currentNode = admin.getNode(path);
+        if (currentNode.getPath().equals(admin.getRootNode().getPath())) {
+            return null;
+        } else {
+            Node parent = currentNode.getParent();
+            if (parent != null) {
+                return parent.getPath();
+            } else {
+                return null;
+            }
+        }
+    }
+}

Added: jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/DumpCoverageTests.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/DumpCoverageTests.java?rev=1512568&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/DumpCoverageTests.java (added)
+++ jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/DumpCoverageTests.java Sat Aug 10 05:53:42 2013
@@ -0,0 +1,136 @@
+/*
+ * 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.integration;
+
+import java.io.IOException;
+import java.util.LinkedList;
+import java.util.List;
+
+import javax.jcr.RepositoryException;
+
+import org.apache.jackrabbit.commons.JcrUtils;
+import org.apache.jackrabbit.vault.fs.api.PathFilterSet;
+import org.apache.jackrabbit.vault.fs.api.ProgressTrackerListener;
+import org.apache.jackrabbit.vault.fs.config.ConfigurationException;
+import org.apache.jackrabbit.vault.fs.config.DefaultWorkspaceFilter;
+import org.apache.jackrabbit.vault.util.Text;
+import org.junit.Before;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import static junit.framework.Assert.assertEquals;
+
+/**
+ * <code>ImportTests</code>...
+ */
+public class DumpCoverageTests extends IntegrationTestBase {
+
+    /**
+     * default logger
+     */
+    private static final Logger log = LoggerFactory.getLogger(DumpCoverageTests.class);
+
+    public static final String TEST_ROOT = "/testroot";
+
+    public static final String[] ALL_PAGES = {
+            TEST_ROOT + "/content",
+            TEST_ROOT + "/content/en",
+            TEST_ROOT + "/content/en/foo",
+            TEST_ROOT + "/content/en/bar",
+            TEST_ROOT + "/content/fr",
+            TEST_ROOT + "/content/fr/foo"
+    };
+    public static final String[] LANGUAGE_PAGES = {
+            TEST_ROOT + "/content/en",
+            TEST_ROOT + "/content/en/foo",
+            TEST_ROOT + "/content/en/bar",
+            TEST_ROOT + "/content/fr",
+            TEST_ROOT + "/content/fr/foo"
+    };
+    public static String[] ALL_PATHS;
+    static {
+        ALL_PATHS = new String[ALL_PAGES.length*2];
+        for (int i=0; i<ALL_PAGES.length;i++) {
+            ALL_PATHS[i*2] = ALL_PAGES[i];
+            ALL_PATHS[i*2+1] = ALL_PAGES[i] + "/jcr:content";
+        }
+    }
+
+    @Before
+    public void init() throws RepositoryException {
+        clean(TEST_ROOT);
+
+        JcrUtils.getOrCreateByPath(TEST_ROOT, "nt:folder", admin);
+        for (String path: ALL_PAGES) {
+            JcrUtils.getOrCreateByPath(path, "nt:folder", admin);
+            JcrUtils.getOrCreateByPath(path + "/jcr:content", "nt:folder", admin);
+        }
+    }
+
+    @Test
+    public void testFullCoverage() throws IOException, RepositoryException, ConfigurationException {
+        DefaultWorkspaceFilter filter = new DefaultWorkspaceFilter();
+        PathFilterSet set1 = new PathFilterSet(TEST_ROOT + "/content");
+        filter.add(set1);
+        Collector listener = new Collector();
+        filter.dumpCoverage(admin, listener, false);
+        checkResults("Full coverage needs to include all paths", ALL_PATHS, listener.paths);
+    }
+
+    @Test
+    public void testNoJcrContentCoverage() throws IOException, RepositoryException, ConfigurationException {
+        DefaultWorkspaceFilter filter = new DefaultWorkspaceFilter();
+        PathFilterSet set1 = new PathFilterSet(TEST_ROOT + "/content");
+        filter.add(set1);
+        Collector listener = new Collector();
+        filter.dumpCoverage(admin, listener, true);
+        checkResults("Partial coverage needs to include all pages", ALL_PAGES, listener.paths);
+    }
+
+
+    @Test
+    public void testSplitRootsCoverage() throws IOException, RepositoryException, ConfigurationException {
+        DefaultWorkspaceFilter filter = new DefaultWorkspaceFilter();
+        PathFilterSet set1 = new PathFilterSet(TEST_ROOT + "/content/en");
+        PathFilterSet set2 = new PathFilterSet(TEST_ROOT + "/content/fr");
+        filter.add(set1);
+        filter.add(set2);
+        Collector listener = new Collector();
+        filter.dumpCoverage(admin, listener, true);
+        checkResults("Split roots", LANGUAGE_PAGES, listener.paths);
+    }
+
+
+    private static class Collector implements ProgressTrackerListener {
+        private final List<String> paths = new LinkedList<String>();
+
+        public void onMessage(Mode mode, String action, String path) {
+            paths.add(path);
+        }
+
+        public void onError(Mode mode, String path, Exception e) {
+        }
+    }
+
+    public static void checkResults(String msg, String[] expected, List<String> result) {
+        String left = Text.implode(expected, "\n");
+        String right = Text.implode(result.toArray(new String[result.size()]), "\n");
+        assertEquals(msg, left, right);
+    }
+}
\ No newline at end of file

Added: jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/ExternalTestHook1.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/ExternalTestHook1.java?rev=1512568&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/ExternalTestHook1.java (added)
+++ jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/ExternalTestHook1.java Sat Aug 10 05:53:42 2013
@@ -0,0 +1,39 @@
+/*
+ * 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.integration;
+
+import javax.jcr.RepositoryException;
+
+import org.apache.jackrabbit.vault.packaging.InstallContext;
+import org.apache.jackrabbit.vault.packaging.InstallHook;
+import org.apache.jackrabbit.vault.packaging.PackageException;
+
+/**
+ * <code>ExternalTestHook</code> that is called by the external_hook package.
+ */
+public class ExternalTestHook1 implements InstallHook {
+
+    public void execute(InstallContext context) throws PackageException {
+        try {
+            context.getSession().getNode("/testroot").setProperty("TestHook1", context.getPhase().toString());
+            context.getSession().save();
+        } catch (RepositoryException e) {
+            throw new PackageException(e);
+        }
+    }
+}
\ No newline at end of file

Added: jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/ExternalTestHook2.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/ExternalTestHook2.java?rev=1512568&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/ExternalTestHook2.java (added)
+++ jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/ExternalTestHook2.java Sat Aug 10 05:53:42 2013
@@ -0,0 +1,39 @@
+/*
+ * 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.integration;
+
+import javax.jcr.RepositoryException;
+
+import org.apache.jackrabbit.vault.packaging.InstallContext;
+import org.apache.jackrabbit.vault.packaging.InstallHook;
+import org.apache.jackrabbit.vault.packaging.PackageException;
+
+/**
+ * <code>ExternalTestHook</code> that is called by the external_hook package.
+ */
+public class ExternalTestHook2 implements InstallHook {
+
+    public void execute(InstallContext context) throws PackageException {
+        try {
+            context.getSession().getNode("/testroot").setProperty("TestHook2", context.getPhase().toString());
+            context.getSession().save();
+        } catch (RepositoryException e) {
+            throw new PackageException(e);
+        }
+    }
+}
\ No newline at end of file



Mime
View raw message