jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r156984 [1/3] - in incubator/jackrabbit/trunk: applications/test/repository/nodetypes/ applications/test/workspaces/default/ applications/test/workspaces/test/ src/test/org/apache/jackrabbit/test/api/ src/test/org/apache/jackrabbit/test/api/nodetype/
Date Thu, 10 Mar 2005 19:38:03 GMT
Author: mreutegg
Date: Thu Mar 10 11:37:51 2005
New Revision: 156984

URL: http://svn.apache.org/viewcvs?view=rev&rev=156984
Log:
Added test cases for Property.setValue() and NodeType.canSetProperty()

Added:
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SetValueBinaryTest.java   (with props)
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SetValueBooleanTest.java   (with props)
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SetValueDateTest.java   (with props)
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SetValueDoubleTest.java   (with props)
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SetValueLongTest.java   (with props)
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SetValueReferenceTest.java   (with props)
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SetValueStringTest.java   (with props)
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/nodetype/CanSetPropertyBinaryTest.java   (with props)
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/nodetype/CanSetPropertyBooleanTest.java   (with props)
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/nodetype/CanSetPropertyDateTest.java   (with props)
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/nodetype/CanSetPropertyDoubleTest.java   (with props)
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/nodetype/CanSetPropertyLongTest.java   (with props)
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/nodetype/CanSetPropertyMultipleTest.java   (with props)
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/nodetype/CanSetPropertyNameTest.java   (with props)
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/nodetype/CanSetPropertyPathTest.java   (with props)
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/nodetype/CanSetPropertyStringTest.java   (with props)
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/nodetype/CanSetPropertyTest.java   (with props)
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/nodetype/NodeTypeUtil.java   (with props)
Modified:
    incubator/jackrabbit/trunk/applications/test/repository/nodetypes/custom_nodetypes.xml
    incubator/jackrabbit/trunk/applications/test/workspaces/default/   (props changed)
    incubator/jackrabbit/trunk/applications/test/workspaces/test/   (props changed)
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/TestAll.java
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/nodetype/TestAll.java

Modified: incubator/jackrabbit/trunk/applications/test/repository/nodetypes/custom_nodetypes.xml
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/applications/test/repository/nodetypes/custom_nodetypes.xml?view=diff&r1=156983&r2=156984
==============================================================================
--- incubator/jackrabbit/trunk/applications/test/repository/nodetypes/custom_nodetypes.xml (original)
+++ incubator/jackrabbit/trunk/applications/test/repository/nodetypes/custom_nodetypes.xml Thu Mar 10 11:37:51 2005
@@ -75,5 +75,114 @@
     </supertypes>
     <propertyDef name="*" requiredType="undefined" autoCreate="false" mandatory="false" onParentVersion="COPY" protected="false" multiple="false"/>
   </nodeType>
+
+  <!-- Defines a nodetype for testing NodeType.canSetProperty() -->
+  <nodeType name="test:canSetProperty" mixin="false" orderableChildNodes="false" primaryItemName="">
+    <supertypes>
+      <supertype>nt:base</supertype>
+    </supertypes>
+    <propertyDef name="String" requiredType="String" autoCreate="false" mandatory="false" onParentVersion="COPY" protected="false" multiple="false"/>
+    <propertyDef name="StringMultiple" requiredType="String" autoCreate="false" mandatory="false" onParentVersion="COPY" protected="false" multiple="true"/>
+    <propertyDef name="StringConstraints" requiredType="String" autoCreate="false" mandatory="false" onParentVersion="COPY" protected="false" multiple="false">
+      <valueConstraints>
+        <valueConstraint>abc</valueConstraint>
+        <valueConstraint>def</valueConstraint>
+        <valueConstraint>ghi</valueConstraint>
+      </valueConstraints>
+    </propertyDef>
+    <propertyDef name="StringMultipleConstraints" requiredType="String" autoCreate="false" mandatory="false" onParentVersion="COPY" protected="false" multiple="true">
+      <valueConstraints>
+        <valueConstraint>abc</valueConstraint>
+        <valueConstraint>def</valueConstraint>
+        <valueConstraint>ghi</valueConstraint>
+      </valueConstraints>
+    </propertyDef>
+    <propertyDef name="Binary" requiredType="Binary" autoCreate="false" mandatory="false" onParentVersion="COPY" protected="false" multiple="false"/>
+    <propertyDef name="BinaryMultiple" requiredType="Binary" autoCreate="false" mandatory="false" onParentVersion="COPY" protected="false" multiple="true"/>
+    <propertyDef name="BinaryConstraints" requiredType="Binary" autoCreate="false" mandatory="false" onParentVersion="COPY" protected="false" multiple="false">
+      <valueConstraints>
+        <valueConstraint>(,100)</valueConstraint>
+      </valueConstraints>
+    </propertyDef>
+    <propertyDef name="BinaryMultipleConstraints" requiredType="Binary" autoCreate="false" mandatory="false" onParentVersion="COPY" protected="false" multiple="true">
+      <valueConstraints>
+        <valueConstraint>(,100)</valueConstraint>
+      </valueConstraints>
+    </propertyDef>
+    <propertyDef name="Date" requiredType="Date" autoCreate="false" mandatory="false" onParentVersion="COPY" protected="false" multiple="false"/>
+    <propertyDef name="DateMultiple" requiredType="Date" autoCreate="false" mandatory="false" onParentVersion="COPY" protected="false" multiple="true"/>
+    <propertyDef name="DateConstraints" requiredType="Date" autoCreate="false" mandatory="false" onParentVersion="COPY" protected="false" multiple="false">
+      <valueConstraints>
+        <valueConstraint>(1974-02-15T00:00:00.000Z,)</valueConstraint>
+      </valueConstraints>
+    </propertyDef>
+    <propertyDef name="DateMultipleConstraints" requiredType="Date" autoCreate="false" mandatory="false" onParentVersion="COPY" protected="false" multiple="true">
+      <valueConstraints>
+        <valueConstraint>(,1974-02-15T00:00:00.000Z)</valueConstraint>
+      </valueConstraints>
+    </propertyDef>
+    <propertyDef name="Double" requiredType="Double" autoCreate="false" mandatory="false" onParentVersion="COPY" protected="false" multiple="false"/>
+    <propertyDef name="DoubleMultiple" requiredType="Double" autoCreate="false" mandatory="false" onParentVersion="COPY" protected="false" multiple="true"/>
+    <propertyDef name="DoubleConstraints" requiredType="Double" autoCreate="false" mandatory="false" onParentVersion="COPY" protected="false" multiple="false">
+      <valueConstraints>
+        <valueConstraint>(100,)</valueConstraint>
+      </valueConstraints>
+    </propertyDef>
+    <propertyDef name="DoubleMultipleConstraints" requiredType="Double" autoCreate="false" mandatory="false" onParentVersion="COPY" protected="false" multiple="true">
+      <valueConstraints>
+        <valueConstraint>(,100)</valueConstraint>
+      </valueConstraints>
+    </propertyDef>
+    <propertyDef name="Long" requiredType="Long" autoCreate="false" mandatory="false" onParentVersion="COPY" protected="false" multiple="false"/>
+    <propertyDef name="LongMultiple" requiredType="Long" autoCreate="false" mandatory="false" onParentVersion="COPY" protected="false" multiple="true"/>
+    <propertyDef name="LongConstraints" requiredType="Long" autoCreate="false" mandatory="false" onParentVersion="COPY" protected="false" multiple="false">
+      <valueConstraints>
+        <valueConstraint>(100,)</valueConstraint>
+      </valueConstraints>
+    </propertyDef>
+    <propertyDef name="LongMultipleConstraints" requiredType="Long" autoCreate="false" mandatory="false" onParentVersion="COPY" protected="false" multiple="true">
+      <valueConstraints>
+        <valueConstraint>(,100)</valueConstraint>
+      </valueConstraints>
+    </propertyDef>
+    <propertyDef name="Boolean" requiredType="Boolean" autoCreate="false" mandatory="false" onParentVersion="COPY" protected="false" multiple="false"/>
+    <propertyDef name="BooleanMultiple" requiredType="Boolean" autoCreate="false" mandatory="false" onParentVersion="COPY" protected="false" multiple="true"/>
+    <propertyDef name="BooleanConstraints" requiredType="Boolean" autoCreate="false" mandatory="false" onParentVersion="COPY" protected="false" multiple="false">
+      <valueConstraints>
+        <valueConstraint>true</valueConstraint>
+      </valueConstraints>
+    </propertyDef>
+    <propertyDef name="BooleanMultipleConstraints" requiredType="Boolean" autoCreate="false" mandatory="false" onParentVersion="COPY" protected="false" multiple="true">
+      <valueConstraints>
+        <valueConstraint>true</valueConstraint>
+      </valueConstraints>
+    </propertyDef>
+    <propertyDef name="Name" requiredType="Name" autoCreate="false" mandatory="false" onParentVersion="COPY" protected="false" multiple="false"/>
+    <propertyDef name="NameMultiple" requiredType="Name" autoCreate="false" mandatory="false" onParentVersion="COPY" protected="false" multiple="true"/>
+    <propertyDef name="NameConstraints" requiredType="Name" autoCreate="false" mandatory="false" onParentVersion="COPY" protected="false" multiple="false">
+      <valueConstraints>
+        <valueConstraint>abc</valueConstraint>
+      </valueConstraints>
+    </propertyDef>
+    <propertyDef name="NameMultipleConstraints" requiredType="Name" autoCreate="false" mandatory="false" onParentVersion="COPY" protected="false" multiple="true">
+      <valueConstraints>
+        <valueConstraint>abc</valueConstraint>
+      </valueConstraints>
+    </propertyDef>
+    <propertyDef name="Path" requiredType="Path" autoCreate="false" mandatory="false" onParentVersion="COPY" protected="false" multiple="false"/>
+    <propertyDef name="PathMultiple" requiredType="Path" autoCreate="false" mandatory="false" onParentVersion="COPY" protected="false" multiple="true"/>
+    <propertyDef name="PathConstraints" requiredType="Path" autoCreate="false" mandatory="false" onParentVersion="COPY" protected="false" multiple="false">
+      <valueConstraints>
+        <valueConstraint>/abc</valueConstraint>
+      </valueConstraints>
+    </propertyDef>
+    <propertyDef name="PathMultipleConstraints" requiredType="Path" autoCreate="false" mandatory="false" onParentVersion="COPY" protected="false" multiple="true">
+      <valueConstraints>
+        <valueConstraint>/abc</valueConstraint>
+      </valueConstraints>
+    </propertyDef>
+  </nodeType>
+
+
 </nodeTypes>
 

