jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r582352 - in /jackrabbit/trunk/contrib/spi/client/src/test/java/org/apache/jackrabbit/jcr2spi: HierarchyNodeTest.java TestAll.java
Date Fri, 05 Oct 2007 17:17:56 GMT
Author: angela
Date: Fri Oct  5 10:17:55 2007
New Revision: 582352

URL: http://svn.apache.org/viewvc?rev=582352&view=rev
Log:
test for JCR-1158

Added:
    jackrabbit/trunk/contrib/spi/client/src/test/java/org/apache/jackrabbit/jcr2spi/HierarchyNodeTest.java
  (with props)
Modified:
    jackrabbit/trunk/contrib/spi/client/src/test/java/org/apache/jackrabbit/jcr2spi/TestAll.java

Added: jackrabbit/trunk/contrib/spi/client/src/test/java/org/apache/jackrabbit/jcr2spi/HierarchyNodeTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/client/src/test/java/org/apache/jackrabbit/jcr2spi/HierarchyNodeTest.java?rev=582352&view=auto
==============================================================================
--- jackrabbit/trunk/contrib/spi/client/src/test/java/org/apache/jackrabbit/jcr2spi/HierarchyNodeTest.java
(added)
+++ jackrabbit/trunk/contrib/spi/client/src/test/java/org/apache/jackrabbit/jcr2spi/HierarchyNodeTest.java
Fri Oct  5 10:17:55 2007
@@ -0,0 +1,116 @@
+/*
+ * 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.jcr2spi;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.apache.jackrabbit.test.AbstractJCRTest;
+import org.apache.jackrabbit.test.NotExecutableException;
+
+import javax.jcr.Node;
+import javax.jcr.PropertyIterator;
+import javax.jcr.NodeIterator;
+import javax.jcr.RepositoryException;
+import javax.jcr.Property;
+import javax.jcr.Session;
+import java.util.Calendar;
+import java.util.Set;
+import java.util.HashSet;
+
+/**
+ * <code>HierarchyNodeTest</code>...
+ */
+public class HierarchyNodeTest extends AbstractJCRTest {
+
+    private static Logger log = LoggerFactory.getLogger(HierarchyNodeTest.class);
+
+    private Set hierarchyNodeProps = new HashSet();
+    private Set resourceProps = new HashSet();
+
+    private String ntFolder;
+    private String ntFile;
+    private String ntResource;
+
+    private Node fileNode;
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        Session s = testRootNode.getSession();
+        String jcrPrefix = s.getNamespacePrefix(NS_JCR_URI);
+        String ntPrefix = s.getNamespacePrefix(NS_NT_URI);
+
+        ntFolder = ntPrefix + ":folder";
+        ntFile = ntPrefix + ":file";
+        ntResource = ntPrefix + ":resource";
+
+        hierarchyNodeProps.add(jcrPrefix+":primaryType");
+        hierarchyNodeProps.add(jcrPrefix+":created");
+
+        resourceProps.add(jcrPrefix+":primaryType");
+        resourceProps.add(jcrPrefix+":lastModified");
+        resourceProps.add(jcrPrefix+":mimeType");
+        resourceProps.add(jcrPrefix+":data");
+        resourceProps.add(jcrPrefix+":uuid");
+
+        try {
+            Node folder = testRootNode.addNode("folder", ntFolder);
+            fileNode = folder.addNode("file", ntFile);
+
+            Node content = fileNode.addNode(jcrPrefix + ":content", ntResource);
+            content.setProperty(jcrPrefix + ":lastModified", Calendar.getInstance());
+            content.setProperty(jcrPrefix + ":mimeType", "text/plain");
+            content.setProperty(jcrPrefix + ":data", "some plain text");
+
+            testRootNode.save();
+        } catch (RepositoryException e) {
+            throw new NotExecutableException("Cannot create hierarchy nodes.");
+        }
+    }
+
+    public void testGetProperties() throws RepositoryException {
+        Session readSession = helper.getReadOnlySession();
+        dump((Node) readSession.getItem(fileNode.getPath()));
+
+        System.out.println("bla");
+    }
+
+    /** Recursively outputs the contents of the given node. */
+    private void dump(Node node) throws RepositoryException {
+
+        // Then output the properties
+        PropertyIterator properties = node.getProperties();
+        Set set = new HashSet();
+        while (properties.hasNext()) {
+            Property property = properties.nextProperty();
+            set.add(property.getName());
+        }
+
+        if (node.getPrimaryNodeType().getName().equals(ntFolder)) {
+            assertTrue(hierarchyNodeProps.size() == set.size() && hierarchyNodeProps.containsAll(set));
+        } else if (node.getPrimaryNodeType().getName().equals(ntFile)) {
+            assertTrue(hierarchyNodeProps.size() == set.size() && hierarchyNodeProps.containsAll(set));
+        } else if (node.getPrimaryNodeType().getName().equals(ntResource)) {
+            assertTrue(resourceProps.size() == set.size() && resourceProps.containsAll(set));
+        }
+
+        // Finally output all the child nodes recursively
+        NodeIterator nodes = node.getNodes();
+        while (nodes.hasNext()) {
+            dump(nodes.nextNode());
+        }
+    }
+}
\ No newline at end of file

Propchange: jackrabbit/trunk/contrib/spi/client/src/test/java/org/apache/jackrabbit/jcr2spi/HierarchyNodeTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/trunk/contrib/spi/client/src/test/java/org/apache/jackrabbit/jcr2spi/HierarchyNodeTest.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision url

Modified: jackrabbit/trunk/contrib/spi/client/src/test/java/org/apache/jackrabbit/jcr2spi/TestAll.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/client/src/test/java/org/apache/jackrabbit/jcr2spi/TestAll.java?rev=582352&r1=582351&r2=582352&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/client/src/test/java/org/apache/jackrabbit/jcr2spi/TestAll.java
(original)
+++ jackrabbit/trunk/contrib/spi/client/src/test/java/org/apache/jackrabbit/jcr2spi/TestAll.java
Fri Oct  5 10:17:55 2007
@@ -81,6 +81,7 @@
 
         // various
         suite.addTestSuite(ReplaceNode.class);
+        suite.addTestSuite(HierarchyNodeTest.class);
 
         return suite;
     }



Mime
View raw message