jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1133324 - in /jackrabbit/sandbox/spi2microkernel/src: main/java/org/apache/jackrabbit/spi2microkernel/ test/java/org/apache/jackrabbit/spi2microkernel/
Date Wed, 08 Jun 2011 10:05:02 GMT
Author: mduerig
Date: Wed Jun  8 10:05:02 2011
New Revision: 1133324

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

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

Modified: jackrabbit/sandbox/spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/RepositoryServiceImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/RepositoryServiceImpl.java?rev=1133324&r1=1133323&r2=1133324&view=diff
==============================================================================
--- jackrabbit/sandbox/spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/RepositoryServiceImpl.java
(original)
+++ jackrabbit/sandbox/spi2microkernel/src/main/java/org/apache/jackrabbit/spi2microkernel/RepositoryServiceImpl.java
Wed Jun  8 10:05:02 2011
@@ -390,13 +390,11 @@ public class RepositoryServiceImpl exten
         }
 
         public void setValue(PropertyId propertyId, QValue value) throws RepositoryException
{
-            // todo implement setValue
-            throw new UnsupportedRepositoryOperationException("setValue");
+            addProperty(propertyId.getParentId(), propertyId.getName(), value);
         }
 
         public void setValue(PropertyId propertyId, QValue[] values) throws RepositoryException
{
-            // todo implement setValue
-            throw new UnsupportedRepositoryOperationException("setValue");
+            addProperty(propertyId.getParentId(), propertyId.getName(), values);
         }
 
         public void remove(ItemId itemId) throws RepositoryException {

Modified: jackrabbit/sandbox/spi2microkernel/src/test/java/org/apache/jackrabbit/spi2microkernel/MicrokernelTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/spi2microkernel/src/test/java/org/apache/jackrabbit/spi2microkernel/MicrokernelTest.java?rev=1133324&r1=1133323&r2=1133324&view=diff
==============================================================================
--- jackrabbit/sandbox/spi2microkernel/src/test/java/org/apache/jackrabbit/spi2microkernel/MicrokernelTest.java
(original)
+++ jackrabbit/sandbox/spi2microkernel/src/test/java/org/apache/jackrabbit/spi2microkernel/MicrokernelTest.java
Wed Jun  8 10:05:02 2011
@@ -98,6 +98,31 @@ public class MicrokernelTest {
     }
 
     @Test
+    public void testAddItemsIncrementally() {
+        MicroKernel mk = getMicroKernel();
+        String head = mk.getHeadRevision();
+
+        long millis = System.currentTimeMillis();
+        String node = "n_" + millis;
+
+        head = mk.commit("/",
+                '+' + node + " : {} \r" +
+                '+' + node + "/child1 : {} \r" +
+                '+' + node + "/child2 : {} \r" +
+                '+' + node + "/child1/grandchild11 : {} \r" +
+                '^' + node + "/prop1 : 41\r" +
+                '^' + node + "/child1/prop2 : 42\r" +
+                '^' + node + "/child1/grandchild11/prop3 : 43",
+                head);
+
+        String json = mk.getNodes('/' + node, 2, head);
+        assertEquals("{\":name\":\"" + node + "\",\"prop1\":\"41\",\":childNodeCount\":2,"
+
+                "\"child1\":{\":name\":\"child1\",\"prop2\":\"42\",\":childNodeCount\":1,"
+
+                "\"grandchild11\":{\":name\":\"grandchild11\",\"prop3\":\"43\",\":childNodeCount\":0}},"
+
+                "\"child2\":{\":name\":\"child2\",\":childNodeCount\":0}}", json);
+    }
+
+    @Test
     public void testStringProperty() throws ParseException {
         MicroKernel mk = getMicroKernel();
         String head = mk.getHeadRevision();

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=1133324&r1=1133323&r2=1133324&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  8 10:05:02 2011
@@ -256,7 +256,7 @@ public class RepositoryTest {
 
     @Ignore  // todo fix in microkernel
     @Test
-    public void setMultiValuedProperty() throws RepositoryException {
+    public void addMultiValuedProperty() throws RepositoryException {
         Node parentNode = getNode("/bar");
         Value[] values = new Value[2];
         values[0] = getSession().getValueFactory().createValue("one");
@@ -267,7 +267,56 @@ public class RepositoryTest {
 
         Session session2 = getRepository().login();
         try {
-            Property property = session2.getProperty("/bar/mv");
+            Property property = session2.getProperty("/bar/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 setStringProperty() throws RepositoryException {
+        Node parentNode = getNode("/bar");
+        addProperty(parentNode, "string2", getSession().getValueFactory().createValue("string
value"));
+
+        Property property = parentNode.getProperty("string2");
+        property.setValue("new value");
+        property.getSession().save();
+
+        Session session2 = getRepository().login();
+        try {
+            Property property2 = session2.getProperty("/bar/string2");
+            assertEquals("new value", property2.getString());
+        }
+        finally {
+            session2.logout();
+        }
+    }
+
+    @Ignore  // todo fix in microkernel
+    @Test
+    public void setMultiValuedProperty() throws RepositoryException {
+        Node parentNode = getNode("/bar");
+        Value[] values = new Value[2];
+        values[0] = getSession().getValueFactory().createValue("one");
+        values[1] = getSession().getValueFactory().createValue("two");
+
+        parentNode.setProperty("multi string2", values);
+        parentNode.getSession().save();
+
+        values[0] = getSession().getValueFactory().createValue("eins");
+        values[1] = getSession().getValueFactory().createValue("zwei");
+        parentNode.setProperty("multi string2", values);
+        parentNode.getSession().save();
+
+        Session session2 = getRepository().login();
+        try {
+            Property property = session2.getProperty("/bar/multi string2");
             assertTrue(property.isMultiple());
             Value[] values2 = property.getValues();
             assertEquals(2, values.length);



Mime
View raw message