Propchange: incubator/jackrabbit/trunk/applications/test/workspaces/default/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Thu Mar 10 11:37:51 2005
@@ -1,3 +1,4 @@
 blobs
 data
 index
+locks

Propchange: incubator/jackrabbit/trunk/applications/test/workspaces/test/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Thu Mar 10 11:37:51 2005
@@ -1,3 +1,4 @@
 blobs
 data
 index
+locks

Added: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SetValueBinaryTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SetValueBinaryTest.java?view=auto&rev=156984
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SetValueBinaryTest.java (added)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SetValueBinaryTest.java Thu Mar 10 11:37:51 2005
@@ -0,0 +1,144 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.test.api;
+
+import org.apache.jackrabbit.test.AbstractJCRTest;
+
+import javax.jcr.Property;
+import javax.jcr.Value;
+import javax.jcr.RepositoryException;
+import javax.jcr.BinaryValue;
+import javax.jcr.Node;
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.io.IOException;
+
+/**
+ * Tests the various {@link Property#setValue(Value)} methods.
+ * <p/>
+ * Configuration requirements:<br/> The node at {@link #testRoot} must allow a
+ * child node of type {@link #testNodeType} with name {@link #nodeName1}. The
+ * node type {@link #testNodeType} must define a single value binary property
+ * with name {@link #propertyName1}.
+ *
+ * @test
+ * @sources SetValueBinaryTest.java
+ * @executeClass org.apache.jackrabbit.test.api.SetValueBinaryTest
+ * @keywords level2
+ */
+public class SetValueBinaryTest extends AbstractJCRTest {
+
+    /**
+     * The binary value
+     */
+    private BinaryValue value;
+
+    /**
+     * The binary data
+     */
+    private byte[] data;
+
+    /**
+     * The node with the binary property
+     */
+    private Node node;
+
+    /**
+     * The binary property
+     */
+    private Property property1;
+
+    protected void setUp() throws Exception {
+        super.setUp();
+
+        // initialize some binary value
+        data = createRandomString(10).getBytes();
+        value = new BinaryValue(new ByteArrayInputStream(data));
+
+        // create a new node under the testRootNode
+        node = testRootNode.addNode(nodeName1, testNodeType);
+
+        // create a new single-value property and save it
+        property1 = node.setProperty(propertyName1, new BinaryValue(new ByteArrayInputStream(new byte[0])));
+        superuser.save();
+    }
+
+    /**
+     * Test the persistence of a property modified with an BinaryValue parameter
+     * and saved from the Session
+     */
+    public void testBinarySession() throws RepositoryException, IOException {
+        property1.setValue(value);
+        superuser.save();
+        compareStream(data, property1.getValue().getStream());
+    }
+
+    /**
+     * Test the persistence of a property modified with an input stream
+     * parameter and saved from the parent Node
+     */
+    public void testBooleanParent() throws RepositoryException, IOException {
+        property1.setValue(value.getStream());
+        node.save();
+        compareStream(data, property1.getValue().getStream());
+    }
+
+    /**
+     * Test the deletion of a property by assigning it a null value, saved from
+     * the Session
+     */
+    public void testRemoveBooleanSession() throws RepositoryException {
+        property1.setValue((InputStream) null);
+        superuser.save();
+
+        try {
+            node.getProperty(propertyName1);
+            fail("The property should not exist anymore, as a null Value has been assigned");
+        } catch (Exception e) {
+            //success : the property has been deleted by assigning it a null value
+        }
+    }
+
+    /**
+     * Test the deletion of a property by assigning it a null value, saved from
+     * the parent Node
+     */
+    public void testRemoveBooleanParent() throws RepositoryException {
+        property1.setValue((BinaryValue) null);
+        node.save();
+
+        try {
+            node.getProperty(propertyName1);
+            fail("The property should not exist anymore, as a null Value has been assigned");
+        } catch (Exception e) {
+            //success : the property has been deleted by assigning it a null value
+        }
+    }
+
+    //--------------------------< internal >------------------------------------
+
+    private void compareStream(byte[] data, InputStream s) throws IOException {
+        byte[] read = new byte[1];
+        for (int i = 0; i < data.length; i++) {
+            assertEquals("Stream data does not match value set.", 1, s.read(read));
+            assertEquals("Stream data does not match value set.", data[i], read[0]);
+        }
+        if (s.available() > 0) {
+            fail("InputStream has more data than value set.");
+        }
+    }
+}

Propchange: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SetValueBinaryTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SetValueBooleanTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SetValueBooleanTest.java?view=auto&rev=156984
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SetValueBooleanTest.java (added)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SetValueBooleanTest.java Thu Mar 10 11:37:51 2005
@@ -0,0 +1,123 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.test.api;
+
+import org.apache.jackrabbit.test.AbstractJCRTest;
+
+import javax.jcr.Property;
+import javax.jcr.Value;
+import javax.jcr.RepositoryException;
+import javax.jcr.BooleanValue;
+import javax.jcr.Node;
+import javax.jcr.PathNotFoundException;
+
+/**
+ * Tests the various {@link Property#setValue(Value)} methods.
+ * <p/>
+ * Configuration requirements:<br/> The node at {@link #testRoot} must allow a
+ * child node of type {@link #testNodeType} with name {@link #nodeName1}. The
+ * node type {@link #testNodeType} must define a single value boolean property
+ * with name {@link #propertyName1}.
+ *
+ * @test
+ * @sources SetValueBooleanTest.java
+ * @executeClass org.apache.jackrabbit.test.api.SetValueBooleanTest
+ * @keywords level2
+ */
+public class SetValueBooleanTest extends AbstractJCRTest {
+
+    /**
+     * The boolean value
+     */
+    private BooleanValue value;
+
+    /**
+     * The node with the boolean property
+     */
+    private Node node;
+
+    /**
+     * The boolean property
+     */
+    private Property property1;
+
+    protected void setUp() throws Exception {
+        super.setUp();
+
+        // initialize some boolean value
+        value = new BooleanValue(true);
+
+        // create a new node under the testRootNode
+        node = testRootNode.addNode(nodeName1, testNodeType);
+
+        // create a new single-value property and save it
+        property1 = node.setProperty(propertyName1, false);
+        superuser.save();
+    }
+
+    /**
+     * Test the persistence of a property modified with an BooleanValue
+     * parameter and saved from the Session
+     */
+    public void testBooleanSession() throws RepositoryException {
+        property1.setValue(value);
+        superuser.save();
+        assertEquals("Boolean property not saved", value.getBoolean(), property1.getValue().getBoolean());
+    }
+
+    /**
+     * Test the persistence of a property modified with an boolean parameter and
+     * saved from the parent Node
+     */
+    public void testBooleanParent() throws RepositoryException {
+        property1.setValue(value.getBoolean());
+        node.save();
+        assertEquals("Boolean property not saved", value.getBoolean(), property1.getValue().getBoolean());
+    }
+
+    /**
+     * Test the deletion of a property by assigning it a null value, saved from
+     * the Session
+     */
+    public void testRemoveBooleanSession() throws RepositoryException {
+        property1.setValue((BooleanValue) null);
+        superuser.save();
+
+        try {
+            node.getProperty(propertyName1);
+            fail("The property should not exist anymore, as a null Value has been assigned");
+        } catch (PathNotFoundException e) {
+            //success : the property has been deleted by assigning it a null value
+        }
+    }
+
+    /**
+     * Test the deletion of a property by assigning it a null value, saved from
+     * the parent Node
+     */
+    public void testRemoveBooleanParent() throws RepositoryException {
+        property1.setValue((BooleanValue) null);
+        node.save();
+
+        try {
+            node.getProperty(propertyName1);
+            fail("The property should not exist anymore, as a null Value has been assigned");
+        } catch (PathNotFoundException e) {
+            //success : the property has been deleted by assigning it a null value
+        }
+    }
+}

