Index: dna-jcr/src/main/java/org/jboss/dna/jcr/JcrI18n.java =================================================================== --- dna-jcr/src/main/java/org/jboss/dna/jcr/JcrI18n.java (revision 938) +++ dna-jcr/src/main/java/org/jboss/dna/jcr/JcrI18n.java (working copy) @@ -135,6 +135,8 @@ public static I18n allNodeTypeTemplatesMustComeFromSameSession; + public static I18n nodeNotReferenceable; + static { try { I18n.initialize(JcrI18n.class); Index: dna-jcr/src/main/java/org/jboss/dna/jcr/JcrMultiValueProperty.java =================================================================== --- dna-jcr/src/main/java/org/jboss/dna/jcr/JcrMultiValueProperty.java (revision 938) +++ dna-jcr/src/main/java/org/jboss/dna/jcr/JcrMultiValueProperty.java (working copy) @@ -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()); } /** Index: dna-jcr/src/main/java/org/jboss/dna/jcr/JcrSingleValueProperty.java =================================================================== --- dna-jcr/src/main/java/org/jboss/dna/jcr/JcrSingleValueProperty.java (revision 938) +++ dna-jcr/src/main/java/org/jboss/dna/jcr/JcrSingleValueProperty.java (working copy) @@ -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())); } /** Index: dna-jcr/src/main/resources/org/jboss/dna/jcr/JcrI18n.properties =================================================================== --- dna-jcr/src/main/resources/org/jboss/dna/jcr/JcrI18n.properties (revision 938) +++ dna-jcr/src/main/resources/org/jboss/dna/jcr/JcrI18n.properties (working copy) @@ -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 Index: dna-jcr/src/test/java/org/jboss/dna/jcr/JcrTckTest.java =================================================================== --- dna-jcr/src/test/java/org/jboss/dna/jcr/JcrTckTest.java (revision 938) +++ dna-jcr/src/test/java/org/jboss/dna/jcr/JcrTckTest.java (working copy) @@ -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);