jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r156950 - in incubator/jackrabbit/trunk: applications/test/ src/test/org/apache/jackrabbit/test/api/
Date Thu, 10 Mar 2005 13:43:39 GMT
Author: mreutegg
Date: Thu Mar 10 05:42:49 2005
New Revision: 156950

URL: http://svn.apache.org/viewcvs?view=rev&rev=156950
Log:
Change test root for level 1 tests. minor adaptions on test cases.

Modified:
    incubator/jackrabbit/trunk/applications/test/repositoryStubImpl.properties
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/AbstractPropertyTest.java
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/NodeDiscoveringNodeTypesTest.java
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/NodeReadMethodsTest.java
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/PropertyReadMethodsTest.java
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/PropertyTypeTest.java
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/UndefinedPropertyTest.java

Modified: incubator/jackrabbit/trunk/applications/test/repositoryStubImpl.properties
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/applications/test/repositoryStubImpl.properties?view=diff&r1=156949&r2=156950
==============================================================================
--- incubator/jackrabbit/trunk/applications/test/repositoryStubImpl.properties (original)
+++ incubator/jackrabbit/trunk/applications/test/repositoryStubImpl.properties Thu Mar 10
05:42:49 2005
@@ -44,67 +44,70 @@
 # ==============================================================================
 
 # Test class: ItemDefTest
-javax.jcr.tck.ItemDefTest.testroot=/
+javax.jcr.tck.ItemDefTest.testroot=/testdata
 
 # Test class: ItemReadMethodsTest
-javax.jcr.tck.ItemReadMethodsTest.testroot=/
+javax.jcr.tck.ItemReadMethodsTest.testroot=/testdata
 
 # Test class: NodeReadMethodsTest
-javax.jcr.tck.NodeReadMethodsTest.testroot=/
+javax.jcr.tck.NodeReadMethodsTest.testroot=/testdata
 
 # Test class: PropertyTypeTest
-javax.jcr.tck.PropertyTypeTest.testroot=/
+javax.jcr.tck.PropertyTypeTest.testroot=/testdata
 
 # Test class: BinaryPropertyTest
-javax.jcr.tck.BinaryPropertyTest.testroot=/
+javax.jcr.tck.BinaryPropertyTest.testroot=/testdata
 
 # Test class: BooleanPropertyTest
-javax.jcr.tck.BooleanPropertyTest.testroot=/
+javax.jcr.tck.BooleanPropertyTest.testroot=/testdata
 
 # Test class: DatePropertyTest
-javax.jcr.tck.DatePropertyTest.testroot=/
+javax.jcr.tck.DatePropertyTest.testroot=/testdata
 
 # Test class: DoublePropertyTest
-javax.jcr.tck.DoublePropertyTest.testroot=/
+javax.jcr.tck.DoublePropertyTest.testroot=/testdata
 
 # Test class: LongPropertyTest
-javax.jcr.tck.LongPropertyTest.testroot=/
+javax.jcr.tck.LongPropertyTest.testroot=/testdata
 
 # Test class: NamePropertyTest
-javax.jcr.tck.NamePropertyTest.testroot=/
+javax.jcr.tck.NamePropertyTest.testroot=/testdata
 
 # Test class: PathPropertyTest
-javax.jcr.tck.PathPropertyTest.testroot=/
+javax.jcr.tck.PathPropertyTest.testroot=/testdata
 
 # Test class: ReferencePropertyTest
-javax.jcr.tck.ReferencePropertyTest.testroot=/
+javax.jcr.tck.ReferencePropertyTest.testroot=/testdata
 
 # Test class: StringPropertyTest
-javax.jcr.tck.StringPropertyTest.testroot=/
+javax.jcr.tck.StringPropertyTest.testroot=/testdata
 
 # Test class: UndefinedPropertyTest
-javax.jcr.tck.UndefinedPropertyTest.testroot=/
+javax.jcr.tck.UndefinedPropertyTest.testroot=/testdata
 
 # Test class: PropertyReadMethodsTest
-javax.jcr.tck.PropertyReadMethodsTest.testroot=/
+javax.jcr.tck.PropertyReadMethodsTest.testroot=/testdata
 
 # Test class: NodeIteratorTest
-javax.jcr.tck.NodeIteratorTest.testroot=/
+javax.jcr.tck.NodeIteratorTest.testroot=/testdata
+
+# Test class: NodeDiscoveringNodeTypesTest
+javax.jcr.tck.NodeDiscoveringNodeTypesTest.testroot=/testdata
 
 # Test class: RepositoryDescriptorTest
