You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by an...@apache.org on 2006/11/30 16:45:36 UTC

svn commit: r480976 - in /jackrabbit/trunk/contrib/spi/client/src/test/java/org/apache/jackrabbit/jcr2spi: MoveTest.java MultiValuedPropertyTest.java SingleValuedPropertyTest.java

Author: angela
Date: Thu Nov 30 07:45:35 2006
New Revision: 480976

URL: http://svn.apache.org/viewvc?view=rev&rev=480976
Log:
work in progress

- tests

Added:
    jackrabbit/trunk/contrib/spi/client/src/test/java/org/apache/jackrabbit/jcr2spi/MultiValuedPropertyTest.java   (with props)
    jackrabbit/trunk/contrib/spi/client/src/test/java/org/apache/jackrabbit/jcr2spi/SingleValuedPropertyTest.java   (with props)
Modified:
    jackrabbit/trunk/contrib/spi/client/src/test/java/org/apache/jackrabbit/jcr2spi/MoveTest.java

Modified: jackrabbit/trunk/contrib/spi/client/src/test/java/org/apache/jackrabbit/jcr2spi/MoveTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/client/src/test/java/org/apache/jackrabbit/jcr2spi/MoveTest.java?view=diff&rev=480976&r1=480975&r2=480976
==============================================================================
--- jackrabbit/trunk/contrib/spi/client/src/test/java/org/apache/jackrabbit/jcr2spi/MoveTest.java (original)
+++ jackrabbit/trunk/contrib/spi/client/src/test/java/org/apache/jackrabbit/jcr2spi/MoveTest.java Thu Nov 30 07:45:35 2006
@@ -26,6 +26,8 @@
 import javax.jcr.NodeIterator;
 import javax.jcr.PathNotFoundException;
 import javax.jcr.Item;
+import javax.jcr.Property;
+import javax.jcr.ItemExistsException;
 
 /**
  * <code>MoveTest</code>...
@@ -243,5 +245,30 @@
         assertTrue("Parent of moved node must be the destination parent node.", moveNode.getParent().isSame(destParentNode));
         // NOTE: implementation specific test
         assertTrue("After successful moving a referenceable node node, accessing the node by uuid be the identical node.", moveNode.getParent() == destParentNode);
+    }
+
+    /**
+     * Tries to move a node using <code>{@link javax.jcr.Session#move(String src, String dest)}
+     * </code> to a location where a property already exists with same name.
+     * <br/> <br/>
+     * This should throw an <code>{@link javax.jcr.ItemExistsException}</code>.
+     */
+    public void testMovePropertyExistsException() throws RepositoryException, NotExecutableException {
+        // try to create a property with the name of the node to be moved
+        // to the destination parent
+        Property destProperty;
+        try {
+            destProperty = destParentNode.setProperty(nodeName2, "anyString");
+        } catch (RepositoryException e) {
+            throw new NotExecutableException("Cannot create property with name '" +nodeName2+ "' and value 'anyString' at move destination.");
+        }
+
+        try {
+            // move the node
+            superuser.move(moveNode.getPath(), destProperty.getPath());
+            fail("Moving a node using Session.move() to a location where a property already exists must throw ItemExistsException");
+        } catch (ItemExistsException e) {
+            // ok, works as expected
+        }
     }
 }

