jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1136009 - /jackrabbit/sandbox/spi2microkernel/src/test/java/org/apache/jackrabbit/spi2microkernel/RepositoryTest.java
Date Wed, 15 Jun 2011 12:17:15 GMT
Author: mduerig
Date: Wed Jun 15 12:17:15 2011
New Revision: 1136009

URL: http://svn.apache.org/viewvc?rev=1136009&view=rev
Log:
spi2microkernel prototype (WIP)
value types: tests

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

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=1136009&r1=1136008&r2=1136009&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
Wed Jun 15 12:17:15 2011
@@ -238,12 +238,60 @@ public class RepositoryTest {
     }
 
     @Test
+    public void addMultiValuedString() throws RepositoryException {
+        Node parentNode = getNode(testPath);
+        Value[] values = new Value[2];
+        values[0] = getSession().getValueFactory().createValue("one");
+        values[1] = getSession().getValueFactory().createValue("two");
+
+        parentNode.setProperty("multi string", values);
+        parentNode.getSession().save();
+
+        Session session2 = getRepository().login();
+        try {
+            Property property = session2.getProperty(testPath + "/multi string");
+            assertTrue(property.isMultiple());
+            Value[] values2 = property.getValues();
+            assertEquals(2, values.length);
+            assertEquals(values[0], values2[0]);
+            assertEquals(values[1], values2[1]);
+        }
+        finally {
+            session2.logout();
+        }
+    }
+
+    @Test
     public void addLongProperty() throws RepositoryException {
         Node parentNode = getNode(testPath);
         addProperty(parentNode, "long", getSession().getValueFactory().createValue(42L));
     }
 
     @Test
+    public void addMultiValuedLong() throws RepositoryException {
+        Node parentNode = getNode(testPath);
+        Value[] values = new Value[2];
+        values[0] = getSession().getValueFactory().createValue(42L);
+        values[1] = getSession().getValueFactory().createValue(84L);
+
+        parentNode.setProperty("multi long", values);
+        parentNode.getSession().save();
+
+        Session session2 = getRepository().login();
+        try {
+            Property property = session2.getProperty(testPath + "/multi long");
+            assertTrue(property.isMultiple());
+            Value[] values2 = property.getValues();
+            assertEquals(2, values.length);
+            assertEquals(values[0], values2[0]);
+            assertEquals(values[1], values2[1]);
+        }
+        finally {
+            session2.logout();
+        }
+    }
+
+    @Test
     public void addDoubleProperty() throws RepositoryException {
         Node parentNode = getNode(testPath);
         addProperty(parentNode, "double", getSession().getValueFactory().createValue(42.2D));
@@ -251,30 +299,78 @@ public class RepositoryTest {
     }
 
     @Test
+    public void addMultiValuedDouble() throws RepositoryException {
+        Node parentNode = getNode(testPath);
+        Value[] values = new Value[2];
+        values[0] = getSession().getValueFactory().createValue(42.1d);
+        values[1] = getSession().getValueFactory().createValue(Double.NaN);
+
+        parentNode.setProperty("multi double", values);
+        parentNode.getSession().save();
+
+        Session session2 = getRepository().login();
+        try {
+            Property property = session2.getProperty(testPath + "/multi double");
+            assertTrue(property.isMultiple());
+            Value[] values2 = property.getValues();
+            assertEquals(2, values.length);
+            assertEquals(values[0], values2[0]);
+            assertEquals(values[1], values2[1]);
+        }
+        finally {
+            session2.logout();
+        }
+    }
+
+    @Test
     public void addBooleanProperty() throws RepositoryException {
         Node parentNode = getNode(testPath);
         addProperty(parentNode, "boolean", getSession().getValueFactory().createValue(true));
     }
 
     @Test
+    public void addMultiValuedBoolean() throws RepositoryException {
+        Node parentNode = getNode(testPath);
+        Value[] values = new Value[2];
+        values[0] = getSession().getValueFactory().createValue(true);
+        values[1] = getSession().getValueFactory().createValue(false);
+
+        parentNode.setProperty("multi boolean", values);
+        parentNode.getSession().save();
+
+        Session session2 = getRepository().login();
+        try {
+            Property property = session2.getProperty(testPath + "/multi boolean");
+            assertTrue(property.isMultiple());
+            Value[] values2 = property.getValues();
+            assertEquals(2, values.length);
+            assertEquals(values[0], values2[0]);
+            assertEquals(values[1], values2[1]);
+        }
+        finally {
+            session2.logout();
+        }
+    }
+
+    @Test
     public void addDecimalProperty() throws RepositoryException {
         Node parentNode = getNode(testPath);
         addProperty(parentNode, "decimal", getSession().getValueFactory().createValue(BigDecimal.valueOf(21)));
     }
 
     @Test
-    public void addMultiValuedProperty() throws RepositoryException {
+    public void addMultiValuedDecimal() throws RepositoryException {
         Node parentNode = getNode(testPath);
         Value[] values = new Value[2];
-        values[0] = getSession().getValueFactory().createValue("one");
-        values[1] = getSession().getValueFactory().createValue("two");
+        values[0] = getSession().getValueFactory().createValue(BigDecimal.valueOf(42));
+        values[1] = getSession().getValueFactory().createValue(BigDecimal.valueOf(99));
 
-        parentNode.setProperty("multi string", values);
+        parentNode.setProperty("multi decimal", values);
         parentNode.getSession().save();
 
         Session session2 = getRepository().login();
         try {
-            Property property = session2.getProperty(testPath + "/multi string");
+            Property property = session2.getProperty(testPath + "/multi decimal");
             assertTrue(property.isMultiple());
             Value[] values2 = property.getValues();
             assertEquals(2, values.length);



Mime
View raw message