-javax.jcr.tck.RepositoryDescriptorTest.testroot=/
+javax.jcr.tck.RepositoryDescriptorTest.testroot=/testdata
 
 # Test class: WorkspaceReadMethodsTest
-javax.jcr.tck.WorkspaceReadMethodsTest.testroot=/
+javax.jcr.tck.WorkspaceReadMethodsTest.testroot=/testdata
 
 # Test class: SessionReadMethodsTest
-javax.jcr.tck.SessionReadMethodsTest.testroot=/
+javax.jcr.tck.SessionReadMethodsTest.testroot=/testdata
 
 # Test class: NamespaceRegistryReadMethodsTest
-javax.jcr.tck.NamespaceRegistryReadMethodsTest.testroot=/
+javax.jcr.tck.NamespaceRegistryReadMethodsTest.testroot=/testdata
 
 # Test class: NamespaceRemappingTest
-javax.jcr.tck.NamespaceRemappingTest.testroot=/
+javax.jcr.tck.NamespaceRemappingTest.testroot=/testdata
 
 # Test class: SessionTest
 # Test method: testMoveItemExistsException
@@ -318,6 +321,3 @@
 javax.jcr.tck.OnParentVersionCopyTest.nodetype=nt:unstructured
 javax.jcr.tck.OnParentVersionAbortTest.nodename4=test:abortOnParentVersion
 javax.jcr.tck.OnParentVersionAbortTest.nodetype=nt:unstructured
-
-# Test class: MergeNodeTest
-javax.jcr.tck.MergeNodeTest.nodetype=test:versionable

Modified: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/AbstractPropertyTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/AbstractPropertyTest.java?view=diff&r1=156949&r2=156950
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/AbstractPropertyTest.java
(original)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/AbstractPropertyTest.java
Thu Mar 10 05:42:49 2005
@@ -55,7 +55,7 @@
         super.setUp();
         session = helper.getReadOnlySession();
 
-        prop = PropertyUtil.searchProp(session, session.getRootNode(), getPropertyType());
+        prop = PropertyUtil.searchProp(session, session.getRootNode().getNode(testPath),
getPropertyType());
         if (prop == null) {
             String msg = "Workspace does not contain a node with a " +
                     PropertyType.nameFromValue(getPropertyType()) + " property.";

Modified: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/NodeDiscoveringNodeTypesTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/NodeDiscoveringNodeTypesTest.java?view=diff&r1=156949&r2=156950
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/NodeDiscoveringNodeTypesTest.java
(original)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/NodeDiscoveringNodeTypesTest.java
Thu Mar 10 05:42:49 2005
@@ -28,10 +28,8 @@
 import java.util.NoSuchElementException;
 
 /**
- * <code>NodeDiscoveringNodeTypesTest</code>...
- * <p/>
  * All test cases in this class rely on content in the repository. That is the
- * root node of the default workspace must at least contain one child node,
+ * default workspace must at least contain one child node under {@link #testRoot}
  * otherwise a {@link NotExecutableException} is thrown.
  *
  * @test
@@ -47,11 +45,6 @@
     private Session session;
 
     /**
-     * The root node of the default workspace
-     */
-    private Node rootNode;
-
-    /**
      * A child node of the root node in the default workspace.
      */
     private Node childNode;
@@ -64,8 +57,8 @@
         super.setUp();
 
         session = helper.getReadOnlySession();
-        rootNode = session.getRootNode();
-        NodeIterator nodes = rootNode.getNodes();
+        testRootNode = session.getRootNode().getNode(testPath);
+        NodeIterator nodes = testRootNode.getNodes();
         try {
             childNode = nodes.nextNode();
         } catch (NoSuchElementException e) {
@@ -120,7 +113,7 @@
                     "Root node must have at least one child node.");
         }
 
