jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r480958 - in /jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/api: PropertyReadMethodsTest.java PropertyUtil.java
Date Thu, 30 Nov 2006 15:15:13 GMT
Author: mreutegg
Date: Thu Nov 30 07:15:12 2006
New Revision: 480958

URL: http://svn.apache.org/viewvc?view=rev&rev=480958
Log:
JCR-655: PropertyReadMethodsTest should also work on NAME property

Modified:
    jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/api/PropertyReadMethodsTest.java
    jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/api/PropertyUtil.java

Modified: jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/api/PropertyReadMethodsTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/api/PropertyReadMethodsTest.java?view=diff&rev=480958&r1=480957&r2=480958
==============================================================================
--- jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/api/PropertyReadMethodsTest.java
(original)
+++ jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/api/PropertyReadMethodsTest.java
Thu Nov 30 07:15:12 2006
@@ -24,7 +24,6 @@
 import javax.jcr.Node;
 import javax.jcr.Property;
 import javax.jcr.PropertyIterator;
-import javax.jcr.PropertyType;
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
 import javax.jcr.Value;
@@ -188,8 +187,8 @@
      */
     public void testIsSame() throws RepositoryException {
         // access same property through different session
-        PropertyIterator properties = testRootNode.getProperties();
-        Property otherProperty = properties.nextProperty();
+        Session otherSession = helper.getReadOnlySession();
+        Property otherProperty = otherSession.getRootNode().getNode(testPath).getProperty(property.getName());
         assertTrue("isSame must return true for the same " +
                 "property retrieved through different sessions.",
                 property.isSame(otherProperty));
@@ -268,10 +267,9 @@
      * property.
      */
     public void testGetValues() throws RepositoryException, NotExecutableException {
-        Property singleProp = PropertyUtil.searchProp(session, testRootNode, PropertyType.STRING);
-
+        Property singleProp = PropertyUtil.searchSingleValuedProperty(testRootNode);
         if (singleProp == null) {
-            throw new NotExecutableException("No single valued String property found.");
+            throw new NotExecutableException("No single valued property found.");
         }
 
         try {
@@ -290,9 +288,9 @@
     public void testGetValueCopyStoredValues()
         throws NotExecutableException, RepositoryException {
 
-        Property prop = PropertyUtil.searchMultivalProp(testRootNode, PropertyType.STRING);
+        Property prop = PropertyUtil.searchMultivalProp(testRootNode);
         if (prop == null) {
-            throw new NotExecutableException("No testable property found.");
+            throw new NotExecutableException("No multivalued property found.");
         }
 
         // acquire the values of the property and change the zeroth value

Modified: jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/api/PropertyUtil.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/api/PropertyUtil.java?view=diff&rev=480958&r1=480957&r2=480958
==============================================================================
--- jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/api/PropertyUtil.java
(original)
+++ jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/test/api/PropertyUtil.java
Thu Nov 30 07:15:12 2006
@@ -426,6 +426,24 @@
         return multiVal;
     }
 
+    /**
+     * Retrieve a single valued property from the given node.
+     *
+     * @param node
+     * @return the property found or null if no property is found.
+     */
+    public static Property searchSingleValuedProperty(Node node)
+            throws RepositoryException, ValueFormatException {
+        PropertyIterator props = node.getProperties();
+        while (props.hasNext()) {
+            Property p = props.nextProperty();
+            if (!p.getDefinition().isMultiple()) {
+                return p;
+            }
+        }
+        // should never get here, since every Node must provide the jcr:primaryType
+        // property, which is single valued.
+        return null;
+    }
+}
 
-
-}
\ No newline at end of file



Mime
View raw message