jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From resc...@apache.org
Subject svn commit: r570564 - in /jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api: ./ query/
Date Tue, 28 Aug 2007 20:34:56 GMT
Author: reschke
Date: Tue Aug 28 13:34:55 2007
New Revision: 570564

URL: http://svn.apache.org/viewvc?rev=570564&view=rev
Log:
JCR-1095: extend PropertyUtil.searchProp so that the caller can specify whether the property
needs to be single-valued, multi-valued (or anything). Add AbstractPropertyTest.getPropertyIsMultivalued
to specify that, and add implementations throughout. Specify "false" for ReferencePropertyTest
which relies on a single-valued property.

Modified:
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/AbstractPropertyTest.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/BinaryPropertyTest.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/BooleanPropertyTest.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/DatePropertyTest.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/DoublePropertyTest.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/LongPropertyTest.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/NamePropertyTest.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/PathPropertyTest.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/PropertyUtil.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/ReferencePropertyTest.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/StringPropertyTest.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/UndefinedPropertyTest.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/DerefQueryLevel1Test.java

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/AbstractPropertyTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/AbstractPropertyTest.java?rev=570564&r1=570563&r2=570564&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/AbstractPropertyTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/AbstractPropertyTest.java
Tue Aug 28 13:34:55 2007
@@ -46,6 +46,12 @@
      * values defined in {@link javax.jcr.PropertyType}.
      */
     protected abstract int getPropertyType();