Added: jackrabbit/trunk/contrib/spi/client/src/test/java/org/apache/jackrabbit/jcr2spi/MultiValuedPropertyTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/client/src/test/java/org/apache/jackrabbit/jcr2spi/MultiValuedPropertyTest.java?view=auto&rev=480976
==============================================================================
--- jackrabbit/trunk/contrib/spi/client/src/test/java/org/apache/jackrabbit/jcr2spi/MultiValuedPropertyTest.java (added)
+++ jackrabbit/trunk/contrib/spi/client/src/test/java/org/apache/jackrabbit/jcr2spi/MultiValuedPropertyTest.java Thu Nov 30 07:45:35 2006
@@ -0,0 +1,179 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.jcr2spi;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.apache.jackrabbit.test.NotExecutableException;
+import org.apache.jackrabbit.test.AbstractJCRTest;
+import org.apache.jackrabbit.test.api.PropertyUtil;
+
+import javax.jcr.RepositoryException;
+import javax.jcr.Property;
+import javax.jcr.ValueFormatException;
+
+/**
+ * <code>MultiValuedPropertyTest</code>...
+ */
+public class MultiValuedPropertyTest extends AbstractJCRTest {
+
+    private static Logger log = LoggerFactory.getLogger(MultiValuedPropertyTest.class);
+
+    /**
+     * Tests if Property.getStream() fails with ValueFormatException for
+     * multivalued properties.
+     *
+     * @throws RepositoryException
+     * @throws NotExecutableException
+     */
+    public void testGetStreamFromMultivalued() throws RepositoryException, NotExecutableException {
+        Property prop = PropertyUtil.searchMultivalProp(testRootNode);
+        if (prop == null) {
+            throw new NotExecutableException("No multivalued property found.");
+        }
+        else {
+            try {
+                prop.getStream();
+                fail("Property.getStream() must fail with ValueFormatException for any multivalued property.");
+            } catch (ValueFormatException vfe) {
+                // ok
+            }
+        }
+    }
+
+    /**
+     * Tests if Property.getString() fails with ValueFormatException for
+     * multivalued properties.
+     *
+     * @throws RepositoryException
+     * @throws NotExecutableException
+     */
+    public void testGetStringFromMultivalued() throws RepositoryException, NotExecutableException {
+        Property prop = PropertyUtil.searchMultivalProp(testRootNode);
+        if (prop == null) {
+            throw new NotExecutableException("No multivalued property found.");
+        }
+        else {
+            try {
+                prop.getString();
+                fail("Property.getString() must fail with ValueFormatException for any multivalued property.");
+            } catch (ValueFormatException vfe) {
+                // ok
+            }
+        }
+    }
+
+    /**
+     * Tests if Property.getDate() fails multivalued properties.
+     *
+     * @throws RepositoryException
+     * @throws NotExecutableException
+     */
+    public void testGetDateFromMultivalued() throws RepositoryException, NotExecutableException {
+        Property prop = PropertyUtil.searchMultivalProp(testRootNode);
+        if (prop == null) {
+            throw new NotExecutableException("No multivalued property found.");
+        }
+        else {
+            try {
+                prop.getDate();
+                fail("Property.getDate() must fail with ValueFormatException for any multivalued property.");
+            } catch (ValueFormatException vfe) {
+                // ok
+            }
+        }
+    }
+
+    /**
+     * Tests if Property.getDouble() fails for multivalued properties.
+     *
+     * @throws RepositoryException
+     * @throws NotExecutableException
+     */
+    public void testGetDoubleFromMultivalued() throws RepositoryException, NotExecutableException {
+        Property prop = PropertyUtil.searchMultivalProp(testRootNode);
+        if (prop == null) {
+            throw new NotExecutableException("No multivalued property found.");
+        }
+        else {
+            try {
+                prop.getDouble();
+                fail("Property.getDouble() must fail with ValueFormatException for any multivalued property.");
+            } catch (ValueFormatException vfe) {
+                // ok
+            }
+        }
+    }
+
+    /**
+     * Tests if Property.getLong() fails for multivalued properties.
+     *
+     * @throws RepositoryException
+     * @throws NotExecutableException
+     */
+    public void testGetLongFromMultivalued() throws RepositoryException, NotExecutableException {
+        Property prop = PropertyUtil.searchMultivalProp(testRootNode);
+        if (prop == null) {
+            throw new NotExecutableException("No multivalued property found.");
+        }
+        else {
+            try {
+                prop.getLong();
+                fail("Property.getLong() must fail with ValueFormatException for any multivalued property.");
+            } catch (ValueFormatException vfe) {
+                // ok
+            }
+        }
+    }
+
+    /**
+     * Tests if Property.getBoolean() fails for multivalued properties.
+     *
+     * @throws RepositoryException
+     * @throws NotExecutableException
+     */
+    public void testGetBooleanFromMultivalued() throws RepositoryException, NotExecutableException {
+        Property prop = PropertyUtil.searchMultivalProp(testRootNode);
+        if (prop == null) {
+            throw new NotExecutableException("No multivalued property found.");
+        }
+        else {
+            try {
+                prop.getBoolean();
+                fail("Property.getLong() must fail with ValueFormatException for any multivalued property.");
+            } catch (ValueFormatException vfe) {
+                // ok
+            }
+        }
+    }
+
+    /**
+     * Tests if Property.getLength() fails for multivalued property.
+     */
+    public void testGetLengthFromMultivalued() throws RepositoryException, NotExecutableException {
+        Property prop = PropertyUtil.searchMultivalProp(testRootNode);
+        if (prop == null) {
+            throw new NotExecutableException("No multivalued property found.");
+        }
+        try {
+            prop.getLength();
+            fail("Property.getLength() called on a multivalue property must fail (ValueFormatException).");
+        } catch (ValueFormatException vfe) {
+            // ok
+        }
+    }
+}
\ No newline at end of file