Propchange: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SetValueBooleanTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SetValueDateTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SetValueDateTest.java?view=auto&rev=156984
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SetValueDateTest.java (added)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SetValueDateTest.java Thu Mar 10 11:37:51 2005
@@ -0,0 +1,127 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.test.api;
+
+import org.apache.jackrabbit.test.AbstractJCRTest;
+
+import javax.jcr.Property;
+import javax.jcr.Value;
+import javax.jcr.RepositoryException;
+import javax.jcr.DateValue;
+import javax.jcr.Node;
+import javax.jcr.PathNotFoundException;
+import java.util.GregorianCalendar;
+import java.util.Calendar;
+
+/**
+ * Tests the various {@link Property#setValue(Value)} methods.
+ * <p/>
+ * Configuration requirements:<br/> The node at {@link #testRoot} must allow a
+ * child node of type {@link #testNodeType} with name {@link #nodeName1}. The
+ * node type {@link #testNodeType} must define a single value date property
+ * with name {@link #propertyName1}.
+ *
+ * @test
+ * @sources SetValueDateTest.java
+ * @executeClass org.apache.jackrabbit.test.api.SetValueDateTest
+ * @keywords level2
+ */
+public class SetValueDateTest extends AbstractJCRTest {
+
+    /**
+     * The date value
+     */
+    private DateValue value;
+
+    /**
+     * The node with the date property
+     */
+    private Node node;
+
+    /**
+     * The date property
+     */
+    private Property property1;
+
+    protected void setUp() throws Exception {
+        super.setUp();
+
+        // initialize some date value
+        value = new DateValue(GregorianCalendar.getInstance());
+
+        // create a new node under the testRootNode
+        node = testRootNode.addNode(nodeName1, testNodeType);
+
+        // create a new single-value property and save it
+        Calendar initialValue = GregorianCalendar.getInstance();
+        initialValue.setTimeInMillis(0);
+        property1 = node.setProperty(propertyName1, initialValue);
+        superuser.save();
+    }
+
+    /**
+     * Test the persistence of a property modified with an DateValues parameter
+     * and saved from the Session
+     */
+    public void testDateSession() throws RepositoryException {
+        property1.setValue(value);
+        superuser.save();
+        assertEquals("Date node property not saved", value.getDate(), property1.getValue().getDate());
+    }
+
+    /**
+     * Test the persistence of a property modified with an date parameter and
+     * saved from the parent Node
+     */
+    public void testDateParent() throws RepositoryException {
+        property1.setValue(value.getDate());
+        node.save();
+        assertEquals("Date node property not saved", value.getDate(), property1.getValue().getDate());
+    }
+
+    /**
+     * Test the deletion of a property by assigning it a null value, saved from
+     * the parent Node
+     */
+    public void testRemoveDateParent() throws RepositoryException {
+        property1.setValue((DateValue) null);
+        node.save();
+
+        try {
+            node.getProperty(propertyName1);
+            fail("The property should not exist anymore, as a null Value has been assigned");
+        } catch (PathNotFoundException e) {
+            //success : the property has been deleted by assigning it a null value
+        }
+    }
+
+    /**
+     * Test the deletion of a property by assigning it a null value, saved from
+     * the Session
+     */
+    public void testRemoveCalendarSession() throws RepositoryException {
+        property1.setValue((Calendar) null);
+        superuser.save();
+
+        try {
+            node.getProperty(propertyName1);
+            fail("The property should not exist anymore, as a null Calendar has been assigned");
+        } catch (PathNotFoundException e) {
+            //success : the property has been deleted by assigning it a null value
+        }
+    }
+}

Propchange: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SetValueDateTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SetValueDoubleTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SetValueDoubleTest.java?view=auto&rev=156984
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SetValueDoubleTest.java (added)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SetValueDoubleTest.java Thu Mar 10 11:37:51 2005
@@ -0,0 +1,123 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.test.api;
+
+import org.apache.jackrabbit.test.AbstractJCRTest;
+
+import javax.jcr.Property;
+import javax.jcr.Value;
+import javax.jcr.RepositoryException;
+import javax.jcr.DoubleValue;
+import javax.jcr.Node;
+import javax.jcr.PathNotFoundException;
+
+/**
+ * Tests the various {@link Property#setValue(Value)} methods.
+ * <p/>
+ * Configuration requirements:<br/> The node at {@link #testRoot} must allow a
+ * child node of type {@link #testNodeType} with name {@link #nodeName1}. The
+ * node type {@link #testNodeType} must define a single value double property
+ * with name {@link #propertyName1}.
+ *
+ * @test
+ * @sources SetValueDoubleTest.java
+ * @executeClass org.apache.jackrabbit.test.api.SetValueDoubleTest
+ * @keywords level2
+ */
+public class SetValueDoubleTest extends AbstractJCRTest {
+
+    /**
+     * The double value
+     */
+    private DoubleValue value;
+
+    /**
+     * The node with the double property
+     */
+    private Node node;
+
+    /**
+     * The double property
+     */
+    private Property property1;
+
+    protected void setUp() throws Exception {
+        super.setUp();
+
+        // initialize some double value
+        value = new DoubleValue(93845.94d);
+
+        // create a new node under the testRootNode
+        node = testRootNode.addNode(nodeName1, testNodeType);
+
+        // create a new single-value property and save it
+        property1 = node.setProperty(propertyName1, 0.0d);
+        superuser.save();
+    }
+
+    /**
+     * Test the persistence of a property modified with an double parameter and
+     * saved from the Session
+     */
+    public void testDoubleSession() throws RepositoryException {
+        property1.setValue(value);
+        superuser.save();
+        assertEquals("Double node property not saved", value.getDouble(), property1.getValue().getDouble(), 0);
+    }
+
+    /**
+     * Test the persistence of a property modified with an double parameter and
+     * saved from the parent Node
+     */
+    public void testDoubleParent() throws RepositoryException {
+        property1.setValue(value.getDouble());
+        node.save();
+        assertEquals("Double node property not saved", value.getDouble(), property1.getValue().getDouble(), 0);
+    }
+
+    /**
+     * Test the deletion of a property by assigning it a null value, saved from
+     * the Session
+     */
+    public void testRemoveDoubleSession() throws RepositoryException {
+        property1.setValue((DoubleValue) null);
+        superuser.save();
+
+        try {
+            node.getProperty(propertyName1);
+            fail("The property should not exist anymore, as a null Double has been assigned");
+        } catch (PathNotFoundException e) {
+            //success : the property has been deleted by assigning it a null value
+        }
+    }
+
+    /**
+     * Test the deletion of a property by assigning it a null value, saved from
+     * the parent Node
+     */
+    public void testRemoveDoubleParent() throws RepositoryException {
+        property1.setValue((DoubleValue) null);
+        node.save();
+
+        try {
+            node.getProperty(propertyName1);
+            fail("The property should not exist anymore, as a null Double has been assigned");
+        } catch (PathNotFoundException e) {
+            //success : the property has been deleted by assigning it a null value
+        }
+    }
+}

