[dna-commits] DNA SVN: r940 - in trunk/dna-jcr/src: main/resources/org/jboss/dna/jcr and 1 other directories.

dna-commits at lists.jboss.org dna-commits at lists.jboss.org
Wed May 27 22:13:55 EDT 2009


Author: bcarothers
Date: 2009-05-27 22:13:55 -0400 (Wed, 27 May 2009)
New Revision: 940

Modified:
   trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrI18n.java
   trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrMultiValueProperty.java
   trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrSingleValueProperty.java
   trunk/dna-jcr/src/main/resources/org/jboss/dna/jcr/JcrI18n.properties
   trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrTckTest.java
Log:
DNA-438 JR TCK Test SetValueValueFormatExceptionTest Fails

Applied patch that forces type conversion to the current property type on the property setValue methods. The patch also checks that the parameter to setValue(Node) is, in fact, referenceable.

Modified: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrI18n.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrI18n.java	2009-05-27 23:10:00 UTC (rev 939)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrI18n.java	2009-05-28 02:13:55 UTC (rev 940)
@@ -135,6 +135,8 @@
 
     public static I18n allNodeTypeTemplatesMustComeFromSameSession;
 
+    public static I18n nodeNotReferenceable;
+
     static {
         try {
             I18n.initialize(JcrI18n.class);

Modified: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrMultiValueProperty.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrMultiValueProperty.java	2009-05-27 23:10:00 UTC (rev 939)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrMultiValueProperty.java	2009-05-28 02:13:55 UTC (rev 940)
@@ -189,6 +189,11 @@
             return;
         }
 
+        for (int i = 0; i < values.length; i++) {
+            // Force a conversion as per SetValueValueFormatExceptionTest in JR TCK
+            if (values[i] != null) ((JcrValue) values[i]).asType(this.getType());
+        }
+        
         cache.getEditorFor(propertyId.getNodeId()).setProperty(propertyId.getPropertyName(), values, PropertyType.UNDEFINED);
     }
 
@@ -212,7 +217,7 @@
             for (int i = 0; i != numValues; ++i) {
                 String value = values[i];
                 if (value == null) continue; // skip null values
-                valuesList.add(createValue(values[i], PropertyType.STRING));
+                valuesList.add(createValue(values[i], PropertyType.STRING).asType(this.getType()));
             }
             if (valuesList.isEmpty()) {
                 jcrValues = EMPTY_VALUES;
@@ -223,7 +228,7 @@
             jcrValues = EMPTY_VALUES;
         }
 