+    
+    /**
+     * Concrete subclasses return the multivalued-ness of property they test.
+     * (<code>null</code>: does not matter)
+     */
+    protected abstract Boolean getPropertyIsMultivalued();
 
     /**
      * Sets up the fixture for the tests.
@@ -55,7 +61,7 @@
         super.setUp();
         session = helper.getReadOnlySession();
 
-        prop = PropertyUtil.searchProp(session, session.getRootNode().getNode(testPath),
getPropertyType());
+        prop = PropertyUtil.searchProp(session, session.getRootNode().getNode(testPath),
getPropertyType(), getPropertyIsMultivalued());
         if (prop == null) {
             cleanUp();
             String msg = "Workspace does not contain a node with a " +

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/BinaryPropertyTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/BinaryPropertyTest.java?rev=570564&r1=570563&r2=570564&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/BinaryPropertyTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/BinaryPropertyTest.java
Tue Aug 28 13:34:55 2007
@@ -46,6 +46,14 @@
     }
 
     /**
+     * Returns "does not matter" (<code>null</code>).
+     * @return <code>null</code>.
+     */
+    protected Boolean getPropertyIsMultivalued() {
+        return null;
+    }
+
+    /**
      * Tests that when Value.getStream() is called a second time the same Stream
      * object is returned. Also tests that when a new Value object is requested
      * also a new Stream object is returned by calling getStream() on the new

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/BooleanPropertyTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/BooleanPropertyTest.java?rev=570564&r1=570563&r2=570564&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/BooleanPropertyTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/BooleanPropertyTest.java
Tue Aug 28 13:34:55 2007
@@ -46,6 +46,14 @@
     }
 
     /**
+     * Returns "does not matter" (<code>null</code>).
+     * @return <code>null</code>.
+     */
+    protected Boolean getPropertyIsMultivalued() {
+        return null;
+    }
+
+    /**
      * Tests that Property.getBoolean() delivers the same as Value.getBoolean()
      * and that in case of a multivalue property Property.getBoolean() throws a
      * ValueFormatException.

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/DatePropertyTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/DatePropertyTest.java?rev=570564&r1=570563&r2=570564&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/DatePropertyTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/DatePropertyTest.java
Tue Aug 28 13:34:55 2007
@@ -46,6 +46,14 @@
     }
 
     /**
+     * Returns "does not matter" (<code>null</code>).
+     * @return <code>null</code>.
+     */
+    protected Boolean getPropertyIsMultivalued() {
+        return null;
+    }
+
+    /**
      * Tests that Property.getDate() delivers the same as Value.getDate() and
      * that in case of a multivalue property a ValueFormatException is thrown.
      */

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/DoublePropertyTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/DoublePropertyTest.java?rev=570564&r1=570563&r2=570564&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/DoublePropertyTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/DoublePropertyTest.java
Tue Aug 28 13:34:55 2007
@@ -47,6 +47,14 @@
     }
 
     /**
+     * Returns "does not matter" (<code>null</code>).
+     * @return <code>null</code>.
+     */
+    protected Boolean getPropertyIsMultivalued() {
+        return null;
+    }
+
+    /**
      * tests that Property.getDouble() delivers the same as Value.getDouble()
      * and if in case of a multivalue property a ValueFormatException is
      * thrown.

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/LongPropertyTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/LongPropertyTest.java?rev=570564&r1=570563&r2=570564&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/LongPropertyTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/LongPropertyTest.java
Tue Aug 28 13:34:55 2007
@@ -47,6 +47,14 @@
     }
 
     /**
+     * Returns "does not matter" (<code>null</code>).
+     * @return <code>null</code>.
+     */
+    protected Boolean getPropertyIsMultivalued() {
+        return null;
+    }
+
+    /**
      * Tests that Property.getLong() delivers the same as Value.getLong() and if
      * in case of a multivalue property a ValueFormatException is thrown.
      */

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/NamePropertyTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/NamePropertyTest.java?rev=570564&r1=570563&r2=570564&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/NamePropertyTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/NamePropertyTest.java
Tue Aug 28 13:34:55 2007
@@ -43,6 +43,14 @@
     }
 
     /**
+     * Returns "does not matter" (<code>null</code>).
+     * @return <code>null</code>.
+     */
+    protected Boolean getPropertyIsMultivalued() {
+        return null;
+    }
+
+    /**
      * Tests conversion from Name type to String type.
      *
      * @throws RepositoryException

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/PathPropertyTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/PathPropertyTest.java?rev=570564&r1=570563&r2=570564&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/PathPropertyTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/PathPropertyTest.java
Tue Aug 28 13:34:55 2007
@@ -43,6 +43,14 @@
     }
 
     /**
+     * Returns "does not matter" (<code>null</code>).
+     * @return <code>null</code>.
+     */
+    protected Boolean getPropertyIsMultivalued() {
+        return null;
+    }
+
+    /**
      * Tests conversion from Path type to String type and if the resulting
      * string has correct format.
      */

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/PropertyUtil.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/PropertyUtil.java?rev=570564&r1=570563&r2=570564&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/PropertyUtil.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/PropertyUtil.java
Tue Aug 28 13:34:55 2007
@@ -146,9 +146,10 @@
      *
      * @param node the node to start traverse
      * @param type the property type to search for
+     * @param multiple whether the property should be multivalued (<code>null</code>:
does not matter)
      * @return the property found or null if no property is found
      */
