jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1133005 - in /jackrabbit/sandbox/spi2microkernel/src: main/java/org/apache/jackrabbit/spi2microkernel/util/Values.java test/java/org/apache/jackrabbit/spi2microkernel/RepositoryTest.java
Date Tue, 07 Jun 2011 13:31:57 GMT
Author: mduerig
Date: Tue Jun  7 13:31:56 2011
New Revision: 1133005

URL: http://svn.apache.org/viewvc?rev=1133005&view=rev
Log:
spi2microkernel prototype (WIP)
write support: addProperty

Modified:
    jackrabbit/sandbox/spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/util/Values.java
    jackrabbit/sandbox/spi2microkernel/src/test/java/org/apache/jackrabbit/spi2microkernel/RepositoryTest.java

Modified: jackrabbit/sandbox/spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/util/Values.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/util/Values.java?rev=1133005&r1=1133004&r2=1133005&view=diff
==============================================================================
--- jackrabbit/sandbox/spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/util/Values.java
(original)
+++ jackrabbit/sandbox/spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/util/Values.java
Tue Jun  7 13:31:56 2011
@@ -88,20 +88,19 @@ public final class Values {
                 return JsonBuilder.escape(value.getString());
 
             case PropertyType.LONG:
+            case PropertyType.DOUBLE:
+            case PropertyType.BOOLEAN:
+            case PropertyType.DECIMAL:
                 return value.getString();
 
-            // todo implement other types
-            case PropertyType.BINARY:
-            case PropertyType.DOUBLE:
             case PropertyType.DATE:
-            case PropertyType.BOOLEAN:
+            case PropertyType.BINARY:
             case PropertyType.NAME:
             case PropertyType.PATH:
             case PropertyType.REFERENCE:
             case PropertyType.WEAKREFERENCE:
             case PropertyType.URI:
-            case PropertyType.DECIMAL:
-            default:
+            default:  // todo implement support for all value types
                 throw new UnsupportedRepositoryOperationException("Cannot handle value of
type " +
                         PropertyType.nameFromValue(value.getType()));
         }

Modified: jackrabbit/sandbox/spi2microkernel/src/test/java/org/apache/jackrabbit/spi2microkernel/RepositoryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/spi2microkernel/src/test/java/org/apache/jackrabbit/spi2microkernel/RepositoryTest.java?rev=1133005&r1=1133004&r2=1133005&view=diff
==============================================================================
--- jackrabbit/sandbox/spi2microkernel/src/test/java/org/apache/jackrabbit/spi2microkernel/RepositoryTest.java
(original)
+++ jackrabbit/sandbox/spi2microkernel/src/test/java/org/apache/jackrabbit/spi2microkernel/RepositoryTest.java
Tue Jun  7 13:31:56 2011
@@ -36,6 +36,7 @@ import javax.jcr.RepositoryFactory;
 import javax.jcr.Session;
 import javax.jcr.Value;
 import java.io.File;
+import java.math.BigDecimal;
 import java.util.Collections;
 import java.util.HashSet;
 import java.util.Iterator;
@@ -225,13 +226,34 @@ public class RepositoryTest {
         addProperty(parentNode, "string", getSession().getValueFactory().createValue("string
value"));
     }
 
-    @Test
     @Ignore  // todo fix in microkernel
+    @Test
     public void addLongProperty() throws RepositoryException {
         Node parentNode = getNode("/bar");
         addProperty(parentNode, "long", getSession().getValueFactory().createValue(42L));
     }
 
+    @Ignore  // todo fix in microkernel
+    @Test
+    public void addDoubleProperty() throws RepositoryException {
+        Node parentNode = getNode("/bar");
+        addProperty(parentNode, "double", getSession().getValueFactory().createValue(42.2D));
+    }
+
+    @Ignore  // todo fix in microkernel
+    @Test
+    public void addBooleanProperty() throws RepositoryException {
+        Node parentNode = getNode("/bar");
+        addProperty(parentNode, "boolean", getSession().getValueFactory().createValue(true));
+    }
+
+    @Ignore  // todo fix in microkernel
+    @Test
+    public void addDecimalProperty() throws RepositoryException {
+        Node parentNode = getNode("/bar");
+        addProperty(parentNode, "decimal", getSession().getValueFactory().createValue(BigDecimal.valueOf(21)));
+    }
+
     //------------------------------------------< private >---
 
     private void addProperty(Node parentNode, String name, Value value) throws RepositoryException
{
@@ -244,7 +266,9 @@ public class RepositoryTest {
         Session session2 = getRepository().login();
         try {
             assertTrue(session2.propertyExists(propertyPath));
-            assertEquals(value, session2.getProperty(propertyPath).getValue());
+            Value value2 = session2.getProperty(propertyPath).getValue();
+            assertEquals(value.getType(), value2.getType());
+            assertEquals(value, value2);
         }
         finally {
             session2.logout();



Mime
View raw message