-        Node node = locateNodeWithMixinNodeTypes(rootNode);
+        Node node = locateNodeWithMixinNodeTypes(testRootNode);
 
         if (node == null) {
             throw new NotExecutableException("Workspace does not contain a node with mixin
node types defined");
@@ -165,14 +158,14 @@
         String nodeTypeName;
 
         // test with primary node's name
-        nodeTypeName = rootNode.getPrimaryNodeType().getName();
+        nodeTypeName = testRootNode.getPrimaryNodeType().getName();
         assertTrue("isNodeType(String nodeTypeName) must return true if " +
                 "nodeTypeName is the name of the primary node type",
-                rootNode.isNodeType(nodeTypeName));
+                testRootNode.isNodeType(nodeTypeName));
 
         // test with mixin node's name
         // (if such a node is available)
-        Node nodeWithMixin = locateNodeWithMixinNodeTypes(rootNode);
+        Node nodeWithMixin = locateNodeWithMixinNodeTypes(testRootNode);
         if (nodeWithMixin != null) {
             NodeType types[] = nodeWithMixin.getMixinNodeTypes();
             nodeTypeName = types[0].getName();
@@ -185,7 +178,7 @@
         // test with the name of predefined supertype "nt:base"
         assertTrue("isNodeType(String nodeTypeName) must return true if " +
                 "nodeTypeName is the name of a node type of a supertype",
-                rootNode.isNodeType(ntBase));
+                testRootNode.isNodeType(ntBase));
     }
 
     //-----------------------< internal >---------------------------------------

Modified: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/NodeReadMethodsTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/NodeReadMethodsTest.java?view=diff&r1=156949&r2=156950
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/NodeReadMethodsTest.java
(original)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/NodeReadMethodsTest.java
Thu Mar 10 05:42:49 2005
@@ -54,12 +54,7 @@
     private Session session;
 
     /**
-     * The root node of the default workspace
-     */
-    private Node rootNode;
-
-    /**
-     * The first child node of the rootNode
+     * The first child node of the testRootNode
      */
     private Node childNode;
 
@@ -71,9 +66,9 @@
         super.setUp();
 
         session = helper.getReadOnlySession();
-        rootNode = session.getRootNode();
 
