jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r740745 - in /jackrabbit/sandbox/spi/spi2davex/src: main/java/org/apache/jackrabbit/spi/spi2davex/ test/java/org/apache/jackrabbit/spi/spi2davex/
Date Wed, 04 Feb 2009 14:04:02 GMT
Author: angela
Date: Wed Feb  4 14:04:01 2009
New Revision: 740745

URL: http://svn.apache.org/viewvc?rev=740745&view=rev
Log:
- JCR-1958: Enhanced JCR remoting (work in progress)

Added:
    jackrabbit/sandbox/spi/spi2davex/src/test/java/org/apache/jackrabbit/spi/spi2davex/CloneTest.java
  (with props)
    jackrabbit/sandbox/spi/spi2davex/src/test/java/org/apache/jackrabbit/spi/spi2davex/CopyTest.java
  (with props)
Modified:
    jackrabbit/sandbox/spi/spi2davex/src/main/java/org/apache/jackrabbit/spi/spi2davex/RepositoryServiceImpl.java
    jackrabbit/sandbox/spi/spi2davex/src/test/java/org/apache/jackrabbit/spi/spi2davex/TestAll.java

Modified: jackrabbit/sandbox/spi/spi2davex/src/main/java/org/apache/jackrabbit/spi/spi2davex/RepositoryServiceImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/spi/spi2davex/src/main/java/org/apache/jackrabbit/spi/spi2davex/RepositoryServiceImpl.java?rev=740745&r1=740744&r2=740745&view=diff
==============================================================================
--- jackrabbit/sandbox/spi/spi2davex/src/main/java/org/apache/jackrabbit/spi/spi2davex/RepositoryServiceImpl.java
(original)
+++ jackrabbit/sandbox/spi/spi2davex/src/main/java/org/apache/jackrabbit/spi/spi2davex/RepositoryServiceImpl.java
Wed Feb  4 14:04:01 2009
@@ -321,7 +321,9 @@
             args.append(resolver.getJCRPath(getPath(srcNodeId, sessionInfo)));
             args.append(",");
             String destParentPath = resolver.getJCRPath(getPath(destParentNodeId, sessionInfo));
-            String destPath = destParentPath + "/" + resolver.getJCRName(destName);
+            String destPath = (destParentPath.endsWith("/") ?
+                    destParentPath + resolver.getJCRName(destName) :
+                    destParentPath + "/" + resolver.getJCRName(destName));
             args.append(destPath);
 
             method.addParameter(PARAM_COPY, args.toString());
@@ -352,7 +354,9 @@
             args.append(resolver.getJCRPath(getPath(srcNodeId, sessionInfo)));
             args.append(",");
             String destParentPath = resolver.getJCRPath(getPath(destParentNodeId, sessionInfo));
-            String destPath = destParentPath + "/" + resolver.getJCRName(destName);
+            String destPath = (destParentPath.endsWith("/") ?
+                    destParentPath + resolver.getJCRName(destName) :
+                    destParentPath + "/" + resolver.getJCRName(destName));
             args.append(destPath);
             args.append(",");
             args.append(Boolean.toString(removeExisting));