Propchange: jackrabbit/trunk/contrib/spi/client/src/test/java/org/apache/jackrabbit/jcr2spi/MultiValuedPropertyTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/trunk/contrib/spi/client/src/test/java/org/apache/jackrabbit/jcr2spi/MultiValuedPropertyTest.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision url

Added: jackrabbit/trunk/contrib/spi/client/src/test/java/org/apache/jackrabbit/jcr2spi/SingleValuedPropertyTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/client/src/test/java/org/apache/jackrabbit/jcr2spi/SingleValuedPropertyTest.java?view=auto&rev=480976
==============================================================================
--- jackrabbit/trunk/contrib/spi/client/src/test/java/org/apache/jackrabbit/jcr2spi/SingleValuedPropertyTest.java (added)
+++ jackrabbit/trunk/contrib/spi/client/src/test/java/org/apache/jackrabbit/jcr2spi/SingleValuedPropertyTest.java Thu Nov 30 07:45:35 2006
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.jcr2spi;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.apache.jackrabbit.test.AbstractJCRTest;
+import org.apache.jackrabbit.test.NotExecutableException;
+import org.apache.jackrabbit.test.api.PropertyUtil;
+
+import javax.jcr.RepositoryException;
+import javax.jcr.Property;
+import javax.jcr.ValueFormatException;
+
+/**
+ * <code>SingleValuedPropertyTest</code>...
+ */
+public class SingleValuedPropertyTest extends AbstractJCRTest {
+
+    private static Logger log = LoggerFactory.getLogger(SingleValuedPropertyTest.class);
+
+    /**
+     * Tests if Property.getLengths() fails for single value property.
+     */
+    public void testGetLengthsFromSingleValued() throws RepositoryException, NotExecutableException {
+        Property singleProp = PropertyUtil.searchSingleValuedProperty(testRootNode);
+        if (singleProp == null) {
+            throw new NotExecutableException("No single valued property found.");
+        }
+        try {
+            singleProp.getLengths();
+            fail("Property.getLengths() called on a single value property must fail (ValueFormatException).");
+        } catch (ValueFormatException vfe) {
+            // ok
+        }
+    }
+}
\ No newline at end of file

Propchange: jackrabbit/trunk/contrib/spi/client/src/test/java/org/apache/jackrabbit/jcr2spi/SingleValuedPropertyTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/trunk/contrib/spi/client/src/test/java/org/apache/jackrabbit/jcr2spi/SingleValuedPropertyTest.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision url