jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From resc...@apache.org
Subject svn commit: r790600 - in /jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api: SetPropertyDecimalTest.java SetValueDecimalTest.java TestAll.java
Date Thu, 02 Jul 2009 14:10:19 GMT
Author: reschke
Date: Thu Jul  2 14:10:19 2009
New Revision: 790600

URL: http://svn.apache.org/viewvc?rev=790600&view=rev
Log:
JCR-2085: add more test cases related to Decimal properties

Added:
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SetValueDecimalTest.java
  (with props)
Modified:
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SetPropertyDecimalTest.java
  (contents, props changed)
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/TestAll.java

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SetPropertyDecimalTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SetPropertyDecimalTest.java?rev=790600&r1=790599&r2=790600&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SetPropertyDecimalTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SetPropertyDecimalTest.java
Thu Jul  2 14:10:19 2009
@@ -1,94 +1,93 @@
-/*
- * 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.test.api;
-
-import java.math.BigDecimal;
-
-import javax.jcr.Node;
-import javax.jcr.Value;
-
-import org.apache.jackrabbit.test.AbstractJCRTest;
-
-/**
- * <code>SetPropertyDecmimalTest</code> tests the <code>Node.setProperty(String,
- * BigDecimal)</code> method
- *
- * @test
- * @sources SetPropertyDecimalTest.java
- * @executeClass org.apache.jackrabbit.test.api.SetPropertyDecimalTest
- * @keywords level2
- */
-public class SetPropertyDecimalTest extends AbstractJCRTest {
-
-    private Node testNode;
-
-    private BigDecimal b1 = new BigDecimal("-123545678901234567890123545678901234567890.123545678901234567890");
-    private BigDecimal b2 = new BigDecimal("123545678901234567890123545678901234567890.123545678901234567890");
-
-    protected void setUp() throws Exception {
-        super.setUp();
-        testNode = testRootNode.addNode(nodeName1, testNodeType);
-        // abort test if the repository does not allow setting
-        // decimal properties on this node
-        ensureCanSetProperty(testNode, propertyName1, testNode.getSession().getValueFactory().createValue(new
BigDecimal(0)));
-    }
-
-    protected void tearDown() throws Exception {
-        testNode = null;
-        super.tearDown();
-    }
-
-    /**
-     * Tests if adding a property with <code>Node.setProperty(String,
-     * BigDecimal)</code> works with <code>Session.save()</code>
-     */
-    public void testNewDecimalPropertySession() throws Exception {
-        testNode.setProperty(propertyName1, b1);
-        superuser.save();
-        assertEquals("Setting property with Node.setProperty(String, double) and Session.save()
not working",
-                b1,
-                testNode.getProperty(propertyName1).getDecimal());
-    }
-
-    /**
-     * Tests if modifying a property with <code>Node.setProperty(String,
-     * BigDecimal)</code> works with <code>Session.save()</code>
-     */
-    public void testModifyDecimalPropertySession() throws Exception {
-        testNode.setProperty(propertyName1, b1);
-        superuser.save();
-        testNode.setProperty(propertyName1, b2);
-        superuser.save();
-        assertEquals("Modifying property with Node.setProperty(String, double) and Session.save()
not working",
-                b2,
-                testNode.getProperty(propertyName1).getDecimal());
-    }
-
-    /**
-     * Tests if removing a <code>BigDecimal</code> property with
-     * <code>Node.setProperty(String, null)</code> works with
-     * <code>Session.save()</code>
-     */
-    public void testRemoveDecimalPropertySession() throws Exception {
-        testNode.setProperty(propertyName1, b1);
-        testRootNode.getSession().save();
-        testNode.setProperty(propertyName1, (Value) null);
-        testRootNode.getSession().save();
-        assertFalse("Removing decimal property with Node.setProperty(String, null) and Session.save()
not working",
-                testNode.hasProperty(propertyName1));
-    }
+/*
+ * 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.test.api;
+
+import java.math.BigDecimal;
+
+import javax.jcr.Node;
+import javax.jcr.Value;
+
+import org.apache.jackrabbit.test.AbstractJCRTest;
+
+/**
+ * <code>SetPropertyDecmimalTest</code> tests the <code>Node.setProperty(String,
+ * BigDecimal)</code> method
+ *
+ * @test
+ * @sources SetPropertyDecimalTest.java
+ * @executeClass org.apache.jackrabbit.test.api.SetPropertyDecimalTest
+ * @keywords level2
+ */
+public class SetPropertyDecimalTest extends AbstractJCRTest {
+
+    private Node testNode;
+
+    private BigDecimal b1 = new BigDecimal("-123545678901234567890123545678901234567890.123545678901234567890");
+    private BigDecimal b2 = new BigDecimal("123545678901234567890123545678901234567890.123545678901234567890");
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        testNode = testRootNode.addNode(nodeName1, testNodeType);
+        // abort test if the repository does not allow setting
+        // decimal properties on this node
+        ensureCanSetProperty(testNode, propertyName1, testNode.getSession().getValueFactory().createValue(new
BigDecimal(0)));
+    }
+
+    protected void tearDown() throws Exception {
+        super.tearDown();
+    }
+
+    /**
+     * Tests if adding a property with <code>Node.setProperty(String,
+     * BigDecimal)</code> works with <code>Session.save()</code>
+     */
+    public void testNewDecimalPropertySession() throws Exception {
+        testNode.setProperty(propertyName1, b1);
+        superuser.save();
+        assertEquals("Setting property with Node.setProperty(String, double) and Session.save()
not working",
+                b1,
+                testNode.getProperty(propertyName1).getDecimal());
+    }
+
+    /**
+     * Tests if modifying a property with <code>Node.setProperty(String,
+     * BigDecimal)</code> works with <code>Session.save()</code>
+     */
+    public void testModifyDecimalPropertySession() throws Exception {
+        testNode.setProperty(propertyName1, b1);
+        superuser.save();
+        testNode.setProperty(propertyName1, b2);
+        superuser.save();
+        assertEquals("Modifying property with Node.setProperty(String, double) and Session.save()
not working",
+                b2,
+                testNode.getProperty(propertyName1).getDecimal());
+    }
+
+    /**
+     * Tests if removing a <code>BigDecimal</code> property with
+     * <code>Node.setProperty(String, null)</code> works with
+     * <code>Session.save()</code>
+     */
+    public void testRemoveDecimalPropertySession() throws Exception {
+        testNode.setProperty(propertyName1, b1);
+        testRootNode.getSession().save();
+        testNode.setProperty(propertyName1, (Value) null);
+        testRootNode.getSession().save();
+        assertFalse("Removing decimal property with Node.setProperty(String, null) and Session.save()
not working",
+                testNode.hasProperty(propertyName1));
+    }
 }