Added: jackrabbit/sandbox/spi/spi2davex/src/test/java/org/apache/jackrabbit/spi/spi2davex/CloneTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/spi/spi2davex/src/test/java/org/apache/jackrabbit/spi/spi2davex/CloneTest.java?rev=740745&view=auto
==============================================================================
--- jackrabbit/sandbox/spi/spi2davex/src/test/java/org/apache/jackrabbit/spi/spi2davex/CloneTest.java
(added)
+++ jackrabbit/sandbox/spi/spi2davex/src/test/java/org/apache/jackrabbit/spi/spi2davex/CloneTest.java
Wed Feb  4 14:04:01 2009
@@ -0,0 +1,118 @@
+/*
+ * 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.spi.spi2davex;
+
+import org.apache.jackrabbit.spi.AbstractSPITest;
+import org.apache.jackrabbit.spi.Batch;
+import org.apache.jackrabbit.spi.NodeId;
+import org.apache.jackrabbit.spi.NodeInfo;
+import org.apache.jackrabbit.spi.RepositoryService;
+import org.apache.jackrabbit.spi.SessionInfo;
+import org.apache.jackrabbit.spi.commons.conversion.DefaultNamePathResolver;
+import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
+import org.apache.jackrabbit.spi.commons.name.NameConstants;
+import org.apache.jackrabbit.spi.commons.namespace.AbstractNamespaceResolver;
+import org.apache.jackrabbit.spi.commons.namespace.NamespaceResolver;
+
+import javax.jcr.NamespaceException;
+import javax.jcr.RepositoryException;
+import java.util.Iterator;
+
+/**
+ * <code>CloneTest</code>...
+ */
+public class CloneTest extends AbstractSPITest {
+
+    private final String testPath = "/test";
+    private NamePathResolver resolver;
+    private RepositoryService rs;
+    private SessionInfo si;
+
+    private SessionInfo sInfo;
+    private NodeId clonedId;
+
+    protected void setUp() throws Exception {
+        super.setUp();
+
+        rs = helper.getRepositoryService();
+        si = helper.getAdminSessionInfo();
+        NamespaceResolver nsResolver = new AbstractNamespaceResolver() {
+            public String getURI(String prefix) throws NamespaceException {
+                return ("jcr".equals(prefix)) ? "http://www.jcp.org/jcr/1.0" : prefix;
+            }
+            public String getPrefix(String uri) throws NamespaceException {
+                return ("http://www.jcp.org/jcr/1.0".equals(uri)) ? "jcr" : uri;
+            }
+        };
+        resolver = new DefaultNamePathResolver(nsResolver);
+
+        try {
+            rs.getNodeInfo(si, getNodeId(testPath));
+        } catch (RepositoryException e) {
+            Batch b = rs.createBatch(si, getNodeId("/"));
+            b.addNode(getNodeId("/"), resolver.getQName("test"), NameConstants.NT_UNSTRUCTURED,
null);
+            rs.submit(b);
+        }
+
+        // todo: retrieve second wsp-name from config
+        sInfo = rs.obtain(si, "test");
+    }
+
+    protected void tearDown() throws Exception {
+        try {
+            if (si != null) {
+                Batch b = rs.createBatch(si, getNodeId("/"));
+                b.remove(getNodeId(testPath));
+                rs.submit(b);
+            }
+            if (sInfo != null && clonedId != null) {
+                Batch b = rs.createBatch(sInfo, getNodeId("/"));
+                b.remove(clonedId);
+                rs.submit(b);
+            }
+        } catch (RepositoryException e) {
+            // cleanup failed... ignore.
+        } finally {
+            if (sInfo != null) {
+                rs.dispose(sInfo);                
+            }
+            if (si != null) {
+                rs.dispose(si);
+            }
+            super.tearDown();
+        }
+    }
+
+    private NodeId getNodeId(String path) throws RepositoryException {
+        return rs.getIdFactory().createNodeId((String) null, resolver.getQPath(path));
+    }
+
+    public void testClone() throws RepositoryException {
+        NodeId srcId = getNodeId(testPath);
+        NodeId destParentId = getNodeId("/");
+        rs.clone(sInfo, si.getWorkspaceName(), srcId, destParentId, resolver.getQName("destname"),
true);
+
+        clonedId = getNodeId("/destname");
+        NodeInfo nInfo = rs.getNodeInfo(sInfo, clonedId);
+        Iterator it = rs.getItemInfos(sInfo, clonedId);
+
+        assertTrue(it.hasNext());
+        NodeInfo nInfo2 = (NodeInfo) it.next();
+        assertEquals(nInfo.getId(), nInfo2.getId());
+        assertEquals(nInfo.getNodetype(), nInfo2.getNodetype());
+    }
+}
\ No newline at end of file

Propchange: jackrabbit/sandbox/spi/spi2davex/src/test/java/org/apache/jackrabbit/spi/spi2davex/CloneTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/sandbox/spi/spi2davex/src/test/java/org/apache/jackrabbit/spi/spi2davex/CloneTest.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision url