Propchange: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SetValueDoubleTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SetValueLongTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SetValueLongTest.java?view=auto&rev=156984
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SetValueLongTest.java (added)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SetValueLongTest.java Thu Mar 10 11:37:51 2005
@@ -0,0 +1,123 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.test.api;
+
+import org.apache.jackrabbit.test.AbstractJCRTest;
+
+import javax.jcr.Property;
+import javax.jcr.Value;
+import javax.jcr.RepositoryException;
+import javax.jcr.LongValue;
+import javax.jcr.Node;
+import javax.jcr.PathNotFoundException;
+
+/**
+ * Tests the various {@link Property#setValue(Value)} methods.
+ * <p/>
+ * Configuration requirements:<br/> The node at {@link #testRoot} must allow a
+ * child node of type {@link #testNodeType} with name {@link #nodeName1}. The
+ * node type {@link #testNodeType} must define a single value long property
+ * with name {@link #propertyName1}.
+ *
+ * @test
+ * @sources SetValueLongTest.java
+ * @executeClass org.apache.jackrabbit.test.api.SetValueLongTest
+ * @keywords level2
+ */
+public class SetValueLongTest extends AbstractJCRTest {
+
+    /**
+     * The long value
+     */
+    private LongValue value;
+
+    /**
+     * The node with the long property
+     */
+    private Node node;
+
+    /**
+     * The long property
+     */
+    private Property property1;
+
+    protected void setUp() throws Exception {
+        super.setUp();
+
+        // initialize some long value
+        value = new LongValue(73057230);
+
+        // create a new node under the testRootNode
+        node = testRootNode.addNode(nodeName1, testNodeType);
+
+        // create a new single-value property and save it
+        property1 = node.setProperty(propertyName1, 0L);
+        superuser.save();
+    }
+
+    /**
+     * Test the persistence of a property modified with an LongValue parameter
+     * and saved from the Session
+     */
+    public void testLongSession() throws RepositoryException {
+        property1.setValue(value);
+        superuser.save();
+        assertEquals("Long property not saved", value.getLong(), property1.getValue().getLong());
+    }
+
+    /**
+     * Test the persistence of a property modified with an long parameter and
+     * saved from the parent Node
+     */
+    public void testLongParent() throws RepositoryException {
+        property1.setValue(value.getLong());
+        node.save();
+        assertEquals("Long property not saved", value.getLong(), property1.getValue().getLong());
+    }
+
+    /**
+     * Test the deletion of a property by assigning it a null value, saved from
+     * the parent Node
+     */
+    public void testRemoveLongParent() throws RepositoryException {
+        property1.setValue((LongValue) null);
+        node.save();
+
+        try {
+            node.getProperty(propertyName1);
+            fail("The property should not exist anymore, as a null Value has been assigned");
+        } catch (PathNotFoundException e) {
+            //success : the property has been deleted by assigning it a null value
+        }
+    }
+
+    /**
+     * Test the deletion of a property by assigning it a null value, saved from
+     * the Session
+     */
+    public void testRemoveLongSession() throws RepositoryException {
+        property1.setValue((LongValue) null);
+        superuser.save();
+
+        try {
+            node.getProperty(propertyName1);
+            fail("The property should not exist anymore, as a null Value has been assigned");
+        } catch (PathNotFoundException e) {
+            //success : the property has been deleted by assigning it a null value
+        }
+    }
+}

Propchange: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SetValueLongTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SetValueReferenceTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SetValueReferenceTest.java?view=auto&rev=156984
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SetValueReferenceTest.java (added)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SetValueReferenceTest.java Thu Mar 10 11:37:51 2005
@@ -0,0 +1,156 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.test.api;
+
+import org.apache.jackrabbit.test.AbstractJCRTest;
+import org.apache.jackrabbit.test.NotExecutableException;
+
+import javax.jcr.Property;
+import javax.jcr.Value;
+import javax.jcr.RepositoryException;
+import javax.jcr.Node;
+import javax.jcr.ReferenceValue;
+import javax.jcr.PathNotFoundException;
+
+/**
+ * Tests the various {@link Property#setValue(Value)} methods.
+ * <p/>
+ * Configuration requirements:<br/> The node at {@link #testRoot} must allow a
+ * child node of type {@link #testNodeType} with name {@link #nodeName1}. The
+ * node type {@link #testNodeType} must define a single value reference property
+ * with name {@link #propertyName1}. The node type {@link #testNodeType} must
+ * be referenceable or allow to add a mix:referenceable, otherwise a
+ * {@link NotExecutableException} is thrown.
+ *
+ * @test
+ * @sources SetValueReferenceTest.java
+ * @executeClass org.apache.jackrabbit.test.api.SetValueReferenceTest
+ * @keywords level2
+ */
+public class SetValueReferenceTest extends AbstractJCRTest {
+
+    /**
+     * The reference value
+     */
+    private ReferenceValue value;
+
+    /**
+     * The node with the reference property
+     */
+    private Node node;
+
+    /**
+     * The reference property
+     */
+    private Property property1;
+
+    /**
+     * @throws NotExecutableException if the node is not referenceable and does
+     *                                not allow to add a mix:referenceable.
+     */
+    protected void setUp() throws Exception {
+        super.setUp();
+
+        // create a new node under the testRootNode
+        node = testRootNode.addNode(nodeName1, testNodeType);
+        ensureReferenceable(node);
+
+        // initialize some reference value
+        value = new ReferenceValue(node);
+
+        // create a new single-value property and save it
+        property1 = node.setProperty(propertyName1, value);
+        superuser.save();
+    }
+
+    /**
+     * Test the persistence of a property modified with an Node parameter and
+     * saved from the Session Requires a Node value (node)
+     */
+    public void testNodeSession() throws RepositoryException, NotExecutableException {
+        property1.setValue(node);
+        superuser.save();
+        assertTrue("Reference property not saved", node.isSame(property1.getNode()));
+    }
+
+    /**
+     * Test the persistence of a property modified with an Node parameter and
+     * saved from the parent Node Requires a Node value (node)
+     */
+    public void testNodeParent() throws RepositoryException {
+        property1.setValue(node);
+        node.save();
+        assertTrue("Reference property not saved", node.isSame(property1.getNode()));
+    }
+
+    /**
+     * Test the deletion of a property by assigning it a null value, saved from
+     * the Session
+     */
+    public void testRemoveNodeSession() throws RepositoryException {
+        property1.setValue((ReferenceValue) null);
+        superuser.save();
+
+        try {
+            node.getProperty(propertyName1);
+            fail("The property should not exist anymore, as a null Value has been assigned");
+        } catch (PathNotFoundException e) {
+            //success : the property has been deleted by assigning it a null value
+        }
+    }
+
+    /**
+     * Test the deletion of a property by assigning it a null value, saved from
+     * the parent Node
+     */
+    public void testRemoveNodeParent() throws RepositoryException {
+        property1.setValue((Node) null);
+        node.save();
+
+        try {
+            node.getProperty(propertyName1);
+            fail("The property should not exist anymore, as a null Value has been assigned");
+        } catch (PathNotFoundException e) {
+            //success : the property has been deleted by assigning it a null value
+        }
+    }
+
+    //-------------------< internal >-------------------------------------------
+
+    /**
+     * Ensures that node <code>n</code> is referenceable. If the node is not of
+     * type mix:referenceable this method tries to add the mixin
+     * mix:referenceable. If the node does not allow to add the mixin, or the
+     * repository does not support referenceable nodes a {@link
+     * NotExecutableException} is thrown.
+     *
+     * @param n the node to check.
+     * @throws NotExecutableException if the node cannot be made referenceable
+     *                                or if the repository does not support
+     *                                referenceable nodes.
+     */
+    private void ensureReferenceable(Node n) throws RepositoryException, NotExecutableException {
+        if (n.isNodeType(mixReferenceable)) {
+            return;
+        }
+        if (n.canAddMixin(mixReferenceable)) {
+            n.addMixin(mixReferenceable);
+        } else {
+            throw new NotExecutableException("Node is not referenceable: " + n.getPath());
+        }
+    }
+}

