jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r157539 - in incubator/jackrabbit/trunk: applications/test/ applications/test/repository/nodetypes/ src/test/org/apache/jackrabbit/test/api/
Date Tue, 15 Mar 2005 13:43:58 GMT
Author: mreutegg
Date: Tue Mar 15 05:43:48 2005
New Revision: 157539

URL: http://svn.apache.org/viewcvs?view=rev&rev=157539
Log:
Test cases for Node.setProperty()

Added:
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SetPropertyBooleanTest.java   (with props)
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SetPropertyCalendarTest.java   (with props)
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SetPropertyDoubleTest.java   (with props)
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SetPropertyInputStreamTest.java   (with props)
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SetPropertyLongTest.java   (with props)
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SetPropertyNodeTest.java   (with props)
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SetPropertyStringTest.java   (with props)
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SetPropertyValueTest.java   (with props)
Modified:
    incubator/jackrabbit/trunk/applications/test/repository/nodetypes/custom_nodetypes.xml
    incubator/jackrabbit/trunk/applications/test/repositoryStubImpl.properties
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/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=157538&r2=157539
==============================================================================
--- incubator/jackrabbit/trunk/applications/test/repository/nodetypes/custom_nodetypes.xml (original)
+++ incubator/jackrabbit/trunk/applications/test/repository/nodetypes/custom_nodetypes.xml Tue Mar 15 05:43:48 2005
@@ -200,5 +200,16 @@
     </childNodeDef>
   </nodeType>
 
+  <!-- Defines a nodetype for testing Node.setProperty(). -->
+  <nodeType name="test:setProperty" isMixin="false" hasOrderableChildNodes="false" primaryItemName="">
+    <supertypes>
+      <supertype>nt:base</supertype>
+      <supertype>mix:referenceable</supertype>
+    </supertypes>
+    <propertyDef name="*" requiredType="undefined" autoCreate="false" mandatory="false" onParentVersion="COPY" protected="false" multiple="false" />
+    <propertyDef name="test:multiProperty" requiredType="undefined" autoCreate="false" mandatory="false" onParentVersion="COPY" protected="false" multiple="true" />
+    <childNodeDef name="*" defaultPrimaryType="test:setProperty" autoCreate="false" mandatory="false" onParentVersion="COPY" protected="false" sameNameSibs="false" />
+  </nodeType>
+
 </nodeTypes>
 

Modified: incubator/jackrabbit/trunk/applications/test/repositoryStubImpl.properties
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/applications/test/repositoryStubImpl.properties?view=diff&r1=157538&r2=157539
==============================================================================
--- incubator/jackrabbit/trunk/applications/test/repositoryStubImpl.properties (original)
+++ incubator/jackrabbit/trunk/applications/test/repositoryStubImpl.properties Tue Mar 15 05:43:48 2005
@@ -181,6 +181,20 @@
 # valid node type that can be added as child of nodetype 2
 javax.jcr.tck.NodeOrderableChildNodesTest.testOrderBeforeUnsupportedRepositoryOperationException.nodetype3=nt:hierarchyNode
 
+# Test class: SetPropertyNodeTest
+# nodetype which is referenceable
+javax.jcr.tck.SetPropertyNodeTest.nodetype=test:setProperty
+
+# Test class: SetPropertyValueTest
+# property that allows multiple values
+javax.jcr.tck.SetPropertyValueTest.propertyname2=test:multiProperty
+javax.jcr.tck.SetPropertyValueTest.nodetype=test:setProperty
+
+# Test class: SetPropertyStringTest
+# property that allows multiple values
+javax.jcr.tck.SetPropertyStringTest.propertyname2=test:multiProperty
+javax.jcr.tck.SetPropertyStringTest.nodetype=test:setProperty
+
 # ------------------------------------------------------------------------------
 # observation configuration
 # ------------------------------------------------------------------------------

Added: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SetPropertyBooleanTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SetPropertyBooleanTest.java?view=auto&rev=157539
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SetPropertyBooleanTest.java (added)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SetPropertyBooleanTest.java Tue Mar 15 05:43:48 2005
@@ -0,0 +1,122 @@
+/*
+ * 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.Value;
+import javax.jcr.Node;
+
+/**
+ * <code>SetPropertyBooleanTest</code> tests the <code>Node.setProperty(String,
+ * boolean)</code> method
+ *
+ * @test
+ * @sources SetPropertyBooleanTest.java
+ * @executeClass org.apache.jackrabbit.test.api.SetPropertyBooleanTest
+ * @keywords level2
+ */
+public class SetPropertyBooleanTest extends AbstractJCRTest {
+
+    private Node testNode;
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        testNode = testRootNode.addNode(nodeName1, testNodeType);
+    }
+
+    /**
+     * Tests if adding a property with <code>Node.setProperty(String,
+     * boolean)</code> works with <code>Session.save()</code>
+     */
+    public void testNewBooleanPropertySession() throws Exception {
+        testNode.setProperty(propertyName1, true);
+        superuser.save();
+        assertEquals("Setting property with Node.setProperty(String, boolean) and Session.save() not working",
+                true,
+                testNode.getProperty(propertyName1).getBoolean());
+    }
+
+    /**
+     * Tests if modifying a property with <code>Node.setProperty(String,
+     * boolean)</code> works with <code>Session.save()</code>
+     */
+    public void testModifyBooleanPropertySession() throws Exception {
+        testNode.setProperty(propertyName1, true);
+        superuser.save();
+        testNode.setProperty(propertyName1, false);
+        superuser.save();
+        assertEquals("Modifying property with Node.setProperty(String, boolean) and Session.save() not working",
+                false,
+                testNode.getProperty(propertyName1).getBoolean());
+    }
+
+    /**
+     * Tests if adding a property with <code>Node.setProperty(String,
+     * boolean)</code> works with <code>parentNode.save()</code>
+     */
+    public void testNewBooleanPropertyParent() throws Exception {
+        testNode.setProperty(propertyName1, true);
+        testRootNode.save();
+        assertEquals("Setting property with Node.setProperty(String, boolean) and parentNode.save() not working",
+                true,
+                testNode.getProperty(propertyName1).getBoolean());
+    }
+
+    /**
+     * Tests if modifying a property with <code>Node.setProperty(String,
+     * boolean)</code> works with <code>parentNode.save()</code>
+     */
+    public void testModifyBooleanPropertyParent() throws Exception {
+        testNode.setProperty(propertyName1, true);
+        testRootNode.save();
+        testNode.setProperty(propertyName1, false);
+        testRootNode.save();
+        assertEquals("Modifying property with Node.setProperty(String, boolean) and parentNode.save() not working",
+                false,
+                testNode.getProperty(propertyName1).getBoolean());
+    }
+
+    /**
+     * Tests if removing a <code>boolean</code> property with
+     * <code>Node.setProperty(String, null)</code> works with
+     * <code>Session.save()</code>
+     */
+    public void testRemoveBooleanPropertySession() throws Exception {
+        testNode.setProperty(propertyName1, true);
+        superuser.save();
+        testNode.setProperty(propertyName1, (Value) null);
+        superuser.save();
+        assertFalse("Removing boolean property with Node.setProperty(String, null) and Session.save() not working",
+                testNode.hasProperty(propertyName1));
+    }
+
+    /**
+     * Tests if removing a <code>boolean</code> property with
+     * <code>Node.setProperty(String, null)</code> works with
+     * <code>parentNode.save()</code>
+     */
+    public void testRemoveBooleanPropertyParent() throws Exception {
+        testNode.setProperty(propertyName1, true);
+        testRootNode.save();
+        testNode.setProperty(propertyName1, (Value) null);
+        testRootNode.save();
+        assertFalse("Removing boolean property with Node.setProperty(String, null) and parentNode.save() not working",
+                testNode.hasProperty(propertyName1));
+    }
+
+}
\ No newline at end of file

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