\ No newline at end of file

Propchange: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SetPropertyDecimalTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SetValueDecimalTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SetValueDecimalTest.java?rev=790600&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SetValueDecimalTest.java
(added)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SetValueDecimalTest.java
Thu Jul  2 14:10:19 2009
@@ -0,0 +1,109 @@
+/*
+ * 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.test.api;
+
+import java.math.BigDecimal;
+
+import org.apache.jackrabbit.test.AbstractJCRTest;
+
+import javax.jcr.Property;
+import javax.jcr.Value;
+import javax.jcr.RepositoryException;
+import javax.jcr.Node;
+import javax.jcr.PathNotFoundException;
+
+/**
+ * Tests the various {@link Property#setValue(Value)} methods.
+ * <p>
+ * Configuration requirements:
+ * <p>
+ * 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 decimal property
+ * with name {@link #propertyName1}.
+ *
+ * @test
+ * @sources SetValueDoubleTest.java
+ * @executeClass org.apache.jackrabbit.test.api.SetValueDoubleTest
+ * @keywords level2
+ */
+public class SetValueDecimalTest extends AbstractJCRTest {
+
+    /**
+     * The decimal value
+     */
+    private Value value;
+
+    /**
+     * The node with the decimal property
+     */
+    private Node node;
+
+    /**
+     * The decimal property
+     */
+    private Property property1;
+
+    protected void setUp() throws Exception {
+        super.setUp();
+
+        // initialize some decimal value
+        value = superuser.getValueFactory().createValue(new BigDecimal("457841848484454646544884.484984949849498489771174"));
+
+        // create a new node under the testRootNode
+        node = testRootNode.addNode(nodeName1, testNodeType);
+
+        // abort test if the repository does not allow setting
+        // decimal properties on this node
+        ensureCanSetProperty(node, propertyName1, node.getSession().getValueFactory().createValue(new
BigDecimal(0)));
+
+        // create a new single-value property and save it
+        property1 = node.setProperty(propertyName1, new BigDecimal(0));
+        superuser.save();
+    }
+
+    protected void tearDown() throws Exception {
+        super.tearDown();
+    }
+
+    /**
+     * Test the persistence of a property modified with an decimal parameter and
+     * saved from the Session
+     */
+    public void testDoubleSession() throws RepositoryException {
+        property1.setValue(value);
+        superuser.save();
+        assertEquals("Decimal node property not saved", value.getDecimal(), property1.getValue().getDecimal());
+    }
+
+    /**
+     * Test the deletion of a property by assigning it a null value, saved from
+     * the Session
+     */
+    public void testRemoveDoubleSession() throws RepositoryException {
+        property1.setValue((Value) null);
+        superuser.save();
+
+        try {
+            node.getProperty(propertyName1);
+            fail("The property should not exist anymore, as a null Decimal has been assigned");
+        } catch (PathNotFoundException e) {
+            //success : the property has been deleted by assigning it a null value
+        }
+    }
+
+}

Propchange: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SetValueDecimalTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/TestAll.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/TestAll.java?rev=790600&r1=790599&r2=790600&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/TestAll.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/TestAll.java
Thu Jul  2 14:10:19 2009
@@ -84,6 +84,7 @@
         suite.addTestSuite(SetValueBinaryTest.class);
         suite.addTestSuite(SetValueBooleanTest.class);
         suite.addTestSuite(SetValueDateTest.class);
+        suite.addTestSuite(SetValueDecimalTest.class);
         suite.addTestSuite(SetValueDoubleTest.class);
         suite.addTestSuite(SetValueLongTest.class);
         suite.addTestSuite(SetValueReferenceTest.class);



Mime
View raw message