Propchange: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SetValueReferenceTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SetValueStringTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SetValueStringTest.java?view=auto&rev=156984
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SetValueStringTest.java (added)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SetValueStringTest.java Thu Mar 10 11:37:51 2005
@@ -0,0 +1,381 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.test.api;
+
+import org.apache.jackrabbit.test.AbstractJCRTest;
+
+import javax.jcr.Property;
+import javax.jcr.Value;
+import javax.jcr.Node;
+import javax.jcr.StringValue;
+import javax.jcr.RepositoryException;
+import javax.jcr.ValueFormatException;
+import javax.jcr.PathNotFoundException;
+import java.util.Arrays;
+import java.util.List;
+import java.util.ArrayList;
+
+/**
+ * Tests the various {@link Property#setValue(Value)} methods.
+ * <p/>
+ * Configuration requirements:<br/>
+ * The node at {@link #testRoot} must allow a child node of type
+ * {@link #testNodeType} with name {@link #nodeName1}. The node type
+ * {@link #testNodeType} must define a single value string property with
+ * name {@link #propertyName1} and a multi value string property with name
+ * {@link #propertyName2}.
+ *
+ * @test
+ * @sources SetValueStringTest.java
+ * @executeClass org.apache.jackrabbit.test.api.SetValueStringTest
+ * @keywords level2
+ */
+public class SetValueStringTest extends AbstractJCRTest {
+
+    private static final String PROP_VALUE_1 = "JCR";
+    private static final String PROP_VALUE_2 = "JSR-170";
+
+    private Property property1 = null;
+    private Property property2 = null;
+    private Node node = null;
+    private Value sv1, sv2 = null;
+    private Value[] mv1, mv2 = null;
+
+    protected void setUp() throws Exception {
+        super.setUp();
+
+        // initialize some multi-value properties
+        sv1 = new StringValue(PROP_VALUE_1);
+        sv2 = new StringValue(PROP_VALUE_2);
+        mv1 = new Value[]{sv1};
+        mv2 = new Value[]{sv1, sv2};
+
+        // create a new node under the testRootNode
+        node = testRootNode.addNode(nodeName1, testNodeType);
+        superuser.save();
+
+        // create a new single-value property and save it
+        property1 = node.setProperty(propertyName1, PROP_VALUE_1);
+        superuser.save();
+
+        // create a new multi-value property and save it
+        property2 = node.setProperty(propertyName2, mv1);
+        superuser.save();
+    }
+
+    // Value tests
+
+    /**
+     * Test the persistence of a property modified with a Value parameter and
+     * saved from the Session Requires a single-value Value (sv2)
+     */
+    public void testValueSession() throws RepositoryException {
+        property1.setValue(sv2);
+        superuser.save();
+        assertEquals("Value node property not saved", sv2, property1.getValue());
+    }
+
+    /**
+     * Test the persistence of a property modified with a Value parameter, and
+     * saved from the parent Node Requires a single-value Value (sv2)
+     */
+    public void testValueParent() throws RepositoryException {
+        property1.setValue(sv2);
+        testRootNode.save();
+        assertEquals("Value node property not saved", sv2, property1.getValue());
+    }
+
+    /**
+     * Test the modification of a single-value property updated with a
+     * multi-value parameter Requires a multi-value Value (mv)
+     */
+    public void testMultiValue() throws RepositoryException {
+        Value[] mv = new Value[]{sv1, sv2}; // multi-value
+        try {
+            property1.setValue(mv);
+            fail("Assigning multiple Value values to a single-valued property should throw a ValueFormatException");
+        } catch (ValueFormatException e) {
+            //success : ValueFormatException as required by the specification
+        }
+    }
+
+    /**
+     * Test the deletion of a property by assigning it a null value, saved from
+     * the Session
+     */
+    public void testRemoveValueSession() throws RepositoryException {
+        Value sv = null;
+        property1.setValue(sv);
+        superuser.save();
+
+        try {
+            node.getProperty(propertyName1);
+            fail("The property should not exist anymore, as a null Value has been assigned");
+        } catch (PathNotFoundException e) {
+            //success : the property has been deleted by assigning it a null value
+        }
+    }
+
+    /**
+     * Test the deletion of a property by assigning it a null value, saved from
+     * the parent Node
+     */
+    public void testRemoveValueParent() throws RepositoryException {
+        Value sv = null;
+        property1.setValue(sv);
+        node.save();
+
+        try {
+            node.getProperty(propertyName1);
+            fail("The property should not exist anymore, as a null Value has been assigned");
+        } catch (PathNotFoundException e) {
+            //success : the property has been deleted by assigning it a null value
+        }
+    }
+
+    // String tests
+
+    /**
+     * Test the persistence of a property modified with a String parameter and
+     * saved from the Session Requires a single-value String (PROP_VALUE_2)
+     */
+    public void testStringSession() throws RepositoryException {
+        property1.setValue(PROP_VALUE_2);
+        superuser.save();
+        assertEquals("String node property not saved", PROP_VALUE_2, property1.getString());
+    }
+
+    /**
+     * Test the persistence of a property modified with a String parameter and
+     * saved from the parent Node Requires a single-value String (PROP_VALUE_2)
+     */
+    public void testStringParent() throws RepositoryException {
+        property1.setValue(PROP_VALUE_2);
+        node.save();
+        assertEquals("String node property not saved", PROP_VALUE_2, property1.getString());
+    }
+
+    /**
+     * Test the modification of a single-value property updated with a
+     * multi-value parameter Requires a multi-value String (mv)
+     */
+    public void testMultiString() throws RepositoryException {
+        String[] mv = new String[]{PROP_VALUE_1, PROP_VALUE_2}; // multi-value
+        try {
+            property1.setValue(mv);
+            fail("Assigning multiple String values to a single-valued property should throw a ValueFormatException");
+        } catch (ValueFormatException e) {
+            //success : ValueFormatException as required by the specification
+        }
+    }
+
+    /**
+     * Test the deletion of a property by assigning it a null value, saved from
+     * the Session
+     */
+    public void testRemoveStringSession() throws RepositoryException {
+        String sv = null;
+        property1.setValue(sv);
+        superuser.save();
+
+        try {
+            node.getProperty(propertyName1);
+            fail("The property should not exist anymore, as a null String has been assigned");
+        } catch (PathNotFoundException e) {
+            //success : the property has been deleted by assigning it a null value
+        }
+    }
+
+    /**
+     * Test the deletion of a property by assigning it a null value, saved from
+     * the parent Node
+     */
+    public void testRemoveStringParent() throws RepositoryException {
+        String sv = null;
+        property1.setValue(sv);
+        node.save();
+
+        try {
+            node.getProperty(propertyName1);
+            fail("The property should not exist anymore, as a null String has been assigned");
+        } catch (PathNotFoundException e) {
+            //success : the property has been deleted by assigning it a null value
+        }
+    }
+
+
+    // Multi-value Value tests
+
+    /**
+     * Test the persistence of a property modified with an multi-value Value
+     * parameter and saved from the Session Requires a multi-value Value (mv2)
+     */
+    public void testMultiValueSession() throws RepositoryException {
+        property2.setValue(mv2);
+        superuser.save();
+        assertEquals("Node property not saved", Arrays.asList(mv2), Arrays.asList(property2.getValues()));
+    }
+
+    /**
+     * Test the persistence of a property modified with an multi-value Value
+     * parameter and saved from the parent Node Requires a multi-value Value
+     * (mv2)
+     */
+    public void testMultiValueParent() throws RepositoryException {
+        property2.setValue(mv2);
+        node.save();
+        assertEquals("Node property not saved", Arrays.asList(mv2), Arrays.asList(property2.getValues()));
+    }
+
+    /**
+     * Test the assignment of a single-value to a multi-value property Requires
+     * a single-value Value (sv1)
+     */
+    public void testMultiValueSingle() throws RepositoryException {
+        try {
+            property2.setValue(sv1);
+            fail("Assigning a single Value value to a multi-valued property should throw a ValueFormatException");
+        } catch (ValueFormatException e) {
+            //success : ValueFormatException as required by the specification
+        }
+    }
+
+    /**
+     * Test the deletion of a property by assigning it a null value, saved from
+     * the Session
+     */
+    public void testRemoveMultiValueSession() throws RepositoryException {
+        property2.setValue((Value[]) null);
+        superuser.save();
+
+        try {
+            node.getProperty(propertyName2);
+            fail("The property should not exist anymore, as a null Value has been assigned");
+        } catch (PathNotFoundException e) {
+            //success : the property has been deleted by assigning it a null value
+        }
+    }
+
+    /**
+     * Test the deletion of a property by assigning it a null value, saved from
+     * the parent Node
+     */
+    public void testRemoveMultiValueParent() throws RepositoryException {
+        property2.setValue((Value[]) null);
+        node.save();
+
+        try {
+            node.getProperty(propertyName2);
+            fail("The property should not exist anymore, as a null Value has been assigned");
+        } catch (PathNotFoundException e) {
+            //success : the property has been deleted by assigning it a null value
+        }
+    }
+
+
+    // Assignment of a null Value in a multi-value array
+
+    /**
+     * Test the deletion of a value in a multi-value property
+     */
+    public void testNullMultiValue() throws RepositoryException {
+        property2.setValue(new Value[]{null, sv2});
+        superuser.save();
+        assertEquals("Null value not removed", Arrays.asList(property2.getValues()), Arrays.asList(new Value[]{sv2}));
+    }
+
+
+    // Multi-value String tests
+
+    /**
+     * Test the persistence of a property modified with an multi-value String
+     * parameter and saved from the Session Requires a multi-value String (mv)
+     */
+    public void testMultiStringSession() throws RepositoryException {
+        String[] mv = new String[]{PROP_VALUE_1, PROP_VALUE_2};
+        property2.setValue(mv);
+        superuser.save();
+        Value[] values = property2.getValues();
+        List strValues = new ArrayList();
+        for (int i = 0; i < values.length; i++) {
+            strValues.add(values[i].getString());
+        }
+        assertEquals("Node property not saved", Arrays.asList(mv), strValues);
+    }
+
+    /**
+     * Test the persistence of a property modified with an multi-value String
+     * parameter and saved from the parent Node Requires a multi-value String
+     * (mv)
+     */
+    public void testMultiStringParent() throws RepositoryException {
+        String[] mv = new String[]{PROP_VALUE_1, PROP_VALUE_2};
+        property2.setValue(mv);
+        node.save();
+        Value[] values = property2.getValues();
+        List strValues = new ArrayList();
+        for (int i = 0; i < values.length; i++) {
+            strValues.add(values[i].getString());
+        }
+        assertEquals("Node property not saved", Arrays.asList(mv), strValues);
+    }
+
+    /**
+     * Test the assignment of a single-value to a multi-value property Requires
+     * a single-value String (PROP_VALUE_1)
+     */
+    public void testMultiStringSingle() throws RepositoryException {
+        try {
+            property2.setValue(PROP_VALUE_1);
+            fail("Assigning a single String value to a multi-valued property should throw a ValueFormatException");
+        } catch (ValueFormatException e) {
+            //success : ValueFormatException as required by the specification
+        }
+    }
+
+    /**
+     * Test the deletion of a property by assigning it a null value, saved from
+     * the Session
+     */
+    public void testRemoveMultiStringSession() throws RepositoryException {
+        property2.setValue((String[]) null);
+        superuser.save();
+
+        try {
+            node.getProperty(propertyName2);
+            fail("The property should not exist anymore, as a null Value has been assigned");
+        } catch (PathNotFoundException e) {
+            //success : the property has been deleted by assigning it a null value
+        }
+    }
+
+    /**
+     * Test the deletion of a property by assigning it a null value, saved from
+     * the parent Node
+     */
+    public void testRemoveMultiStringParent() throws RepositoryException {
+        property2.setValue((String[]) null);
+        node.save();
+
+        try {
+            node.getProperty(propertyName2);
+            fail("The property should not exist anymore, as a null Value has been assigned");
+        } catch (PathNotFoundException e) {
+            //success : the property has been deleted by assigning it a null value
+        }
+    }
+}
\ No newline at end of file