Added: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SetPropertyCalendarTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SetPropertyCalendarTest.java?view=auto&rev=157539
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SetPropertyCalendarTest.java (added)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SetPropertyCalendarTest.java Tue Mar 15 05:43:48 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.Node;
+
+import java.util.Calendar;
+import java.util.GregorianCalendar;
+
+/**
+ * <code>SetPropertyCalendarTest</code> tests the <code>Node.setProperty(String,
+ * Calendar)</code> method
+ *
+ * @test
+ * @sources SetPropertyCalendarTest.java
+ * @executeClass org.apache.jackrabbit.test.api.SetPropertyCalendarTest
+ * @keywords level2
+ */
+public class SetPropertyCalendarTest extends AbstractJCRTest {
+
+    private Node testNode;
+
+    private Calendar c1 = new GregorianCalendar(2005, 1, 10, 14, 8, 56);
+    private Calendar c2 = new GregorianCalendar(1945, 1, 6, 16, 20, 0);
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        testNode = testRootNode.addNode(nodeName1, testNodeType);
+    }
+
+    /**
+     * Tests if adding a property with <code>Node.setProperty(String,
+     * Calendar)</code> works with <code>Session.save()</code>
+     */
+    public void testNewCalendarPropertySession() throws Exception {
+        testNode.setProperty(propertyName1, c1);
+        superuser.save();
+        assertEquals("Setting property with Node.setProperty(String, Calendar) and Session.save() not working",
+                c1,
+                testNode.getProperty(propertyName1).getDate());
+    }
+
+    /**
+     * Tests if modifying a property with <code>Node.setProperty(String,
+     * Calendar)</code> works with <code>Session.save()</code>
+     */
+    public void testModifyCalendarPropertySession() throws Exception {
+        testNode.setProperty(propertyName1, c1);
+        superuser.save();
+        testNode.setProperty(propertyName1, c2);
+        superuser.save();
+        assertEquals("Modifying property with Node.setProperty(String, Calendar) and Session.save() not working",
+                c2,
+                testNode.getProperty(propertyName1).getDate());
+    }
+
+    /**
+     * Tests if adding a property with <code>Node.setProperty(String,
+     * Calendar)</code> works with <code>parentNode.save()</code>
+     */
+    public void testNewCalendarPropertyParent() throws Exception {
+        testNode.setProperty(propertyName1, c1);
+        testRootNode.save();
+        assertEquals("Setting property with Node.setProperty(String, Calendar) and parentNode.save() not working",
+                c1,
+                testNode.getProperty(propertyName1).getDate());
+    }
+
+    /**
+     * Tests if modifying a property with <code>Node.setProperty(String,
+     * Calendar)</code> works with <code>parentNode.save()</code>
+     */
+    public void testModifyCalendarPropertyParent() throws Exception {
+        testNode.setProperty(propertyName1, c1);
+        testRootNode.save();
+        testNode.setProperty(propertyName1, c2);
+        testRootNode.save();
+        assertEquals("Modifying property with Node.setProperty(String, Calendar) and parentNode.save() not working",
+                c2,
+                testNode.getProperty(propertyName1).getDate());
+    }
+
+    /**
+     * Tests if removing a <code>Calendar</code> property with
+     * <code>Node.setProperty(String, null)</code> works with
+     * <code>Session.save()</code>
+     */
+    public void testRemoveCalendarPropertySession() throws Exception {
+        testNode.setProperty(propertyName1, c1);
+        superuser.save();
+        testNode.setProperty(propertyName1, (Calendar) null);
+        superuser.save();
+        assertFalse("Removing property with Node.setProperty(String, (Calendar)null) and Session.save() not working",
+                testNode.hasProperty(propertyName1));
+    }
+
+    /**
+     * Tests if removing a <code>Calendar</code> property with
+     * <code>Node.setProperty(String, null)</code> works with
+     * <code>parentNode.save()</code>
+     */
+    public void testRemoveCalendarPropertyParent() throws Exception {
+        testNode.setProperty(propertyName1, c1);
+        testRootNode.save();
+        testNode.setProperty(propertyName1, (Calendar) null);
+        testRootNode.save();
+        assertFalse("Removing property with Node.setProperty(String, (Calendar)null) and parentNode.save() not working",
+                testNode.hasProperty(propertyName1));
+    }
+
+}
\ No newline at end of file

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

Added: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SetPropertyDoubleTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SetPropertyDoubleTest.java?view=auto&rev=157539
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SetPropertyDoubleTest.java (added)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SetPropertyDoubleTest.java Tue Mar 15 05:43:48 2005
@@ -0,0 +1,125 @@
+/*
+ * 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.Value;
+import javax.jcr.Node;
+
+/**
+ * <code>SetPropertyDoubleTest</code> tests the <code>Node.setProperty(String,
+ * double)</code> method
+ *
+ * @test
+ * @sources SetPropertyDoubleTest.java
+ * @executeClass org.apache.jackrabbit.test.api.SetPropertyDoubleTest
+ * @keywords level2
+ */
+public class SetPropertyDoubleTest extends AbstractJCRTest {
+
+    private Node testNode;
+
+    private double d1 = 1.23e20;
+    private double d2 = 1.24e21;
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        testNode = testRootNode.addNode(nodeName1, testNodeType);
+    }
+
+    /**
+     * Tests if adding a property with <code>Node.setProperty(String,
+     * double)</code> works with <code>Session.save()</code>
+     */
+    public void testNewDoublePropertySession() throws Exception {
+        testNode.setProperty(propertyName1, d1);
+        superuser.save();
+        assertEquals("Setting property with Node.setProperty(String, double) and Session.save() not working",
+                new Double(d1),
+                new Double(testNode.getProperty(propertyName1).getDouble()));
+    }
+
+    /**
+     * Tests if modifying a property with <code>Node.setProperty(String,
+     * double)</code> works with <code>Session.save()</code>
+     */
+    public void testModifyDoublePropertySession() throws Exception {
+        testNode.setProperty(propertyName1, d1);
+        superuser.save();
+        testNode.setProperty(propertyName1, d2);
+        superuser.save();
+        assertEquals("Modifying property with Node.setProperty(String, double) and Session.save() not working",
+                new Double(d2),
+                new Double(testNode.getProperty(propertyName1).getDouble()));
+    }
+
+    /**
+     * Tests if adding a property with <code>Node.setProperty(String,
+     * double)</code> works with <code>parentNode.save()</code>
+     */
+    public void testNewDoublePropertyParent() throws Exception {
+        testNode.setProperty(propertyName1, d1);
+        testRootNode.save();
+        assertEquals("Setting property with Node.setProperty(String, double) and parentNode.save() not working",
+                new Double(d1),
+                new Double(testNode.getProperty(propertyName1).getDouble()));
+    }
+
+    /**
+     * Tests if modifying a property with <code>Node.setProperty(String,
+     * double)</code> works with <code>parentNode.save()</code>
+     */
+    public void testModifyDoublePropertyParent() throws Exception {
+        testNode.setProperty(propertyName1, d1);
+        testRootNode.save();
+        testNode.setProperty(propertyName1, d2);
+        testRootNode.save();
+        assertEquals("Modifying property with Node.setProperty(String, double) and parentNode.save() not working",
+                new Double(d2),
+                new Double(testNode.getProperty(propertyName1).getDouble()));
+    }
+
+    /**
+     * Tests if removing a <code>double</code> property with
+     * <code>Node.setProperty(String, null)</code> works with
+     * <code>Session.save()</code>
+     */
+    public void testRemoveDoublePropertySession() throws Exception {
+        testNode.setProperty(propertyName1, d1);
+        superuser.save();
+        testNode.setProperty(propertyName1, (Value) null);
+        superuser.save();
+        assertFalse("Removing double property with Node.setProperty(String, null) and Session.save() not working",
+                testNode.hasProperty(propertyName1));
+    }
+
+    /**
+     * Tests if removing a <code>double</code> property with
+     * <code>Node.setProperty(String, null)</code> works with
+     * <code>parentNode.save()</code>
+     */
+    public void testRemoveDoublePropertyParent() throws Exception {
+        testNode.setProperty(propertyName1, d1);
+        testRootNode.save();
+        testNode.setProperty(propertyName1, (Value) null);
+        testRootNode.save();
+        assertFalse("Removing double property with Node.setProperty(String, null) and parentNode.save() not working",
+                testNode.hasProperty(propertyName1));
+    }
+
+}
\ No newline at end of file

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

Added: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SetPropertyInputStreamTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SetPropertyInputStreamTest.java?view=auto&rev=157539
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SetPropertyInputStreamTest.java (added)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SetPropertyInputStreamTest.java Tue Mar 15 05:43:48 2005
@@ -0,0 +1,160 @@
+/*
+ * 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.Node;
+
+import java.io.InputStream;
+import java.io.ByteArrayInputStream;
+
+/**
+ * <code>SetPropertyInputStreamTest</code> tests the <code>Node.setProperty(String,
+ * InputStream)</code> method
+ *
+ * @test
+ * @sources SetPropertyInputStreamTest.java
+ * @executeClass org.apache.jackrabbit.test.api.SetPropertyInputStreamTest
+ * @keywords level2
+ */
+public class SetPropertyInputStreamTest extends AbstractJCRTest {
+
+    private Node testNode;
+
+    byte[] bytes1 = {73, 26, 32, -36, 40, -43, -124};
+    private InputStream is1 = new ByteArrayInputStream(bytes1);
+    byte[] bytes2 = {-124, -43, 40, -36, 32, 26, 73};
+    private InputStream is2 = new ByteArrayInputStream(bytes2);
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        testNode = testRootNode.addNode(nodeName1, testNodeType);
+    }
+
+    /**
+     * Tests if adding a property with <code>Node.setProperty(String,
+     * InputStream)</code> works with <code>Session.save()</code>
+     */
+    public void testNewInputStreamPropertySession() throws Exception {
+        testNode.setProperty(propertyName1, is1);
+        superuser.save();
+        is1 = new ByteArrayInputStream(bytes1);
+        assertTrue("Setting property with Node.setProperty(String, InputStream) and Session.save() not working",
+                compareInputStreams(is1, testNode.getProperty(propertyName1).getStream()));
+    }
+
+    /**
+     * Tests if modifying a property with <code>Node.setProperty(String,
+     * InputStream)</code> works with <code>Session.save()</code>
+     */
+    public void testModifyInputStreamPropertySession() throws Exception {
+        testNode.setProperty(propertyName1, is1);
+        superuser.save();
+        testNode.setProperty(propertyName1, is2);
+        superuser.save();
+        is2 = new ByteArrayInputStream(bytes2);
+        assertTrue("Modifying property with Node.setProperty(String, InputStream) and Session.save() not working",
+                compareInputStreams(is2, testNode.getProperty(propertyName1).getStream()));
+    }
+
+    /**
+     * Tests if adding a property with <code>Node.setProperty(String,
+     * InputStream)</code> works with <code>parentNode.save()</code>
+     */
+    public void testNewInputStreamPropertyParent() throws Exception {
+        testNode.setProperty(propertyName1, is1);
+        testRootNode.save();
+        is1 = new ByteArrayInputStream(bytes1);
+        assertTrue("Setting property with Node.setProperty(String, InputStream) and parentNode.save() not working",
+                compareInputStreams(is1, testNode.getProperty(propertyName1).getStream()));
+    }
+
+    /**
+     * Tests if modifying a property with <code>Node.setProperty(String,
+     * InputStream)</code> works with <code>parentNode.save()</code>
+     */
+    public void testModifyInputStreamPropertyParent() throws Exception {
+        testNode.setProperty(propertyName1, is1);
+        testRootNode.save();
+        testNode.setProperty(propertyName1, is2);
+        testRootNode.save();
+        is2 = new ByteArrayInputStream(bytes2);
+        assertTrue("Modifying property with Node.setProperty(String, InputStream) and parentNode.save() not working",
+                compareInputStreams(is2, testNode.getProperty(propertyName1).getStream()));
+    }
+
+    /**
+     * Tests if removing a <code>InputStream</code> property with
+     * <code>Node.setProperty(String, null)</code> works with
+     * <code>Session.save()</code>
+     */
+    public void testRemoveInputStreamPropertySession() throws Exception {
+        testNode.setProperty(propertyName1, is1);
+        superuser.save();
+        testNode.setProperty(propertyName1, (InputStream) null);
+        superuser.save();
+        assertFalse("Removing property with Node.setProperty(String, (InputStream)null) and Session.save() not working",
+                testNode.hasProperty(propertyName1));
+    }
+
+    /**
+     * Tests if removing a <code>InputStream</code> property with
+     * <code>Node.setProperty(String, null)</code> works with
+     * <code>parentNode.save()</code>
+     */
+    public void testRemoveInputStreamPropertyParent() throws Exception {
+        testNode.setProperty(propertyName1, is1);
+        testRootNode.save();
+        testNode.setProperty(propertyName1, (InputStream) null);
+        testRootNode.save();
+        assertFalse("Removing property with Node.setProperty(String, (InputStream)null) and parentNode.save() not working",
+                testNode.hasProperty(propertyName1));
+    }
+
+    /**
+     * helper function: InputStream comparison
+     */
+    private boolean compareInputStreams(InputStream f1, InputStream f2) {
+        try {
+            boolean equal = false;
+            int f1byte, f2byte;
+
+            while ((f1byte = f1.read()) != -1) {
+                // byte match -> check next
+                if ((f2byte = f2.read()) != -1 && f2byte == f1byte) {
+                    equal = true;
+                    continue;
+                }
+                // byte mismatch
+                else {
+                    equal = false;
+                    break;
+                }
+            }
+
+            // length mismatch
+            if ((f2byte = f2.read()) != -1) {
+                equal = false;
+            }
+
+            return equal;
+        } catch (Exception e) {
+            return false;
+        }
+    }
+}
\ No newline at end of file

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

Added: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SetPropertyLongTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SetPropertyLongTest.java?view=auto&rev=157539
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SetPropertyLongTest.java (added)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SetPropertyLongTest.java Tue Mar 15 05:43:48 2005
@@ -0,0 +1,125 @@
+/*
+ * 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.Value;
+import javax.jcr.Node;
+
+/**
+ * <code>SetPropertyLongTest</code> tests the <code>Node.setProperty(String,
+ * long)</code> method
+ *
+ * @test
+ * @sources SetPropertyLongTest.java
+ * @executeClass org.apache.jackrabbit.test.api.SetPropertyLongTest
+ * @keywords level2
+ */
+public class SetPropertyLongTest extends AbstractJCRTest {
+
+    private Node testNode;
+
+    private long l1 = 2147483650L;
+    private long l2 = -2147483800L;
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        testNode = testRootNode.addNode(nodeName1, testNodeType);
+    }
+
+    /**
+     * Tests if adding a property with <code>Node.setProperty(String,
+     * long)</code> works with <code>Session.save()</code>
+     */
+    public void testNewLongPropertySession() throws Exception {
+        testNode.setProperty(propertyName1, l1);
+        superuser.save();
+        assertEquals("Setting property with Node.setProperty(String, double) and Session.save() not working",
+                new Long(l1),
+                new Long(testNode.getProperty(propertyName1).getLong()));
+    }
+
+    /**
+     * Tests if modifying a property with <code>Node.setProperty(String,
+     * long)</code> works with <code>Session.save()</code>
+     */
+    public void testModifyLongPropertySession() throws Exception {
+        testNode.setProperty(propertyName1, l1);
+        superuser.save();
+        testNode.setProperty(propertyName1, l2);
+        superuser.save();
+        assertEquals("Modifying property with Node.setProperty(String, double) and Session.save() not working",
+                new Long(l2),
+                new Long(testNode.getProperty(propertyName1).getLong()));
+    }
+
+    /**
+     * Tests if adding a property with <code>Node.setProperty(String,
+     * long)</code> works with <code>parentNode.save()</code>
+     */
+    public void testNewLongPropertyParent() throws Exception {
+        testNode.setProperty(propertyName1, l1);
+        testRootNode.save();
+        assertEquals("Setting property with Node.setProperty(String, double) and parentNode.save() not working",
+                new Long(l1),
+                new Long(testNode.getProperty(propertyName1).getLong()));
+    }
+
+    /**
+     * Tests if modifying a property with <code>Node.setProperty(String,
+     * long)</code> works with <code>parentNode.save()</code>
+     */
+    public void testModifyLongPropertyParent() throws Exception {
+        testNode.setProperty(propertyName1, l1);
+        testRootNode.save();
+        testNode.setProperty(propertyName1, l2);
+        testRootNode.save();
+        assertEquals("Modifying property with Node.setProperty(String, double) and parentNode.save() not working",
+                new Long(l2),
+                new Long(testNode.getProperty(propertyName1).getLong()));
+    }
+
+    /**
+     * Tests if removing a <code>long</code> property with
+     * <code>Node.setProperty(String, null)</code> works with
+     * <code>Session.save()</code>
+     */
+    public void testRemoveLongPropertySession() throws Exception {
+        testNode.setProperty(propertyName1, l1);
+        superuser.save();
+        testNode.setProperty(propertyName1, (Value) null);
+        superuser.save();
+        assertFalse("Removing long property with Node.setProperty(String, null) and Session.save() not working",
+                testNode.hasProperty(propertyName1));
+    }
+
+    /**
+     * Tests if removing a <code>long</code> property with
+     * <code>Node.setProperty(String, null)</code> works with
+     * <code>parentNode.save()</code>
+     */
+    public void testRemoveLongPropertyParent() throws Exception {
+        testNode.setProperty(propertyName1, l1);
+        testRootNode.save();
+        testNode.setProperty(propertyName1, (Value) null);
+        testRootNode.save();
+        assertFalse("Removing long property with Node.setProperty(String, null) and parentNode.save() not working",
+                testNode.hasProperty(propertyName1));
+    }
+
+}
\ No newline at end of file

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

Added: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SetPropertyNodeTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SetPropertyNodeTest.java?view=auto&rev=157539
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SetPropertyNodeTest.java (added)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SetPropertyNodeTest.java Tue Mar 15 05:43:48 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.Node;
+
+/**
+ * <code>SetPropertyNodeTest</code> tests the <code>Node.setProperty(String,
+ * Node)</code> method
+ *
+ * @test
+ * @sources SetPropertyNodeTest.java
+ * @executeClass org.apache.jackrabbit.test.api.SetPropertyNodeTest
+ * @keywords level2
+ */
+public class SetPropertyNodeTest extends AbstractJCRTest {
+
+    private Node testNode;
+
+    private Node n1;
+    private Node n2;
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        testNode = testRootNode.addNode(nodeName1, testNodeType);
+
+        n1 = testRootNode.addNode(nodeName2, testNodeType);
+        n2 = testRootNode.addNode(nodeName3, testNodeType);
+    }
+
+    /**
+     * Tests if adding a property with <code>Node.setProperty(String,
+     * Node)</code> works with <code>Session.save()</code>
+     */
+    public void testNewNodePropertySession() throws Exception {
+        testNode.setProperty(propertyName1, n1);
+        superuser.save();
+        assertEquals("Setting property with Node.setProperty(String, Node) and Session.save() not working",
+                n1.getUUID(),
+                testNode.getProperty(propertyName1).getString());
+    }
+
+    /**
+     * Tests if modifying a property with <code>Node.setProperty(String,
+     * Node)</code> works with <code>Session.save()</code>
+     */
+    public void testModifyNodePropertySession() throws Exception {
+        testNode.setProperty(propertyName1, n1);
+        superuser.save();
+        testNode.setProperty(propertyName1, n2);
+        superuser.save();
+        assertEquals("Modifying property with Node.setProperty(String, Node) and Session.save() not working",
+                n2.getUUID(),
+                testNode.getProperty(propertyName1).getString());
+    }
+
+    /**
+     * Tests if adding a property with <code>Node.setProperty(String,
+     * Node)</code> works with <code>parentNode.save()</code>
+     */
+    public void testNewNodePropertyParent() throws Exception {
+        testNode.setProperty(propertyName1, n1);
+        testRootNode.save();
+        assertEquals("Setting property with Node.setProperty(String, Node) and parentNode.save() not working",
+                n1.getUUID(),
+                testNode.getProperty(propertyName1).getString());
+    }
+
+    /**
+     * Tests if modifying a property with <code>Node.setProperty(String,
+     * Node)</code> works with <code>parentNode.save()</code>
+     */
+    public void testModifyNodePropertyParent() throws Exception {
+        testNode.setProperty(propertyName1, n1);
+        testRootNode.save();
+        testNode.setProperty(propertyName1, n2);
+        testRootNode.save();
+        assertEquals("Modifying property with Node.setProperty(String, Node) and parentNode.save() not working",
+                n2.getUUID(),
+                testNode.getProperty(propertyName1).getString());
+    }
+
+    /**
+     * Tests if removing a <code>Node</code> property with
+     * <code>Node.setProperty(String, null)</code> works with
+     * <code>Session.save()</code>
+     */
+    public void testRemoveNodePropertySession() throws Exception {
+        testNode.setProperty(propertyName1, n1);
+        superuser.save();
+        testNode.setProperty(propertyName1, (Node) null);
+        superuser.save();
+        assertFalse("Removing property with Node.setProperty(String, (Node)null) and Session.save() not working",
+                testNode.hasProperty(propertyName1));
+    }
+
+    /**
+     * Tests if removing a <code>Node</code> property with
+     * <code>Node.setProperty(String, null)</code> works with
+     * <code>parentNode.save()</code>
+     */
+    public void testRemoveNodePropertyParent() throws Exception {
+        testNode.setProperty(propertyName1, n1);
+        testRootNode.save();
+        testNode.setProperty(propertyName1, (Node) null);
+        testRootNode.save();
+        assertFalse("Removing property with Node.setProperty(String, (Node)null) and parentNode.save() not working",
+                testNode.hasProperty(propertyName1));
+    }
+
+}
\ No newline at end of file

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

Added: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SetPropertyStringTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SetPropertyStringTest.java?view=auto&rev=157539
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SetPropertyStringTest.java (added)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SetPropertyStringTest.java Tue Mar 15 05:43:48 2005
@@ -0,0 +1,369 @@
+/*
+ * 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.Value;
+import javax.jcr.Node;
+
+import javax.jcr.StringValue;
+import javax.jcr.ValueFormatException;
+import javax.jcr.PropertyType;
+
+import java.util.Arrays;
+
+
+/**
+ * <code>SetPropertyStringTest</code> tests the methods
+ * <code>Node.setProperty(String, String)</code>, <code>Node.setProperty(String,
+ * String[])</code> and <code>Node.setProperty(String, String[], int)</code>
+ *
+ * @test
+ * @sources SetPropertyStringTest.java
+ * @executeClass org.apache.jackrabbit.test.api.SetPropertyStringTest
+ * @keywords level2
+ */
+public class SetPropertyStringTest extends AbstractJCRTest {
+
+    private Node testNode;
+
+    private String s1 = "abc";
+    private String s2 = "xyz";
+
+    private String[] sArray1 = new String[3];
+    private String[] sArray2 = new String[3];
+    private String[] sArrayNull = new String[3];
+
+    private Value[] vArray1 = new Value[3];
+    private Value[] vArray2 = new Value[3];
+
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        testNode = testRootNode.addNode(nodeName1, testNodeType);
+
+        sArray1[0] = "a";
+        sArray1[1] = "b";
+        sArray1[2] = "c";
+        sArray2[0] = "x";
+        sArray2[1] = "y";
+        sArray2[2] = "z";
+        sArrayNull[0] = null;
+        sArrayNull[1] = null;
+        sArrayNull[2] = null;
+
+        vArray1[0] = new StringValue("a");
+        vArray1[1] = new StringValue("b");
+        vArray1[2] = new StringValue("c");
+
+        vArray2[0] = new StringValue("x");
+        vArray2[1] = new StringValue("y");
+        vArray2[2] = new StringValue("z");
+    }
+
+    /**
+     * Tests if adding a property with <code>Node.setProperty(String,
+     * String)</code> works with <code>Session.save()</code>
+     */
+    public void testNewStringPropertySession() throws Exception {
+        testNode.setProperty(propertyName1, s1);
+        superuser.save();
+        assertEquals("Setting property with Node.setProperty(String, String) and Session.save() not working",
+                s1,
+                testNode.getProperty(propertyName1).getString());
+    }
+
+    /**
+     * Tests if modifying a property with <code>Node.setProperty(String,
+     * String)</code> works with <code>Session.save()</code>
+     */
+    public void testModifyStringPropertySession() throws Exception {
+        testNode.setProperty(propertyName1, s1);
+        superuser.save();
+        testNode.setProperty(propertyName1, s2);
+        superuser.save();
+        assertEquals("Modifying property with Node.setProperty(String, String) and Session.save() not working",
+                s2,
+                testNode.getProperty(propertyName1).getString());
+    }
+
+    /**
+     * Tests if adding a property with <code>Node.setProperty(String,
+     * String)</code> works with <code>parentNode.save()</code>
+     */
+    public void testNewStringPropertyParent() throws Exception {
+        testNode.setProperty(propertyName1, s1);
+        testRootNode.save();
+        assertEquals("Setting property with Node.setProperty(String, String) and parentNode.save() not working",
+                s1,
+                testNode.getProperty(propertyName1).getString());
+    }
+
+    /**
+     * Tests if modifying a property with <code>Node.setProperty(String,
+     * String)</code> works with <code>parentNode.save()</code>
+     */
+    public void testModifyStringPropertyParent() throws Exception {
+        testNode.setProperty(propertyName1, s1);
+        testRootNode.save();
+        testNode.setProperty(propertyName1, s2);
+        testRootNode.save();
+        assertEquals("Modifying property with Node.setProperty(String, String) and parentNode.save() not working",
+                s2,
+                testNode.getProperty(propertyName1).getString());
+    }
+
+    /**
+     * Tests if removing a <code>String</code> property with
+     * <code>Node.setProperty(String, null)</code> works with
+     * <code>Session.save()</code>
+     */
+    public void testRemoveStringPropertySession() throws Exception {
+        testNode.setProperty(propertyName1, s1);
+        superuser.save();
+        testNode.setProperty(propertyName1, (String) null);
+        superuser.save();
+        assertFalse("Removing property with Node.setProperty(String, (String)null) and Session.save() not working",
+                testNode.hasProperty(propertyName1));
+    }
+
+    /**
+     * Tests if removing a <code>String</code> property with
+     * <code>Node.setProperty(String, null)</code> works with
+     * <code>parentNode.save()</code>
+     */
+    public void testRemoveStringPropertyParent() throws Exception {
+        testNode.setProperty(propertyName1, s1);
+        testRootNode.save();
+        testNode.setProperty(propertyName1, (String) null);
+        testRootNode.save();
+        assertFalse("Removing property with Node.setProperty(String, (String)null) and parentNode.save() not working",
+                testNode.hasProperty(propertyName1));
+    }
+
+    /**
+     * Tests if adding properties with <code>Node.setProperty(String,
+     * String[])</code> works with <code>Session.save()</code>
+     */
+    public void testNewStringArrayPropertySession() throws Exception {
+        testNode.setProperty(propertyName2, sArray1);
+        superuser.save();
+        assertEquals("Setting properties with Node.setProperty(String, String[]) and Session.save() not working",
+                Arrays.asList(vArray1),
+                Arrays.asList(testNode.getProperty(propertyName2).getValues()));
+    }
+
+    /**
+     * Tests if modifying properties with <code>Node.setProperty(String,
+     * String[])</code> works with <code>Session.save()</code>
+     */
+    public void testModifyStringArrayPropertySession() throws Exception {
+        testNode.setProperty(propertyName2, sArray1);
+        superuser.save();
+        testNode.setProperty(propertyName2, sArray2);
+        superuser.save();
+        assertEquals("Modifying properties with Node.setProperty(String, String[]) and Session.save() not working",
+                Arrays.asList(vArray2),
+                Arrays.asList(testNode.getProperty(propertyName2).getValues()));
+    }
+
+    /**
+     * Tests if adding properties with <code>Node.setProperty(String,
+     * String[])</code> works with <code>parentNode.save()</code>
+     */
+    public void testNewStringArrayPropertyParent() throws Exception {
+        testNode.setProperty(propertyName2, sArray1);
+        testRootNode.save();
+        assertEquals("Setting properties with Node.setProperty(String, String[]) and parentNode.save() not working",
+                Arrays.asList(vArray1),
+                Arrays.asList(testNode.getProperty(propertyName2).getValues()));
+    }
+
+    /**
+     * Tests if modifying properties with <code>Node.setProperty(String,
+     * String[])</code> works with <code>parentNode.save()</code>
+     */
+    public void testModifyStringArrayPropertyParent() throws Exception {
+        testNode.setProperty(propertyName2, sArray1);
+        testRootNode.save();
+        testNode.setProperty(propertyName2, sArray2);
+        testRootNode.save();
+        assertEquals("Modifying properties with Node.setProperty(String, String[]) and parentNode.save() not working",
+                Arrays.asList(vArray2),
+                Arrays.asList(testNode.getProperty(propertyName2).getValues()));
+    }
+
+    /**
+     * Tests if <code>Node.setProperty(String, String[])</code> throws a {@link
+     * javax.jcr.ValueFormatException} when trying to set a single-value
+     * property to a multi-value
+     */
+    public void testSetSingleStringArrayValueFormatException() throws Exception {
+        try {
+            testNode.setProperty(propertyName1, sArray1);
+            fail("setProperty(singleValueProperty, String[]) not throwing a ValueFormatException");
+        } catch (ValueFormatException success) {
+        }
+    }
+
+    /**
+     * Tests if removing a <code>String[]</code> property with
+     * <code>Node.setProperty(String, null)</code> works with
+     * <code>Session.save()</code>
+     */
+    public void testRemoveStringArrayPropertySession() throws Exception {
+        testNode.setProperty(propertyName2, sArray1);
+        superuser.save();
+        testNode.setProperty(propertyName2, (String[]) null);
+        superuser.save();
+        assertFalse("Removing property with Node.setProperty(String, (String[])null) and Session.save() not working",
+                testNode.hasProperty(propertyName2));
+    }
+
+    /**
+     * Tests if removing a <code>String[]</code> property with
+     * <code>Node.setProperty(String, null)</code> works with
+     * <code>parentNode.save()</code>
+     */
+    public void testRemoveStringArrayPropertyParent() throws Exception {
+        testNode.setProperty(propertyName2, sArray1);
+        testRootNode.save();
+        testNode.setProperty(propertyName2, (String[]) null);
+        testRootNode.save();
+        assertFalse("Removing property with Node.setProperty(String, (String[])null) and parentNode.save() not working",
+                testNode.hasProperty(propertyName2));
+    }
+
+    /**
+     * Tests if <code>Node.setProperty(String, String[])</code> saves an array
+     * of null values as an empty String[]
+     */
+    public void testSetNullStringArray() throws Exception {
+        testNode.setProperty(propertyName2, sArrayNull);
+        superuser.save();
+        assertEquals("Node.setProperty(String, nullStringArray[]) did not set the property to an empty String[]",
+                Arrays.asList(new Value[0]),
+                Arrays.asList(testNode.getProperty(propertyName2).getValues()));
+    }
+
+    /**
+     * Tests if adding properties with <code>Node.setProperty(String, String[],
+     * int)</code> works with <code>Session.save()</code>
+     */
+    public void testNewStringArrayPropertySessionWithPropertyType() throws Exception {
+        testNode.setProperty(propertyName2, sArray1, PropertyType.STRING);
+        superuser.save();
+        assertEquals("Setting properties with Node.setProperty(String, String[], int) and Session.save() not working",
+                Arrays.asList(vArray1),
+                Arrays.asList(testNode.getProperty(propertyName2).getValues()));
+    }
+
+    /**
+     * Tests if modifying properties with <code>Node.setProperty(String,
+     * String[], int)</code> works with <code>Session.save()</code>
+     */
+    public void testModifyStringArrayPropertySessionWithPropertyType() throws Exception {
+        testNode.setProperty(propertyName2, sArray1, PropertyType.STRING);
+        superuser.save();
+        testNode.setProperty(propertyName2, sArray2, PropertyType.STRING);
+        superuser.save();
+        assertEquals("Modifying properties with Node.setProperty(String, String[], int) and Session.save() not working",
+                Arrays.asList(vArray2),
+                Arrays.asList(testNode.getProperty(propertyName2).getValues()));
+    }
+
+    /**
+     * Tests if adding properties with <code>Node.setProperty(String, String[],
+     * int)</code> works with <code>parentNode.save()</code>
+     */
+    public void testNewStringArrayPropertyParentWithPropertyType() throws Exception {
+        testNode.setProperty(propertyName2, sArray1, PropertyType.STRING);
+        testRootNode.save();
+        assertEquals("Setting properties with Node.setProperty(String, String[], int) and parentNode.save() not working",
+                Arrays.asList(vArray1),
+                Arrays.asList(testNode.getProperty(propertyName2).getValues()));
+    }
+
+    /**
+     * Tests if modifying properties with <code>Node.setProperty(String,
+     * String[], int)</code> works with <code>parentNode.save()</code>
+     */
+    public void testModifyStringArrayPropertyParentWithPropertyType() throws Exception {
+        testNode.setProperty(propertyName2, sArray1, PropertyType.STRING);
+        testRootNode.save();
+        testNode.setProperty(propertyName2, sArray2, PropertyType.STRING);
+        testRootNode.save();
+        assertEquals("Modifying properties with Node.setProperty(String, String[], int) and parentNode.save() not working",
+                Arrays.asList(vArray2),
+                Arrays.asList(testNode.getProperty(propertyName2).getValues()));
+    }
+
+    /**
+     * Tests if <code>Node.setProperty(String, String[], int)</code> throws a
+     * {@link javax.jcr.ValueFormatException} when trying to set a single-value
+     * property to a multi-value
+     */
+    public void testSetSingleStringArrayValueFormatExceptionWithPropertyType() throws Exception {
+        try {
+            testNode.setProperty(propertyName1, sArray1, PropertyType.STRING);
+            fail("setProperty(singleValueProperty, String[], int) not throwing a ValueFormatException");
+        } catch (ValueFormatException success) {
+        }
+    }
+
+    /**
+     * Tests if removing a <code>String[]</code> property with
+     * <code>Node.setProperty(String, null, int)</code> works with
+     * <code>Session.save()</code>
+     */
+    public void testRemoveStringArrayPropertySessionWithPropertyType() throws Exception {
+        testNode.setProperty(propertyName2, sArray1, PropertyType.STRING);
+        superuser.save();
+        testNode.setProperty(propertyName2, (String[]) null, PropertyType.STRING);
+        superuser.save();
+        assertFalse("Removing property with Node.setProperty(String, (String[])null, int) and Session.save() not working",
+                testNode.hasProperty(propertyName2));
+    }
+
+    /**
+     * Tests if removing a <code>String[]</code> property with
+     * <code>Node.setProperty(String, null, int)</code> works with
+     * <code>parentNode.save()</code>
+     */
+    public void testRemoveStringArrayPropertyParentWithPropertyType() throws Exception {
+        testNode.setProperty(propertyName2, sArray1, PropertyType.STRING);
+        testRootNode.save();
+        testNode.setProperty(propertyName2, (String[]) null, PropertyType.STRING);
+        testRootNode.save();
+        assertFalse("Removing property with Node.setProperty(String, (String[])null, int) and parentNode.save() not working",
+                testNode.hasProperty(propertyName2));
+    }
+
+    /**
+     * Tests if <code>Node.setProperty(String, String[], int)</code> saves an
+     * array of null values as an empty String[]
+     */
+    public void testSetNullStringArrayWithPropertyType() throws Exception {
+        testNode.setProperty(propertyName2, sArrayNull, PropertyType.STRING);
+        superuser.save();
+        assertEquals("Node.setProperty(String, nullStringArray[], int) did not set the property to an empty Value[]",
+                Arrays.asList(new Value[0]),
+                Arrays.asList(testNode.getProperty(propertyName2).getValues()));
+    }
+
+}
\ No newline at end of file

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

Added: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SetPropertyValueTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SetPropertyValueTest.java?view=auto&rev=157539
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SetPropertyValueTest.java (added)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SetPropertyValueTest.java Tue Mar 15 05:43:48 2005
@@ -0,0 +1,395 @@
+/*
+ * 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.Value;
+import javax.jcr.Node;
+
+import javax.jcr.StringValue;
+import javax.jcr.BooleanValue;
+import javax.jcr.LongValue;
+import javax.jcr.ValueFormatException;
+import javax.jcr.PropertyType;
+
+import java.util.Arrays;
+
+/**
+ * <code>SetPropertyValueTest</code> tests the methods <code>Node.setProperty(String,
+ * Value)</code>, <code>Node.setProperty(String, Value[])</code> and
+ * <code>Node.setProperty(String, Value[], int)</code>
+ *
+ * @test
+ * @sources SetPropertyValueTest.java
+ * @executeClass org.apache.jackrabbit.test.api.SetPropertyValueTest
+ * @keywords level2
+ */
+public class SetPropertyValueTest extends AbstractJCRTest {
+
+    private Node testNode;
+
+    private Value v1 = new StringValue("abc");
+    private Value v2 = new StringValue("xyz");
+
+    private Value[] vArray1 = new Value[3];
+    private Value[] vArray2 = new Value[3];
+    private Value[] vArrayMixed = new Value[3];
+    private Value[] vArrayNull = new Value[3];
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        testNode = testRootNode.addNode(nodeName1, testNodeType);
+
+        vArray1[0] = new StringValue("a");
+        vArray1[1] = new StringValue("b");
+        vArray1[2] = new StringValue("c");
+
+        vArray2[0] = new StringValue("x");
+        vArray2[1] = new StringValue("y");
+        vArray2[2] = new StringValue("z");
+
+        vArrayMixed[0] = new StringValue("abc");
+        vArrayMixed[1] = new BooleanValue(true);
+        vArrayMixed[2] = new LongValue(2147483650L);
+    }
+
+    /**
+     * Tests if adding a property with <code>Node.setProperty(String,
+     * Value)</code> works with <code>Session.save()</code>
+     */
+    public void testNewValuePropertySession() throws Exception {
+        testNode.setProperty(propertyName1, v1);
+        superuser.save();
+        assertEquals("Setting property with Node.setProperty(String, Value) and Session.save() not working",
+                v1,
+                testNode.getProperty(propertyName1).getValue());
+    }
+
+    /**
+     * Tests if modifying a property with <code>Node.setProperty(String,
+     * Value)</code> works with <code>Session.save()</code>
+     */
+    public void testModifyValuePropertySession() throws Exception {
+        testNode.setProperty(propertyName1, v1);
+        superuser.save();
+        testNode.setProperty(propertyName1, v2);
+        superuser.save();
+        assertEquals("Modifying property with Node.setProperty(String, Value) and Session.save() not working",
+                v2,
+                testNode.getProperty(propertyName1).getValue());
+    }
+
+    /**
+     * Tests if adding a property with <code>Node.setProperty(String,
+     * Value)</code> works with <code>parentNode.save()</code>
+     */
+    public void testNewValuePropertyParent() throws Exception {
+        testNode.setProperty(propertyName1, v1);
+        testRootNode.save();
+        assertEquals("Setting property with Node.setProperty(String, Value) and parentNode.save() not working",
+                v1,
+                testNode.getProperty(propertyName1).getValue());
+    }
+
+    /**
+     * Tests if modifying a property with <code>Node.setProperty(String,
+     * Value)</code> works with <code>parentNode.save()</code>
+     */
+    public void testModifyValuePropertyParent() throws Exception {
+        testNode.setProperty(propertyName1, v1);
+        testRootNode.save();
+        testNode.setProperty(propertyName1, v2);
+        testRootNode.save();
+        assertEquals("Modifying property with Node.setProperty(String, Value) and parentNode.save() not working",
+                v2,
+                testNode.getProperty(propertyName1).getValue());
+    }
+
+    /**
+     * Tests if removing a <code>Value</code> property with
+     * <code>Node.setProperty(String, null)</code> works with
+     * <code>Session.save()</code>
+     */
+    public void testRemoveValuePropertySession() throws Exception {
+        testNode.setProperty(propertyName1, v1);
+        superuser.save();
+        testNode.setProperty(propertyName1, (Value) null);
+        superuser.save();
+        assertFalse("Removing property with Node.setProperty(String, (Value)null) and Session.save() not working",
+                testNode.hasProperty(propertyName1));
+    }
+
+    /**
+     * Tests if removing a <code>Value</code> property with
+     * <code>Node.setProperty(String, null)</code> works with
+     * <code>parentNode.save()</code>
+     */
+    public void testRemoveValuePropertyParent() throws Exception {
+        testNode.setProperty(propertyName1, v1);
+        testRootNode.save();
+        testNode.setProperty(propertyName1, (Value) null);
+        testRootNode.save();
+        assertFalse("Removing property with Node.setProperty(String, (Value)null) and parentNode.save() not working",
+                testNode.hasProperty(propertyName1));
+    }
+
+    /**
+     * Value[]
+     */
+
+    /**
+     * Tests if adding properties with <code>Node.setProperty(String,
+     * Value[])</code> works with <code>Session.save()</code>
+     */
+    public void testNewValueArrayPropertySession() throws Exception {
+        testNode.setProperty(propertyName2, vArray1);
+        superuser.save();
+        assertEquals("Setting properties with Node.setProperty(String, Value[]) and Session.save() not working",
+                Arrays.asList(vArray1),
+                Arrays.asList(testNode.getProperty(propertyName2).getValues()));
+    }
+
+    /**
+     * Tests if modifying properties with <code>Node.setProperty(String,
+     * Value[])</code> works with <code>Session.save()</code>
+     */
+    public void testModifyValueArrayPropertySession() throws Exception {
+        testNode.setProperty(propertyName2, vArray1);
+        superuser.save();
+        testNode.setProperty(propertyName2, vArray2);
+        superuser.save();
+        assertEquals("Modifying properties with Node.setProperty(String, Value[]) and Session.save() not working",
+                Arrays.asList(vArray2),
+                Arrays.asList(testNode.getProperty(propertyName2).getValues()));
+    }
+
+    /**
+     * Tests if adding properties with <code>Node.setProperty(String,
+     * Value[])</code> works with <code>parentNode.save()</code>
+     */
+    public void testNewValueArrayPropertyParent() throws Exception {
+        testNode.setProperty(propertyName2, vArray1);
+        testRootNode.save();
+        assertEquals("Setting properties with Node.setProperty(String, Value[]) and parentNode.save() not working",
+                Arrays.asList(vArray1),
+                Arrays.asList(testNode.getProperty(propertyName2).getValues()));
+    }
+
+    /**
+     * Tests if modifying properties with <code>Node.setProperty(String,
+     * Value[])</code> works with <code>parentNode.save()</code>
+     */
+    public void testModifyValueArrayPropertyParent() throws Exception {
+        testNode.setProperty(propertyName2, vArray1);
+        testRootNode.save();
+        testNode.setProperty(propertyName2, vArray2);
+        testRootNode.save();
+        assertEquals("Modifying properties with Node.setProperty(String, Value[]) and parentNode.save() not working",
+                Arrays.asList(vArray2),
+                Arrays.asList(testNode.getProperty(propertyName2).getValues()));
+    }
+
+    /**
+     * Tests if <code>Node.setProperty(String, Value[])</code> throws a {@link
+     * javax.jcr.ValueFormatException} when trying to set a multi-value property
+     * to an array of values with different types
+     */
+    public void testSetMixedValueArrayValueFormatException() throws Exception {
+        try {
+            testNode.setProperty(propertyName2, vArrayMixed);
+            fail("setProperty(String, mixedValueArray[]) not throwing a ValueFormatException");
+        } catch (ValueFormatException success) {
+        }
+    }
+
+    /**
+     * Tests if <code>Node.setProperty(String, Value[])</code> throws a {@link
+     * javax.jcr.ValueFormatException} when trying to set a single-value
+     * property to a multi-value
+     */
+    public void testSetSingleValueArrayValueFormatException() throws Exception {
+        try {
+            testNode.setProperty(propertyName1, vArray1);
+            fail("setProperty(singleValueProperty, Value[]) not throwing a ValueFormatException");
+        } catch (ValueFormatException success) {
+        }
+    }
+
+    /**
+     * Tests if removing a <code>Value[]</code> property with
+     * <code>Node.setProperty(String, null)</code> works with
+     * <code>Session.save()</code>
+     */
+    public void testRemoveValueArrayPropertySession() throws Exception {
+        testNode.setProperty(propertyName2, vArray1);
+        superuser.save();
+        testNode.setProperty(propertyName2, (Value[]) null);
+        superuser.save();
+        assertFalse("Removing property with Node.setProperty(String, (Value[])null) and Session.save() not working",
+                testNode.hasProperty(propertyName2));
+    }
+
+    /**
+     * Tests if removing a <code>Value[]</code> property with
+     * <code>Node.setProperty(String, null)</code> works with
+     * <code>parentNode.save()</code>
+     */
+    public void testRemoveValueArrayPropertyParent() throws Exception {
+        testNode.setProperty(propertyName2, vArray1);
+        testRootNode.save();
+        testNode.setProperty(propertyName2, (Value[]) null);
+        testRootNode.save();
+        assertFalse("Removing property with Node.setProperty(String, (Value[])null) and parentNode.save() not working",
+                testNode.hasProperty(propertyName2));
+    }
+
+    /**
+     * Tests if <code>Node.setProperty(String, Value[])</code> saves an array of
+     * null values as an empty Value[]
+     */
+    public void testSetNullValueArray() throws Exception {
+        testNode.setProperty(propertyName2, vArrayNull);
+        superuser.save();
+        assertEquals("Node.setProperty(String, nullValueArray[]) did not set the property to an empty Value[]",
+                Arrays.asList(new Value[0]),
+                Arrays.asList(testNode.getProperty(propertyName2).getValues()));
+    }
+
+    /**
+     * Value[] with PropertyType
+     */
+
+    /**
+     * Tests if adding properties with <code>Node.setProperty(String, Value[],
+     * int)</code> works with <code>Session.save()</code>
+     */
+    public void testNewValueArrayPropertySessionWithPropertyType() throws Exception {
+        testNode.setProperty(propertyName2, vArray1, PropertyType.STRING);
+        superuser.save();
+        assertEquals("Setting properties with Node.setProperty(String, Value[], int) and Session.save() not working",
+                Arrays.asList(vArray1),
+                Arrays.asList(testNode.getProperty(propertyName2).getValues()));
+    }
+
+    /**
+     * Tests if modifying properties with <code>Node.setProperty(String,
+     * Value[], int)</code> works with <code>Session.save()</code>
+     */
+    public void testModifyValueArrayPropertySessionWithPropertyType() throws Exception {
+        testNode.setProperty(propertyName2, vArray1, PropertyType.STRING);
+        superuser.save();
+        testNode.setProperty(propertyName2, vArray2, PropertyType.STRING);
+        superuser.save();
+        assertEquals("Modifying properties with Node.setProperty(String, Value[], int) and Session.save() not working",
+                Arrays.asList(vArray2),
+                Arrays.asList(testNode.getProperty(propertyName2).getValues()));
+    }
+
+    /**
+     * Tests if adding properties with <code>Node.setProperty(String, Value[],
+     * int)</code> works with <code>parentNode.save()</code>
+     */
+    public void testNewValueArrayPropertyParentWithPropertyType() throws Exception {
+        testNode.setProperty(propertyName2, vArray1, PropertyType.STRING);
+        testRootNode.save();
+        assertEquals("Setting properties with Node.setProperty(String, Value[], int) and parentNode.save() not working",
+                Arrays.asList(vArray1),
+                Arrays.asList(testNode.getProperty(propertyName2).getValues()));
+    }
+
+    /**
+     * Tests if modifying properties with <code>Node.setProperty(String,
+     * Value[], int)</code> works with <code>parentNode.save()</code>
+     */
+    public void testModifyValueArrayPropertyParentWithPropertyType() throws Exception {
+        testNode.setProperty(propertyName2, vArray1, PropertyType.STRING);
+        testRootNode.save();
+        testNode.setProperty(propertyName2, vArray2, PropertyType.STRING);
+        testRootNode.save();
+        assertEquals("Modifying properties with Node.setProperty(String, Value[], int) and parentNode.save() not working",
+                Arrays.asList(vArray2),
+                Arrays.asList(testNode.getProperty(propertyName2).getValues()));
+    }
+
+    /**
+     * Tests if <code>Node.setProperty(String, Value[], int)</code> throws a
+     * {@link javax.jcr.ValueFormatException} when trying to set a multi-value
+     * property to an array of values with different types
+     */
+    public void testSetMixedValueArrayValueFormatExceptionWithPropertyType() throws Exception {
+        try {
+            testNode.setProperty(propertyName2, vArrayMixed, PropertyType.STRING);
+            fail("setProperty(String, mixedValueArray[], int) not throwing a ValueFormatException");
+        } catch (ValueFormatException success) {
+        }
+    }
+
+    /**
+     * Tests if <code>Node.setProperty(String, Value[], int)</code> throws a
+     * {@link javax.jcr.ValueFormatException} when trying to set a single-value
+     * property to a multi-value
+     */
+    public void testSetSingleValueArrayValueFormatExceptionWithPropertyType() throws Exception {
+        try {
+            testNode.setProperty(propertyName1, vArray1, PropertyType.STRING);
+            fail("setProperty(singleValueProperty, Value[], int) not throwing a ValueFormatException");
+        } catch (ValueFormatException success) {
+        }
+    }
+
+    /**
+     * Tests if removing a <code>Value[]</code> property with
+     * <code>Node.setProperty(String, null, int)</code> works with
+     * <code>Session.save()</code>
+     */
+    public void testRemoveValueArrayPropertySessionWithPropertyType() throws Exception {
+        testNode.setProperty(propertyName2, vArray1, PropertyType.STRING);
+        superuser.save();
+        testNode.setProperty(propertyName2, (Value[]) null, PropertyType.STRING);
+        superuser.save();
+        assertFalse("Removing property with Node.setProperty(String, (Value[])null, int) and Session.save() not working",
+                testNode.hasProperty(propertyName2));
+    }
+
+    /**
+     * Tests if removing a <code>Value[]</code> property with
+     * <code>Node.setProperty(String, null, int)</code> works with
+     * <code>parentNode.save()</code>
+     */
+    public void testRemoveValueArrayPropertyParentWithPropertyType() throws Exception {
+        testNode.setProperty(propertyName2, vArray1, PropertyType.STRING);
+        testRootNode.save();
+        testNode.setProperty(propertyName2, (Value[]) null, PropertyType.STRING);
+        testRootNode.save();
+        assertFalse("Removing property with Node.setProperty(String, (Value[])null, int) and parentNode.save() not working",
+                testNode.hasProperty(propertyName2));
+    }
+
+    /**
+     * Tests if <code>Node.setProperty(String, Value[], int)</code> saves an
+     * array of null values as an empty Value[]
+     */
+    public void testSetNullValueArrayWithPropertyType() throws Exception {
+        testNode.setProperty(propertyName2, vArrayNull, PropertyType.STRING);
+        superuser.save();
+        assertEquals("Node.setProperty(String, nullValueArray[], int) did not set the property to an empty Value[]",
+                Arrays.asList(new Value[0]),
+                Arrays.asList(testNode.getProperty(propertyName2).getValues()));
+    }
+
+}
\ No newline at end of file

Propchange: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SetPropertyValueTest.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=157538&r2=157539
==============================================================================
--- 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 Tue Mar 15 05:43:48 2005
@@ -81,6 +81,15 @@
         suite.addTestSuite(SetValueReferenceTest.class);
         suite.addTestSuite(SetValueStringTest.class);
 
+        suite.addTestSuite(SetPropertyBooleanTest.class);
+        suite.addTestSuite(SetPropertyCalendarTest.class);
+        suite.addTestSuite(SetPropertyDoubleTest.class);
+        suite.addTestSuite(SetPropertyInputStreamTest.class);
+        suite.addTestSuite(SetPropertyLongTest.class);
+        suite.addTestSuite(SetPropertyNodeTest.class);
+        suite.addTestSuite(SetPropertyStringTest.class);
+        suite.addTestSuite(SetPropertyValueTest.class);
+
         suite.addTestSuite(NodeItemIsModifiedTest.class);
         suite.addTestSuite(NodeItemIsNewTest.class);
         suite.addTestSuite(PropertyItemIsModifiedTest.class);



Mime
View raw message