Added: jackrabbit/sandbox/spi/spi2davex/src/test/java/org/apache/jackrabbit/spi/spi2davex/CopyTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/spi/spi2davex/src/test/java/org/apache/jackrabbit/spi/spi2davex/CopyTest.java?rev=740745&view=auto
==============================================================================
--- jackrabbit/sandbox/spi/spi2davex/src/test/java/org/apache/jackrabbit/spi/spi2davex/CopyTest.java
(added)
+++ jackrabbit/sandbox/spi/spi2davex/src/test/java/org/apache/jackrabbit/spi/spi2davex/CopyTest.java
Wed Feb  4 14:04:01 2009
@@ -0,0 +1,141 @@
+/*
+ * 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.spi.spi2davex;
+
+import org.apache.jackrabbit.spi.AbstractSPITest;
+import org.apache.jackrabbit.spi.RepositoryService;
+import org.apache.jackrabbit.spi.SessionInfo;
+import org.apache.jackrabbit.spi.NodeId;
+import org.apache.jackrabbit.spi.Batch;
+import org.apache.jackrabbit.spi.NodeInfo;
+import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
+import org.apache.jackrabbit.spi.commons.conversion.DefaultNamePathResolver;
+import org.apache.jackrabbit.spi.commons.namespace.NamespaceResolver;
+import org.apache.jackrabbit.spi.commons.namespace.AbstractNamespaceResolver;
+import org.apache.jackrabbit.spi.commons.name.NameConstants;
+
+import javax.jcr.NamespaceException;
+import javax.jcr.RepositoryException;
+import java.util.Iterator;
+
+/**
+ * <code>CopyTest</code>...
+ */
+public class CopyTest extends AbstractSPITest {
+    private final String testPath = "/test";
+    private NamePathResolver resolver;
+    private RepositoryService rs;
+    private SessionInfo si;
+
+    private SessionInfo sInfo;
+    private NodeId copiedId;
+
+    protected void setUp() throws Exception {
+        super.setUp();
+
+        rs = helper.getRepositoryService();
+        si = helper.getAdminSessionInfo();
+        NamespaceResolver nsResolver = new AbstractNamespaceResolver() {
+            public String getURI(String prefix) throws NamespaceException {
+                return ("jcr".equals(prefix)) ? "http://www.jcp.org/jcr/1.0" : prefix;
+            }
+            public String getPrefix(String uri) throws NamespaceException {
+                return ("http://www.jcp.org/jcr/1.0".equals(uri)) ? "jcr" : uri;
+            }
+        };
+        resolver = new DefaultNamePathResolver(nsResolver);
+
+        try {
+            rs.getNodeInfo(si, getNodeId(testPath));
+        } catch (RepositoryException e) {
+            Batch b = rs.createBatch(si, getNodeId("/"));
+            b.addNode(getNodeId("/"), resolver.getQName("test"), NameConstants.NT_UNSTRUCTURED,
null);
+            rs.submit(b);
+        }
+    }
+
+    protected void tearDown() throws Exception {
+        try {
+            if (si != null) {
+                Batch b = rs.createBatch(si, getNodeId("/"));
+                b.remove(getNodeId(testPath));
+                rs.submit(b);
+            }
+            if (sInfo != null && copiedId != null) {
+                Batch b = rs.createBatch(sInfo, getNodeId("/"));
+                b.remove(copiedId);
+                rs.submit(b);
+            }
+        } catch (RepositoryException e) {
+            // cleanup failed... ignore.
+        } finally {
+            if (sInfo != null) {
+                rs.dispose(sInfo);
+            }
+            if (si != null) {
+                rs.dispose(si);
+            }
+            super.tearDown();
+        }
+    }
+
+    private NodeId getNodeId(String path) throws RepositoryException {
+        return rs.getIdFactory().createNodeId((String) null, resolver.getQPath(path));
+    }
+
+    public void testCopy() throws RepositoryException {
+        NodeId nid = null;
+        try {
+            NodeId srcId = getNodeId(testPath);
+            NodeId destParentId = getNodeId("/");
+            rs.copy(si, si.getWorkspaceName(), srcId, destParentId, resolver.getQName("destname"));
+
+            nid = getNodeId("/destname");
+            NodeInfo nInfo = rs.getNodeInfo(si, nid);
+            Iterator it = rs.getItemInfos(si, nid);
+
+            assertTrue(it.hasNext());
+            NodeInfo nInfo2 = (NodeInfo) it.next();
+            assertEquals(nInfo.getId(), nInfo2.getId());
+            assertEquals(nInfo.getNodetype(), nInfo2.getNodetype());
+        } finally {
+            if (nid != null) {
+                Batch b = rs.createBatch(si, getNodeId("/"));
+                b.remove(nid);
+                rs.submit(b);
+            }
+        }
+    }
+
+    public void testCopyAcrossWorkspaces() throws RepositoryException {
+        // todo: retrieve second wsp-name from config
+        sInfo = rs.obtain(si, "test");
+
+        NodeId srcId = getNodeId(testPath);
+        NodeId destParentId = getNodeId("/");
+        rs.copy(sInfo, si.getWorkspaceName(), srcId, destParentId, resolver.getQName("destname"));
+
+        copiedId = getNodeId("/destname");
+        NodeInfo nInfo = rs.getNodeInfo(sInfo, copiedId);
+        Iterator it = rs.getItemInfos(sInfo, copiedId);
+
+        assertTrue(it.hasNext());
+        NodeInfo nInfo2 = (NodeInfo) it.next();
+        assertEquals(nInfo.getId(), nInfo2.getId());
+        assertEquals(nInfo.getNodetype(), nInfo2.getNodetype());
+    }
+}
\ No newline at end of file

Propchange: jackrabbit/sandbox/spi/spi2davex/src/test/java/org/apache/jackrabbit/spi/spi2davex/CopyTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/sandbox/spi/spi2davex/src/test/java/org/apache/jackrabbit/spi/spi2davex/CopyTest.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision url

Modified: jackrabbit/sandbox/spi/spi2davex/src/test/java/org/apache/jackrabbit/spi/spi2davex/TestAll.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/spi/spi2davex/src/test/java/org/apache/jackrabbit/spi/spi2davex/TestAll.java?rev=740745&r1=740744&r2=740745&view=diff
==============================================================================
--- jackrabbit/sandbox/spi/spi2davex/src/test/java/org/apache/jackrabbit/spi/spi2davex/TestAll.java
(original)
+++ jackrabbit/sandbox/spi/spi2davex/src/test/java/org/apache/jackrabbit/spi/spi2davex/TestAll.java
Wed Feb  4 14:04:01 2009
@@ -33,6 +33,8 @@
         suite.addTestSuite(ConnectionTest.class);
         suite.addTestSuite(ReadTest.class);
         suite.addTestSuite(BatchTest.class);
+        suite.addTestSuite(CopyTest.class);
+        suite.addTestSuite(CloneTest.class);
 
         return suite;
     }



Mime
View raw message