-        cache.getEditorFor(propertyId.getNodeId()).setProperty(propertyId.getPropertyName(), jcrValues, PropertyType.STRING);
+        cache.getEditorFor(propertyId.getNodeId()).setProperty(propertyId.getPropertyName(), jcrValues, this.getType());
     }
 
     /**

Modified: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrSingleValueProperty.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrSingleValueProperty.java	2009-05-27 23:10:00 UTC (rev 939)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrSingleValueProperty.java	2009-05-28 02:13:55 UTC (rev 940)
@@ -191,6 +191,10 @@
         JcrValue jcrValue = null;
         if (value instanceof JcrValue) {
             jcrValue = (JcrValue)value;
+
+            // Force a conversion as per SetValueValueFormatExceptionTest in JR TCK
+            jcrValue.asType(this.getType());
+            
             cache.getEditorFor(propertyId.getNodeId()).setProperty(propertyId.getPropertyName(), jcrValue);
             return;
         }
@@ -199,6 +203,7 @@
             cache.getEditorFor(propertyId.getNodeId()).removeProperty(propertyId.getPropertyName());
             return;
         }
+        
         // We have to convert from one Value implementation to ours ...
         switch (value.getType()) {
             case PropertyType.STRING:
@@ -250,7 +255,7 @@
             this.remove();
             return;
         }
-        setValue(createValue(value, PropertyType.STRING));
+        setValue(createValue(value, PropertyType.STRING).asType(this.getType()));
     }
 
     /**
@@ -264,7 +269,7 @@
             this.remove();
             return;
         }
-        setValue(createValue(context().getValueFactories().getBinaryFactory().create(value), PropertyType.DATE));
+        setValue(createValue(context().getValueFactories().getBinaryFactory().create(value), PropertyType.BINARY).asType(this.getType()));
     }
 
     /**
@@ -274,7 +279,7 @@
      */
     public void setValue( long value )
         throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException {
-        setValue(createValue(new Long(value), PropertyType.LONG));
+        setValue(createValue(new Long(value), PropertyType.LONG).asType(this.getType()));
     }
 
     /**
@@ -284,7 +289,7 @@
      */
     public void setValue( double value )
         throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException {
-        setValue(createValue(new Double(value), PropertyType.DOUBLE));
+        setValue(createValue(new Double(value), PropertyType.DOUBLE).asType(this.getType()));
     }
 
     /**
@@ -298,7 +303,7 @@
             this.remove();
             return;
         }
-        setValue(createValue(context().getValueFactories().getDateFactory().create(value), PropertyType.DATE));
+        setValue(createValue(context().getValueFactories().getDateFactory().create(value), PropertyType.DATE).asType(this.getType()));
     }
 
     /**
@@ -308,7 +313,7 @@
      */
     public void setValue( boolean value )
         throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException {
-        setValue(createValue(new Boolean(value), PropertyType.BOOLEAN));
+        setValue(createValue(new Boolean(value), PropertyType.BOOLEAN).asType(this.getType()));
     }
 
     /**
@@ -322,8 +327,13 @@
             this.remove();
             return;
         }
+        
+        if (!value.isNodeType(JcrMixLexicon.REFERENCEABLE.getString(this.context().getNamespaceRegistry()))) {
+            throw new ValueFormatException(JcrI18n.nodeNotReferenceable.text());
+        }
+        
         String uuid = value.getUUID();
-        setValue(createValue(uuid, PropertyType.REFERENCE));
+        setValue(createValue(uuid, PropertyType.REFERENCE).asType(this.getType()));
     }
 
     /**

Modified: trunk/dna-jcr/src/main/resources/org/jboss/dna/jcr/JcrI18n.properties
===================================================================
--- trunk/dna-jcr/src/main/resources/org/jboss/dna/jcr/JcrI18n.properties	2009-05-27 23:10:00 UTC (rev 939)
+++ trunk/dna-jcr/src/main/resources/org/jboss/dna/jcr/JcrI18n.properties	2009-05-28 02:13:55 UTC (rev 940)
@@ -119,3 +119,5 @@
 missingMandatoryItem=The mandatory {0} named '{1}' defined in type '{2}' is missing from the node at '{3}'
 
 allNodeTypeTemplatesMustComeFromSameSession=All node type templates must be created from the same javax.jcr.Session
+
+nodeNotReferenceable=Only referenceable nodes may be the value of reference properties.
\ No newline at end of file

Modified: trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrTckTest.java
===================================================================
--- trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrTckTest.java	2009-05-27 23:10:00 UTC (rev 939)
+++ trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrTckTest.java	2009-05-28 02:13:55 UTC (rev 940)
@@ -60,6 +60,7 @@
 import org.apache.jackrabbit.test.api.SetValueLongTest;
 import org.apache.jackrabbit.test.api.SetValueReferenceTest;
 import org.apache.jackrabbit.test.api.SetValueStringTest;
+import org.apache.jackrabbit.test.api.SetValueValueFormatExceptionTest;
 import org.apache.jackrabbit.test.api.SetValueVersionExceptionTest;
 import org.apache.jackrabbit.test.api.ValueFactoryTest;
 import org.apache.jackrabbit.test.api.WorkspaceCloneReferenceableTest;
@@ -187,7 +188,7 @@
             addTestSuite(SetValueReferenceTest.class);
             addTestSuite(SetValueStringTest.class);
             addTestSuite(SetValueConstraintViolationExceptionTest.class);
-            // addTestSuite(SetValueValueFormatExceptionTest.class);
+            addTestSuite(SetValueValueFormatExceptionTest.class);
             addTestSuite(SetValueVersionExceptionTest.class);
 
             addTestSuite(SetPropertyBooleanTest.class);




More information about the dna-commits mailing list