-        NodeIterator nodes = rootNode.getNodes();
+        testRootNode = session.getRootNode().getNode(testPath);
+        NodeIterator nodes = testRootNode.getNodes();
         try {
             childNode = nodes.nextNode();
         } catch (NoSuchElementException e) {
@@ -102,8 +97,8 @@
             throw new NotExecutableException("Workspace does not have sufficient content
to run this test.");
         }
 
-        String path = "/" + childNode.getName();
-        if (getSize(rootNode.getNodes(childNode.getName())) > 1) {
+        String path = testRoot + "/" + childNode.getName();
+        if (getSize(testRootNode.getNodes(childNode.getName())) > 1) {
             // is a same-name-sibling, append index
             path += "[" + childNode.getIndex() + "]";
         }
@@ -120,7 +115,7 @@
     public void testGetName() throws RepositoryException {
         assertEquals("getName() of root must be an empty string",
                 "",
-                rootNode.getName());
+                session.getRootNode().getName());
 
         // build name from path
         String path = childNode.getPath();
@@ -138,9 +133,9 @@
      * <code>Item</code>, returns this <code>Node</code> itself.
      */
     public void testGetAncestorOfNodeDepth() throws RepositoryException {
-        Node nodeAtDepth = (Node) rootNode.getAncestor(rootNode.getDepth());
+        Node nodeAtDepth = (Node) testRootNode.getAncestor(testRootNode.getDepth());
         assertTrue("The ancestor of depth = n, where n is the depth of this " +
-                "Node must be the item itself.", rootNode.isSame(nodeAtDepth));
+                "Node must be the item itself.", testRootNode.isSame(nodeAtDepth));
     }
 
     /**
@@ -149,8 +144,8 @@
      */
     public void testGetAncestorOfGreaterDepth() throws RepositoryException {
         try {
-            int greaterDepth = rootNode.getDepth() + 1;
-            rootNode.getAncestor(greaterDepth);
+            int greaterDepth = testRootNode.getDepth() + 1;
+            testRootNode.getAncestor(greaterDepth);
             fail("Getting ancestor of depth n, where n is greater than depth of" +
                     "this Node must throw an ItemNotFoundException");
         } catch (ItemNotFoundException e) {
@@ -164,7 +159,7 @@
      */
     public void testGetAncestorOfNegativeDepth() throws RepositoryException {
         try {
-            rootNode.getAncestor(-1);
+            testRootNode.getAncestor(-1);
             fail("Getting ancestor of depth < 0 must throw an ItemNotFoundException.");
         } catch (ItemNotFoundException e) {
             // success
@@ -182,7 +177,7 @@
         }
 
         assertTrue("getParent() of a child node return the parent node.",
-                rootNode.isSame(childNode.getParent()));
+                testRootNode.isSame(childNode.getParent()));
     }
 
     /**
@@ -190,7 +185,7 @@
      */
     public void testGetParentOfRoot() throws RepositoryException {
         try {
-            rootNode.getParent();
+            session.getRootNode().getParent();
             fail("getParent() of root must throw an ItemNotFoundException.");
         } catch (ItemNotFoundException e) {
             // success
@@ -201,10 +196,10 @@
      * Tests if depth of root is 0 and depth of a sub node of root is 1
      */
     public void testGetDepth() throws RepositoryException {
-        assertEquals("getDepth() of root must be 0", 0, rootNode.getDepth());
-        if (childNode != null) {
+        assertEquals("getDepth() of root must be 0", 0, session.getRootNode().getDepth());
+        for (NodeIterator it = session.getRootNode().getNodes(); it.hasNext();) {
             assertEquals("getDepth() of child node of root must be 1", 1,
-                    childNode.getDepth());
+                    it.nextNode().getDepth());
         }
     }
 
@@ -214,7 +209,7 @@
     public void testGetSession() throws RepositoryException {
         assertSame("getSession must return the Session through which " +
                 "the Node was acquired.",
-                rootNode.getSession(),
+                testRootNode.getSession(),
                 session);
     }
 
@@ -223,7 +218,7 @@
      */
     public void testIsNode() {
         assertTrue("isNode() must return true.",
-                rootNode.isNode());
+                testRootNode.isNode());
     }
 
     /**
@@ -232,17 +227,17 @@
      */
     public void testIsSame() throws RepositoryException {
         // access same node through different session
-        Item otherRootNode = helper.getReadOnlySession().getRootNode();
+        Item otherTestNode = helper.getReadOnlySession().getRootNode().getNode(testPath);
         assertTrue("isSame(Item item) must return true for the same " +
                 "item retrieved through different sessions.",
-                rootNode.isSame(otherRootNode));
+                testRootNode.isSame(otherTestNode));
     }
 
     /**
      *
      */
     public void testAccept() throws RepositoryException {
-        final Node n = rootNode;
+        final Node n = testRootNode;
 
         ItemVisitor itemVisitor = new ItemVisitor() {
             public void visit(Property property) {
@@ -268,7 +263,7 @@
             throws NotExecutableException, RepositoryException {
 
         StringBuffer notExistingPath = new StringBuffer("X");
-        NodeIterator nodes = rootNode.getNodes();
+        NodeIterator nodes = testRootNode.getNodes();
         while (nodes.hasNext()) {
             // build a path that for sure is not existing
             // (":" of namespace prefix will be replaced later on)
@@ -276,7 +271,7 @@
         }
 
         try {
-            rootNode.getNode(notExistingPath.toString().replaceAll(":", ""));
+            testRootNode.getNode(notExistingPath.toString().replaceAll(":", ""));
             fail("getNode(String relPath) must throw a PathNotFoundException" +
                     "if no node exists at relPath");
         } catch (PathNotFoundException e) {
@@ -284,10 +279,10 @@
         }
 
         try {
-            NodeIterator nodes2 = rootNode.getNodes();
+            NodeIterator nodes2 = testRootNode.getNodes();
             Node node = nodes2.nextNode();
             assertTrue("Node from Iterator is not the same as the Node from getNode()",
-                    rootNode.getNode(node.getName()).isSame(node));
+                    testRootNode.getNode(node.getName()).isSame(node));
         } catch (NoSuchElementException e) {
             throw new NotExecutableException("Workspace does not have sufficient content
for this test. " +
                     "Root node must have at least one child node.");
@@ -298,7 +293,7 @@
      * Test if all returned items are of type node.
      */
     public void testGetNodes() throws RepositoryException {
-        NodeIterator nodes = rootNode.getNodes();
+        NodeIterator nodes = testRootNode.getNodes();
         while (nodes.hasNext()) {
             Item item = (Item) nodes.next();
             assertTrue("Item is not a node", item.isNode());
@@ -314,7 +309,7 @@
             throws NotExecutableException, RepositoryException {
 
         // get root node and build an ArrayList of its sub nodes
-        Node node = rootNode;
+        Node node = testRootNode;
         if (!node.hasNodes()) {
             throw new NotExecutableException("Workspace does not have sufficient content
for this test. " +
                     "Root node must have at least one child node.");
@@ -436,7 +431,7 @@
     public void testGetProperty()
             throws NotExecutableException, RepositoryException {
         StringBuffer notExistingPath = new StringBuffer("X");
-        PropertyIterator properties = rootNode.getProperties();
+        PropertyIterator properties = testRootNode.getProperties();
         while (properties.hasNext()) {
             // build a path that for sure is not existing
             // (":" of namespace prefix will be replaced later on)
@@ -444,7 +439,7 @@
         }
 
         try {
-            rootNode.getProperty(notExistingPath.toString().replaceAll(":", ""));
+            testRootNode.getProperty(notExistingPath.toString().replaceAll(":", ""));
             fail("getProperty(String relPath) must throw a " +
                     "PathNotFoundException if no node exists at relPath");
         } catch (PathNotFoundException e) {
@@ -452,10 +447,10 @@
         }
 
         try {
-            PropertyIterator properties2 = rootNode.getProperties();
+            PropertyIterator properties2 = testRootNode.getProperties();
             Property property = properties2.nextProperty();
             assertTrue("Property returned by getProperties() is not the same as returned
by getProperty(String).",
-                    rootNode.getProperty(property.getName()).isSame(property));
+                    testRootNode.getProperty(property.getName()).isSame(property));
         } catch (NoSuchElementException e) {
             fail("Root node must always have at least one property: jcr:primaryType");
         }
@@ -465,7 +460,7 @@
      * Test if all returned items are of type node.
      */
     public void testGetProperties() throws RepositoryException {
-        PropertyIterator properties = rootNode.getProperties();
+        PropertyIterator properties = testRootNode.getProperties();
         while (properties.hasNext()) {
             Item item = (Item) properties.next();
             assertFalse("Item is not a property", item.isNode());
@@ -481,7 +476,7 @@
             throws NotExecutableException, RepositoryException {
 
         // get root node and build an ArrayList of its sub nodes
-        Node node = rootNode;
+        Node node = testRootNode;
         if (!node.hasProperties()) {
             fail("Root node must always have at least one property: jcr:primaryType");
         }
@@ -606,7 +601,7 @@
     public void testGetPrimaryItem()
             throws NotExecutableException, RepositoryException {
 
-        Node node = locateNodeWithPrimaryItem(rootNode);
+        Node node = locateNodeWithPrimaryItem(testRootNode);
 
         if (node == null) {
             throw new NotExecutableException("Workspace does not contain a node with primary
item defined");
@@ -635,7 +630,7 @@
     public void testGetPrimaryItemItemNotFoundException()
             throws NotExecutableException, RepositoryException {
 
-        Node node = locateNodeWithoutPrimaryItem(rootNode);
+        Node node = locateNodeWithoutPrimaryItem(testRootNode);
 
         if (node == null) {
             throw new NotExecutableException("Workspace does not contain a node with primary
item defined");
@@ -653,16 +648,16 @@
     /**
      * Test if getIndex() returns the correct index. Therefor a node with same
      * name sibling is located recursively in the entire repository. If no such
-     * node is found, the test checks if the rootNode returns 1
+     * node is found, the test checks if the testRootNode returns 1
      */
     public void testGetIndex()
             throws RepositoryException {
 
-        Node node = locateNodeWithSameNameSiblings(rootNode);
+        Node node = locateNodeWithSameNameSiblings(testRootNode);
 
         if (node == null) {
             assertEquals("getIndex() of a node without same name siblings " +
-                    "must return 1", rootNode.getIndex(), 1);
+                    "must return 1", testRootNode.getIndex(), 1);
         } else {
             NodeIterator nodes = node.getParent().getNodes(node.getName());
             int i = 1;
@@ -678,7 +673,7 @@
     public void testGetReferences()
             throws NotExecutableException, RepositoryException {
 
-        Node node = locateNodeWithReference(rootNode);
+        Node node = locateNodeWithReference(testRootNode);
 
         if (node == null) {
             throw new NotExecutableException("Workspace does not contain a node with a reference
property set");
@@ -687,12 +682,13 @@
         PropertyIterator properties = node.getProperties();
         while (properties.hasNext()) {
             Property p = properties.nextProperty();
-            if (p.getType() == PropertyType.REFERENCE) {
+            if (p.getType() == PropertyType.REFERENCE && !p.getDefinition().isMultiple())
{
                 Node referencedNode = p.getNode();
                 PropertyIterator refs = referencedNode.getReferences();
                 boolean referenceFound = false;
                 while (refs.hasNext()) {
-                    if (refs.nextProperty() == p) {
+                    Property ref = refs.nextProperty();
+                    if (ref.isSame(p)) {
                         referenceFound = true;
                     }
                 }
@@ -714,7 +710,7 @@
             throws NotExecutableException, RepositoryException {
 
         // find a node of type mix:referenceable
-        Node node = locateReferenceableNode(rootNode);
+        Node node = locateReferenceableNode(testRootNode);
 
         if (node == null) {
             throw new NotExecutableException("Workspace does not contain a referencable node");
@@ -738,7 +734,7 @@
             throws NotExecutableException, RepositoryException {
 
         // find a node NOT of type mix:referenceable
-        Node node = locateNonReferenceableNode(rootNode);
+        Node node = locateNonReferenceableNode(testRootNode);
 
         if (node == null) {
             throw new NotExecutableException("Workspace does not contain a non referenceable
node");
@@ -759,7 +755,7 @@
     public void testHasNode()
             throws NotExecutableException, RepositoryException {
 
-        Node node = rootNode;
+        Node node = testRootNode;
 
         NodeIterator nodes = node.getNodes();
         StringBuffer notExistingNodeName = new StringBuffer();
@@ -785,7 +781,7 @@
      * Tested node: root
      */
     public void testHasNodes() throws RepositoryException {
-        Node node = rootNode;
+        Node node = testRootNode;
         NodeIterator nodes = node.getNodes();
 
         int i = 0;
@@ -812,7 +808,7 @@
     public void testHasProperty()
             throws NotExecutableException, RepositoryException {
 
-        Node node = rootNode;
+        Node node = testRootNode;
 
         PropertyIterator properties = node.getProperties();
         StringBuffer notExistingPropertyName = new StringBuffer();
@@ -839,7 +835,7 @@
      * @throws RepositoryException
      */
     public void testHasProperties() throws RepositoryException {
-        Node node = rootNode;
+        Node node = testRootNode;
         PropertyIterator properties = node.getProperties();
 
         int i = 0;
@@ -910,7 +906,8 @@
 
     /**
      * Returns the first descendant of <code>node</code> which has a property
of
-     * type {@link javax.jcr.PropertyType#REFERENCE} set.
+     * type {@link javax.jcr.PropertyType#REFERENCE} set and is <b>not</b>
+     * multivalued.
      *
      * @param node <code>Node</code> to start traversal.
      * @return first node with a property of PropertType.REFERENCE
@@ -921,7 +918,7 @@
         PropertyIterator properties = node.getProperties();
         while (properties.hasNext()) {
             Property p = properties.nextProperty();
-            if (p.getType() == PropertyType.REFERENCE) {
+            if (p.getType() == PropertyType.REFERENCE && !p.getDefinition().isMultiple())
{
                 return node;
             }
         }

Modified: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/PropertyReadMethodsTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/PropertyReadMethodsTest.java?view=diff&r1=156949&r2=156950
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/PropertyReadMethodsTest.java
(original)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/PropertyReadMethodsTest.java
Thu Mar 10 05:42:49 2005
@@ -47,11 +47,6 @@
     private Session session;
 
     /**
-     * The root node of the default workspace
-     */
-    private Node rootNode;
-
-    /**
      * A property of the root node
      */
     private Property property;
@@ -64,9 +59,9 @@
         super.setUp();
 
         session = helper.getReadOnlySession();
-        rootNode = session.getRootNode();
+        testRootNode = session.getRootNode().getNode(testPath);
 
-        PropertyIterator properties = rootNode.getProperties();
+        PropertyIterator properties = testRootNode.getProperties();
         try {
             property = properties.nextProperty();
         } catch (NoSuchElementException e) {
@@ -94,7 +89,7 @@
             throws NotExecutableException, RepositoryException {
 
         assertEquals("getPath returns wrong result",
-                "/" + property.getName(),
+                testRoot + "/" + property.getName(),
                 property.getPath());
     }
 
@@ -158,14 +153,14 @@
      */
     public void testGetParent() throws RepositoryException {
         assertTrue("getParent() of a property must return the parent node.",
-                rootNode.isSame(property.getParent()));
+                testRootNode.isSame(property.getParent()));
     }
 
     /**
-     * Tests if depth of a property of root is 1
+     * Tests if depth of a property of depth of node + 1
      */
     public void testGetDepth() throws RepositoryException {
-        assertEquals("getDepth() of a property of root must be 1", 1,
+        assertEquals("getDepth() of a property of root must be 1", testRootNode.getDepth()
+ 1,
                 property.getDepth());
     }
 
@@ -193,7 +188,7 @@
      */
     public void testIsSame() throws RepositoryException {
         // access same property through different session
-        PropertyIterator properties = helper.getReadOnlySession().getRootNode().getProperties();
+        PropertyIterator properties = testRootNode.getProperties();
         Property otherProperty = properties.nextProperty();
         assertTrue("isSame must return true for the same " +
                 "property retrieved through different sessions.",
@@ -226,7 +221,7 @@
      */
     public void testNoNullValue() throws RepositoryException {
         assertFalse("Single property with null value found.",
-                PropertyUtil.nullValues(rootNode));
+                PropertyUtil.nullValues(testRootNode));
     }
 
     /**
@@ -234,7 +229,7 @@
      * type.
      */
     public void testMultiValueType() throws RepositoryException, NotExecutableException {
-        Property multiValProp = PropertyUtil.searchMultivalProp(rootNode);
+        Property multiValProp = PropertyUtil.searchMultivalProp(testRootNode);
         if (multiValProp != null) {
             Value[] vals = multiValProp.getValues();
             if (vals.length > 0) {
@@ -253,7 +248,7 @@
      * Tests failure of Property.getValue() method for a multivalue property.
      */
     public void testGetValue() throws RepositoryException, NotExecutableException {
-        Property multiValProp = PropertyUtil.searchMultivalProp(rootNode);
+        Property multiValProp = PropertyUtil.searchMultivalProp(testRootNode);
         if (multiValProp != null) {
             try {
                 multiValProp.getValue();
@@ -272,7 +267,7 @@
      * property.
      */
     public void testGetValues() throws RepositoryException {
-        Property singleProp = PropertyUtil.searchProp(session, rootNode, PropertyType.STRING);
+        Property singleProp = PropertyUtil.searchProp(session, testRootNode, PropertyType.STRING);
         try {
             singleProp.getValues();
             fail("Property.getValues() called on a single property " +

Modified: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/PropertyTypeTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/PropertyTypeTest.java?view=diff&r1=156949&r2=156950
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/PropertyTypeTest.java
(original)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/PropertyTypeTest.java
Thu Mar 10 05:42:49 2005
@@ -29,7 +29,7 @@
 /**
  * Tests if the type of a property is set according to the node type as well
  * as no property is of type UNDEFINED. This test runs recursively through
- * the entire repository.
+ * the workspace starting at {@link #testRoot}.
  *
  * @test
  * @sources PropertyTypeTest.java
@@ -49,12 +49,16 @@
     /**
      * Tests if the type of a property is set according to the node type as well
      * as no property is of type UNDEFINED. This test runs recursively through
-     * the entire repository.
+     * the workspace starting at {@link #testRoot}.
      */
     public void testType() throws RepositoryException {
         Session session = helper.getReadOnlySession();
-        Node root = session.getRootNode();
-        typeCheckChildren(root);
+        try {
+            Node root = session.getRootNode().getNode(testPath);
+            typeCheckChildren(root);
+        } finally {
+            session.logout();
+        }
     }
 
     private void typeCheckChildren(Node parentNode)

Modified: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/UndefinedPropertyTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/UndefinedPropertyTest.java?view=diff&r1=156949&r2=156950
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/UndefinedPropertyTest.java
(original)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/UndefinedPropertyTest.java
Thu Mar 10 05:42:49 2005
@@ -48,7 +48,11 @@
      */
     public void testUndefinedProperty() throws RepositoryException {
         Session session = helper.getReadOnlySession();
-        Property prop = PropertyUtil.searchProp(session, session.getRootNode(), PropertyType.UNDEFINED);
-        assertNull("Property with type Undefined found.", prop);
+        try {
+            Property prop = PropertyUtil.searchProp(session, session.getRootNode().getNode(testPath),
PropertyType.UNDEFINED);
+            assertNull("Property with type Undefined found.", prop);
+        } finally {
+            session.logout();
+        }
     }
 }



Mime
View raw message