-    public static Property searchProp(Session session, Node node, int type)
+    public static Property searchProp(Session session, Node node, int type, Boolean multiple)
             throws RepositoryException, ValueFormatException {
 
         Property prop = null;
@@ -157,7 +158,7 @@
             for (PropertyIterator props = node.getProperties(); props.hasNext();) {
                 Property property = props.nextProperty();
                 propType = property.getType();
-                if (propType == type) {
+                if (propType == type && (multiple == null || multiple.booleanValue()
== property.getDefinition().isMultiple())) {
                     prop = property;
                     break;
                 }
@@ -166,7 +167,7 @@
         if (prop == null) {
             for (NodeIterator nodes = node.getNodes(); nodes.hasNext();) {
                 Node n = nodes.nextNode();
-                prop = searchProp(session, n, type);
+                prop = searchProp(session, n, type, multiple);
                 if (prop != null) {
                     break;
                 }

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/ReferencePropertyTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/ReferencePropertyTest.java?rev=570564&r1=570563&r2=570564&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/ReferencePropertyTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/ReferencePropertyTest.java
Tue Aug 28 13:34:55 2007
@@ -24,8 +24,6 @@
 import javax.jcr.Value;
 import javax.jcr.ValueFormatException;
 
-import org.apache.jackrabbit.test.NotExecutableException;
-
 /**
  * Tests a reference property. If the workspace does not contain a node with
  * a reference property a {@link org.apache.jackrabbit.test.NotExecutableException}
@@ -46,16 +44,7 @@
      */
     protected void setUp() throws Exception {
         super.setUp();
-        if (prop.getDefinition().isMultiple()) {
-            Value v[] = prop.getValues();
-            if (v.length == 0) {
-                throw new NotExecutableException("Property " + prop.getName() + " is multivalued
with length 0");
-            }
-            referencedNode = prop.getSession().getNodeByUUID(prop.getValues()[0].getString());
-        }
-        else {
-            referencedNode = prop.getNode();
-        }
+        referencedNode = prop.getNode();
     }
 
     /**
@@ -64,6 +53,14 @@
      */
     protected int getPropertyType() {
         return PropertyType.REFERENCE;
+    }
+
+    /**
+     * Returns {@link Boolean#FALSE}.
+     * @return {@link Boolean#FALSE}.
+     */
+    protected Boolean getPropertyIsMultivalued() {
+        return Boolean.FALSE;
     }
 
     /**

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/StringPropertyTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/StringPropertyTest.java?rev=570564&r1=570563&r2=570564&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/StringPropertyTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/StringPropertyTest.java
Tue Aug 28 13:34:55 2007
@@ -77,6 +77,14 @@
     }
 
     /**
+     * Returns "does not matter" (<code>null</code>).
+     * @return <code>null</code>.
+     */
+    protected Boolean getPropertyIsMultivalued() {
+        return null;
+    }
+
+    /**
      * Tests that Property.getString() delivers a string equal to the string
      * received with Value.getString().
      */

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/UndefinedPropertyTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/UndefinedPropertyTest.java?rev=570564&r1=570563&r2=570564&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/UndefinedPropertyTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/UndefinedPropertyTest.java
Tue Aug 28 13:34:55 2007
@@ -44,12 +44,20 @@
     }
 
     /**
+     * Returns "does not matter" (<code>null</code>).
+     * @return <code>null</code>.
+     */
+    protected Boolean getPropertyIsMultivalued() {
+        return null;
+    }
+
+    /**
      * Tests that no actual property with type Undefined exists.
      */
     public void testUndefinedProperty() throws RepositoryException {
         Session session = helper.getReadOnlySession();
         try {
-            Property prop = PropertyUtil.searchProp(session, session.getRootNode().getNode(testPath),
PropertyType.UNDEFINED);
+            Property prop = PropertyUtil.searchProp(session, session.getRootNode().getNode(testPath),
PropertyType.UNDEFINED, null);
             assertNull("Property with type Undefined found.", prop);
         } finally {
             session.logout();

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/DerefQueryLevel1Test.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/DerefQueryLevel1Test.java?rev=570564&r1=570563&r2=570564&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/DerefQueryLevel1Test.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/DerefQueryLevel1Test.java
Tue Aug 28 13:34:55 2007
@@ -68,7 +68,7 @@
      */
     public void testDerefSinglePropWithNodeTest()
             throws RepositoryException, NotExecutableException {
-        Property refProp = PropertyUtil.searchProp(session, testRootNode, PropertyType.REFERENCE);
+        Property refProp = PropertyUtil.searchProp(session, testRootNode, PropertyType.REFERENCE,
Boolean.FALSE);
         if (refProp == null) {
             throw new NotExecutableException("Workspace does not contain a node with a reference
property.");
         }
@@ -85,7 +85,7 @@
      */
     public void testDerefSinglePropWithNodeStar()
             throws RepositoryException, NotExecutableException {
-        Property refProp = PropertyUtil.searchProp(session, testRootNode, PropertyType.REFERENCE);
+        Property refProp = PropertyUtil.searchProp(session, testRootNode, PropertyType.REFERENCE,
Boolean.FALSE);
         if (refProp == null) {
             throw new NotExecutableException("Workspace does not contain a node with a reference
property.");
         }



Mime
View raw message