Propchange: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SetValueStringTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/TestAll.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/TestAll.java?view=diff&r1=156983&r2=156984
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/TestAll.java (original)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/TestAll.java Thu Mar 10 11:37:51 2005
@@ -73,6 +73,14 @@
         suite.addTestSuite(NodeUUIDTest.class);
         suite.addTestSuite(NodeOrderableChildNodesTest.class);
 
+        suite.addTestSuite(SetValueBinaryTest.class);
+        suite.addTestSuite(SetValueBooleanTest.class);
+        suite.addTestSuite(SetValueDateTest.class);
+        suite.addTestSuite(SetValueDoubleTest.class);
+        suite.addTestSuite(SetValueLongTest.class);
+        suite.addTestSuite(SetValueReferenceTest.class);
+        suite.addTestSuite(SetValueStringTest.class);
+
         return suite;
     }
 }

Added: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/nodetype/CanSetPropertyBinaryTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/nodetype/CanSetPropertyBinaryTest.java?view=auto&rev=156984
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/nodetype/CanSetPropertyBinaryTest.java (added)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/nodetype/CanSetPropertyBinaryTest.java Thu Mar 10 11:37:51 2005
@@ -0,0 +1,256 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.test.api.nodetype;
+
+import org.apache.jackrabbit.test.AbstractJCRTest;
+import org.apache.jackrabbit.test.NotExecutableException;
+
+import javax.jcr.nodetype.PropertyDef;
+import javax.jcr.nodetype.NodeType;
+import javax.jcr.Session;
+import javax.jcr.PropertyType;
+import javax.jcr.RepositoryException;
+import javax.jcr.Value;
+import java.text.ParseException;
+
+/**
+ * Test of <code>NodeType.canSetProperty(String propertyName, Value
+ * value)</code> and <code>NodeType.canSetProperty(String propertyName, Value[]
+ * values)</code> where property is of type Binary.
+ *
+ * @test
+ * @sources CanSetPropertyBinaryTest.java
+ * @executeClass org.apache.jackrabbit.test.api.nodetype.CanSetPropertyBinaryTest
+ * @keywords level1
+ */
+public class CanSetPropertyBinaryTest extends AbstractJCRTest {
+    /**
+     * The session we use for the tests
+     */
+    private Session session;
+
+    /**
+     * Sets up the fixture for the test cases.
+     */
+    protected void setUp() throws Exception {
+        isReadOnly = true;
+        super.setUp();
+
+        session = helper.getReadOnlySession();
+    }
+
+    /**
+     * Releases the session aquired in {@link #setUp()}.
+     */
+    protected void tearDown() throws Exception {
+        if (session != null) {
+            session.logout();
+        }
+        super.tearDown();
+    }
+
+
+    /**
+     * Tests if NodeType.canSetProperty(String propertyName, Value value)
+     * returns true if value and its type are convertible to BinaryValue.
+     */
+    public void testConversions()
+            throws NotExecutableException, RepositoryException {
+
+        PropertyDef propDef =
+                NodeTypeUtil.locatePropertyDef(session, PropertyType.BINARY, false, false, false, false);
+
+        if (propDef == null) {
+            throw new NotExecutableException("No string property def that meets the " +
+                    "requirements of the test has been found");
+        }
+
+        NodeType nodeType = propDef.getDeclaringNodeType();
+
+
+        Value stringValue = NodeTypeUtil.getValueOfType(PropertyType.STRING);
+        assertTrue("canSetProperty(String propertyName, Value value) must return " +
+                "true if the property is of type Binary and value is a StringValue",
+                nodeType.canSetProperty(propDef.getName(), stringValue));
+
+        Value binaryValue = NodeTypeUtil.getValueOfType(PropertyType.BINARY);
+        assertTrue("canSetProperty(String propertyName, Value value) must return " +
+                "true if the property is of type Binary and value is a BinaryValue",
+                nodeType.canSetProperty(propDef.getName(), binaryValue));
+
+        Value dateValue = NodeTypeUtil.getValueOfType(PropertyType.DATE);
+        assertTrue("canSetProperty(String propertyName, Value value) must return " +
+                "true if the property is of type Binary and value is a DateValue",
+                nodeType.canSetProperty(propDef.getName(), dateValue));
+
+        Value doubleValue = NodeTypeUtil.getValueOfType(PropertyType.DOUBLE);
+        assertTrue("canSetProperty(String propertyName, Value value) must return " +
+                "true if the property is of type Binary and value is a DoubleValue",
+                nodeType.canSetProperty(propDef.getName(), doubleValue));
+
+        Value longValue = NodeTypeUtil.getValueOfType(PropertyType.LONG);
+        assertTrue("canSetProperty(String propertyName, Value value) must return " +
+                "true if the property is of type Binary and value is a LongValue",
+                nodeType.canSetProperty(propDef.getName(), longValue));
+
+        Value booleanValue = NodeTypeUtil.getValueOfType(PropertyType.BOOLEAN);
+        assertTrue("canSetProperty(String propertyName, Value value) must return " +
+                "true if the property is of type Binary and value is a BooleanValue",
+                nodeType.canSetProperty(propDef.getName(), booleanValue));
+
+        Value nameValue = NodeTypeUtil.getValueOfType(PropertyType.NAME);
+        assertTrue("canSetProperty(String propertyName, Value value) must return " +
+                "true if the property is of type Binary and value is a NameValue",
+                nodeType.canSetProperty(propDef.getName(), nameValue));
+
+        Value pathValue = NodeTypeUtil.getValueOfType(PropertyType.PATH);
+        assertTrue("canSetProperty(String propertyName, Value value) must return " +
+                "true if the property is of type Binary and value is a PathValue",
+                nodeType.canSetProperty(propDef.getName(), pathValue));
+    }
+
+    /**
+     * Tests if NodeType.canSetProperty(String propertyName, Value[] values)
+     * returns true if all values and its types are convertible to BinaryValue.
+     */
+    public void testConversionsMultiple()
+            throws NotExecutableException, RepositoryException {
+
+        PropertyDef propDef =
+                NodeTypeUtil.locatePropertyDef(session, PropertyType.BINARY, true, false, false, false);
+
+        if (propDef == null) {
+            throw new NotExecutableException("No multiple string property def that meets the " +
+                    "requirements of the test has been found");
+        }
+
+        NodeType nodeType = propDef.getDeclaringNodeType();
+
+
+        Value binaryValue = NodeTypeUtil.getValueOfType(PropertyType.BINARY);
+
+        Value stringValue = NodeTypeUtil.getValueOfType(PropertyType.STRING);
+        Value stringValues[] = {stringValue};
+        assertTrue("canSetProperty(String propertyName, Value[] values) must return " +
+                "true if the property is of type Binary and values are of type StringValue",
+                nodeType.canSetProperty(propDef.getName(), stringValues));
+
+        Value binaryValues[] = {binaryValue};
+        assertTrue("canSetProperty(String propertyName, Value[] values) must return " +
+                "true if the property is of type Binary and values are of type BinaryValue",
+                nodeType.canSetProperty(propDef.getName(), binaryValues));
+
+        Value dateValue = NodeTypeUtil.getValueOfType(PropertyType.DATE);
+        Value dateValues[] = {dateValue};
+        assertTrue("canSetProperty(String propertyName, Value[] values) must return " +
+                "true if the property is of type Binary and values are of type DateValue",
+                nodeType.canSetProperty(propDef.getName(), dateValues));
+
+        Value doubleValue = NodeTypeUtil.getValueOfType(PropertyType.DOUBLE);
+        Value doubleValues[] = {doubleValue};
+        assertTrue("canSetProperty(String propertyName, Value[] values) must return " +
+                "true if the property is of type Binary and values are of type DoubleValue",
+                nodeType.canSetProperty(propDef.getName(), doubleValues));
+
+        Value longValue = NodeTypeUtil.getValueOfType(PropertyType.LONG);
+        Value longValues[] = {longValue};
+        assertTrue("canSetProperty(String propertyName, Value[] values) must return " +
+                "true if the property is of type Binary and values are of type LongValue",
+                nodeType.canSetProperty(propDef.getName(), longValues));
+
+        Value booleanValue = NodeTypeUtil.getValueOfType(PropertyType.BOOLEAN);
+        Value booleanValues[] = {booleanValue};
+        assertTrue("canSetProperty(String propertyName, Value[] values) must return " +
+                "true if the property is of type Binary and values are of type BooleanValue",
+                nodeType.canSetProperty(propDef.getName(), booleanValues));
+
+        Value nameValue = NodeTypeUtil.getValueOfType(PropertyType.NAME);
+        Value nameValues[] = {nameValue};
+        assertTrue("canSetProperty(String propertyName, Value[] values) must return " +
+                "true if the property is of type Binary and values are of type NameValue",
+                nodeType.canSetProperty(propDef.getName(), nameValues));
+
+        Value pathValue = NodeTypeUtil.getValueOfType(PropertyType.PATH);
+        Value pathValues[] = {pathValue};
+        assertTrue("canSetProperty(String propertyName, Value[] values) must return " +
+                "true if the property is of type Binary and values are of type PathValue",
+                nodeType.canSetProperty(propDef.getName(), pathValues));
+    }
+
+    /**
+     * Tests if canSetProperty(String propertyName, Value value) returns false
+     * if value does not match the value constraints of the property def
+     */
+    public void testOutOfValueConstraint()
+            throws NotExecutableException, ParseException, RepositoryException {
+
+        PropertyDef propDef =
+                NodeTypeUtil.locatePropertyDef(session, PropertyType.BINARY, false, false, true, false);
+
+        if (propDef == null) {
+            throw new NotExecutableException("No binary property def with " +
+                    "testable value constraints has been found");
+        }
+
+        Value value = NodeTypeUtil.getValueOutOfContstraint(propDef);
+        if (value == null) {
+            // value should never be null since this is catched already in locatePropertyDef
+            throw new NotExecutableException("No binary property def with " +
+                    "testable value constraints has been found");
+        }
+
+        NodeType nodeType = propDef.getDeclaringNodeType();
+
+        // todo: canSetProperty does not return true if size in range
+        // ?: jackrabbit bug or does it not work like i did? (without stream)
+        // reported to sguggis 05-03-10
+        assertFalse("canSetProperty(String propertyName, Value value) must " +
+                "return false if value does not match the value constraints.",
+                nodeType.canSetProperty(propDef.getName(), value));
+    }
+
+    /**
+     * Tests if canSetProperty(String propertyName, Value[] values) returns
+     * false if values do not match the value constraints of the property def
+     */
+    public void testOutOfValueConstraintMultiple()
+            throws NotExecutableException, ParseException, RepositoryException {
+
+        PropertyDef propDef =
+                NodeTypeUtil.locatePropertyDef(session, PropertyType.BINARY, true, false, true, false);
+
+        if (propDef == null) {
+            throw new NotExecutableException("No multiple binary property def with " +
+                    "testable value constraints has been found");
+        }
+
+        Value value = NodeTypeUtil.getValueOutOfContstraint(propDef);
+        if (value == null) {
+            // value should never be null since this is catched already in locatePropertyDef
+            throw new NotExecutableException("No multiple binary property def with " +
+                    "testable value constraints has been found");
+        }
+
+        NodeType nodeType = propDef.getDeclaringNodeType();
+        Value values[] = {value};
+
+        assertFalse("canSetProperty(String propertyName, Value[] values) must " +
+                "return false if values do not match the value constraints.",
+                nodeType.canSetProperty(propDef.getName(), values));
+    }
+
+}
\ No newline at end of file

Propchange: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/nodetype/CanSetPropertyBinaryTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/nodetype/CanSetPropertyBooleanTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/nodetype/CanSetPropertyBooleanTest.java?view=auto&rev=156984
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/nodetype/CanSetPropertyBooleanTest.java (added)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/nodetype/CanSetPropertyBooleanTest.java Thu Mar 10 11:37:51 2005
@@ -0,0 +1,255 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.test.api.nodetype;
+
+import org.apache.jackrabbit.test.AbstractJCRTest;
+import org.apache.jackrabbit.test.NotExecutableException;
+
+import javax.jcr.nodetype.PropertyDef;
+import javax.jcr.nodetype.NodeType;
+import javax.jcr.Session;
+import javax.jcr.PropertyType;
+import javax.jcr.RepositoryException;
+import javax.jcr.Value;
+import java.text.ParseException;
+
+/**
+ * Test of <code>NodeType.canSetProperty(String propertyName, Value
+ * value)</code> and <code>NodeType.canSetProperty(String propertyName, Value[]
+ * values)</code> where property is of type Boolean.
+ *
+ * @test
+ * @sources CanSetPropertyBooleanTest.java
+ * @executeClass org.apache.jackrabbit.test.api.nodetype.CanSetPropertyBooleanTest
+ * @keywords level1
+ */
+public class CanSetPropertyBooleanTest extends AbstractJCRTest {
+    /**
+     * The session we use for the tests
+     */
+    private Session session;
+
+    /**
+     * Sets up the fixture for the test cases.
+     */
+    protected void setUp() throws Exception {
+        isReadOnly = true;
+        super.setUp();
+
+        session = helper.getReadOnlySession();
+    }
+
+    /**
+     * Releases the session aquired in {@link #setUp()}.
+     */
+    protected void tearDown() throws Exception {
+        if (session != null) {
+            session.logout();
+        }
+        super.tearDown();
+    }
+
+
+    /**
+     * Tests if NodeType.canSetProperty(String propertyName, Value value)
+     * returns true if value and its type are convertible to BooleanValue.
+     */
+    public void testConversions()
+            throws NotExecutableException, RepositoryException {
+
+        PropertyDef propDef =
+                NodeTypeUtil.locatePropertyDef(session, PropertyType.BOOLEAN, false, false, false, false);
+
+        if (propDef == null) {
+            throw new NotExecutableException("No boolean property def that meets the " +
+                    "requirements of the test has been found");
+        }
+
+        NodeType nodeType = propDef.getDeclaringNodeType();
+
+
+        Value stringValue = NodeTypeUtil.getValueOfType(PropertyType.STRING);
+        assertTrue("canSetProperty(String propertyName, Value value) must return " +
+                "true if the property is of type Boolean and value is a StringValue",
+                nodeType.canSetProperty(propDef.getName(), stringValue));
+
+        Value binaryValue = NodeTypeUtil.getValueOfType(PropertyType.BINARY);
+        assertTrue("canSetProperty(String propertyName, Value value) must return " +
+                "true if the property is of type Boolean and value is a BinaryValue" +
+                "in UTF-8",
+                nodeType.canSetProperty(propDef.getName(), binaryValue));
+
+        Value dateValue = NodeTypeUtil.getValueOfType(PropertyType.DATE);
+        assertFalse("canSetProperty(String propertyName, Value value) must return " +
+                "false if the property is of type Boolean and value is a DateValue",
+                nodeType.canSetProperty(propDef.getName(), dateValue));
+
+        Value doubleValue = NodeTypeUtil.getValueOfType(PropertyType.DOUBLE);
+        assertFalse("canSetProperty(String propertyName, Value value) must return " +
+                "false if the property is of type Boolean and value is a DoubleValue",
+                nodeType.canSetProperty(propDef.getName(), doubleValue));
+
+        Value longValue = NodeTypeUtil.getValueOfType(PropertyType.LONG);
+        assertFalse("canSetProperty(String propertyName, Value value) must return " +
+                "false if the property is of type Boolean and value is a LongValue",
+                nodeType.canSetProperty(propDef.getName(), longValue));
+
+        Value booleanValue = NodeTypeUtil.getValueOfType(PropertyType.BOOLEAN);
+        assertTrue("canSetProperty(String propertyName, Value value) must return " +
+                "true if the property is of type Boolean and value is a BooleanValue",
+                nodeType.canSetProperty(propDef.getName(), booleanValue));
+
+        Value nameValue = NodeTypeUtil.getValueOfType(PropertyType.NAME);
+        assertFalse("canSetProperty(String propertyName, Value value) must return " +
+                "false if the property is of type Boolean and value is a NameValue",
+                nodeType.canSetProperty(propDef.getName(), nameValue));
+
+        Value pathValue = NodeTypeUtil.getValueOfType(PropertyType.PATH);
+        assertFalse("canSetProperty(String propertyName, Value value) must return " +
+                "false if the property is of type Boolean and value is a PathValue",
+                nodeType.canSetProperty(propDef.getName(), pathValue));
+    }
+
+    /**
+     * Tests if NodeType.canSetProperty(String propertyName, Value[] values)
+     * returns true if all values and its types are convertible to
+     * BooleanValue.
+     */
+    public void testConversionsMultiple()
+            throws NotExecutableException, RepositoryException {
+
+        PropertyDef propDef =
+                NodeTypeUtil.locatePropertyDef(session, PropertyType.BOOLEAN, true, false, false, false);
+
+        if (propDef == null) {
+            throw new NotExecutableException("No multiple boolean property def that meets the " +
+                    "requirements of the test has been found");
+        }
+
+        NodeType nodeType = propDef.getDeclaringNodeType();
+
+
+        Value booleanValue = NodeTypeUtil.getValueOfType(PropertyType.BOOLEAN);
+
+        Value stringValue = NodeTypeUtil.getValueOfType(PropertyType.STRING);
+        Value stringValues[] = {stringValue};
+        assertTrue("canSetProperty(String propertyName, Value[] values) must return " +
+                "true if the property is of type Boolean and values are of type StringValue",
+                nodeType.canSetProperty(propDef.getName(), stringValues));
+
+        Value binaryValue = NodeTypeUtil.getValueOfType(PropertyType.BINARY);
+        Value binaryValues[] = {binaryValue};
+        assertTrue("canSetProperty(String propertyName, Value[] values) must return " +
+                "true if the property is of type Boolean and values are of type BinaryValue",
+                nodeType.canSetProperty(propDef.getName(), binaryValues));
+
+        Value dateValue = NodeTypeUtil.getValueOfType(PropertyType.DATE);
+        Value dateValues[] = {booleanValue, dateValue};
+        assertFalse("canSetProperty(String propertyName, Value[] values) must return " +
+                "false if the property is of type Boolean and values are of type DateValue",
+                nodeType.canSetProperty(propDef.getName(), dateValues));
+
+        Value doubleValue = NodeTypeUtil.getValueOfType(PropertyType.DOUBLE);
+        Value doubleValues[] = {booleanValue, doubleValue};
+        assertFalse("canSetProperty(String propertyName, Value[] values) must return " +
+                "false if the property is of type Boolean and values are of type DoubleValue",
+                nodeType.canSetProperty(propDef.getName(), doubleValues));
+
+        Value longValue = NodeTypeUtil.getValueOfType(PropertyType.LONG);
+        Value longValues[] = {booleanValue, longValue};
+        assertFalse("canSetProperty(String propertyName, Value[] values) must return " +
+                "false if the property is of type Boolean and values are of type LongValue",
+                nodeType.canSetProperty(propDef.getName(), longValues));
+
+        Value booleanValues[] = {booleanValue};
+        assertTrue("canSetProperty(String propertyName, Value[] values) must return " +
+                "true if the property is of type Boolean and values are of type BooleanValue",
+                nodeType.canSetProperty(propDef.getName(), booleanValues));
+
+        Value nameValue = NodeTypeUtil.getValueOfType(PropertyType.NAME);
+        Value nameValues[] = {booleanValue, nameValue};
+        assertFalse("canSetProperty(String propertyName, Value[] values) must return " +
+                "false if the property is of type Boolean and values are of type NameValue",
+                nodeType.canSetProperty(propDef.getName(), nameValues));
+
+        Value pathValue = NodeTypeUtil.getValueOfType(PropertyType.PATH);
+        Value pathValues[] = {booleanValue, pathValue};
+        assertFalse("canSetProperty(String propertyName, Value[] values) must return " +
+                "false if the property is of type Boolean and values are of type PathValue",
+                nodeType.canSetProperty(propDef.getName(), pathValues));
+    }
+
+    /**
+     * Tests if canSetProperty(String propertyName, Value value) returns false
+     * if value does not match the value constraints of the property def
+     */
+    public void testOutOfValueConstraint()
+            throws NotExecutableException, ParseException, RepositoryException {
+
+        PropertyDef propDef =
+                NodeTypeUtil.locatePropertyDef(session, PropertyType.BOOLEAN, false, false, true, false);
+
+        if (propDef == null) {
+            throw new NotExecutableException("No boolean property def with " +
+                    "testable value constraints has been found");
+        }
+
+        Value value = NodeTypeUtil.getValueOutOfContstraint(propDef);
+        System.out.println(value.getString());
+        if (value == null) {
+            // value should never be null since this is catched already in locatePropertyDef
+            throw new NotExecutableException("No boolean property def with " +
+                    "testable value constraints has been found");
+        }
+
+        NodeType nodeType = propDef.getDeclaringNodeType();
+
+        assertFalse("canSetProperty(String propertyName, Value value) must " +
+                "return false if value does not match the value constraints.",
+                nodeType.canSetProperty(propDef.getName(), value));
+    }
+
+    /**
+     * Tests if canSetProperty(String propertyName, Value[] values) returns
+     * false if values do not match the value constraints of the property def
+     */
+    public void testOutOfValueConstraintMultiple()
+            throws NotExecutableException, ParseException, RepositoryException {
+
+        PropertyDef propDef =
+                NodeTypeUtil.locatePropertyDef(session, PropertyType.BOOLEAN, true, false, true, false);
+
+        if (propDef == null) {
+            throw new NotExecutableException("No multiple boolean property def with " +
+                    "testable value constraints has been found");
+        }
+
+        Value value = NodeTypeUtil.getValueOutOfContstraint(propDef);
+        if (value == null) {
+            // value should never be null since this is catched already in locatePropertyDef
+            throw new NotExecutableException("No multiple boolean property def with " +
+                    "testable value constraints has been found");
+        }
+
+        NodeType nodeType = propDef.getDeclaringNodeType();
+        Value values[] = {value};
+
+        assertFalse("canSetProperty(String propertyName, Value[] values) must " +
+                "return false if values do not match the value constraints.",
+                nodeType.canSetProperty(propDef.getName(), values));
+    }
+}
\ No newline at end of file

Propchange: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/nodetype/CanSetPropertyBooleanTest.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message