jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1136019 - in /jackrabbit/sandbox/spi2microkernel/src: main/java/org/apache/jackrabbit/spi2microkernel/util/Values.java test/java/org/apache/jackrabbit/spi2microkernel/RepositoryTest.java
Date Wed, 15 Jun 2011 13:01:27 GMT
Author: mduerig
Date: Wed Jun 15 13:01:27 2011
New Revision: 1136019

URL: http://svn.apache.org/viewvc?rev=1136019&view=rev
Log:
spi2microkernel prototype (WIP)
value types: name, path

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=1136019&r1=1136018&r2=1136019&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
Wed Jun 15 13:01:27 2011
@@ -133,6 +133,28 @@ public final class Values {
         };
         put(TYPES[PropertyType.URI], valueFactory);
 
+        valueFactory = new ValueFactory() {
+            public QValue create(Object value) throws RepositoryException {
+                throw new RepositoryException("Invalid value " + value);
+            }
+
+            public QValue create(String value) throws RepositoryException {
+                return FACTORY.create(value, PropertyType.NAME);
+            }
+        };
+        put(TYPES[PropertyType.NAME], valueFactory);
+
+        valueFactory = new ValueFactory() {
+            public QValue create(Object value) throws RepositoryException {
+                throw new RepositoryException("Invalid value " + value);
+            }
+
+            public QValue create(String value) throws RepositoryException {
+                return FACTORY.create(value, PropertyType.PATH);
+            }
+        };
+        put(TYPES[PropertyType.PATH], valueFactory);
+
         // todo handle other value types
     }};
 
@@ -185,12 +207,12 @@ public final class Values {
             case PropertyType.DECIMAL:
             case PropertyType.DATE:
             case PropertyType.URI:
+            case PropertyType.NAME:
+            case PropertyType.PATH:
                 return typeEncode(type, value.getString());
 
             // todo implement support for the other value types
             case PropertyType.BINARY:
-            case PropertyType.NAME:
-            case PropertyType.PATH:
             case PropertyType.REFERENCE:
             case PropertyType.WEAKREFERENCE:
             default:

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=1136019&r1=1136018&r2=1136019&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 13:01:27 2011
@@ -428,12 +428,72 @@ public class RepositoryTest {
         values[0] = getSession().getValueFactory().createValue("http://www.day.com", PropertyType.URI);
         values[1] = getSession().getValueFactory().createValue("file://var/dam", PropertyType.URI);
 
-        parentNode.setProperty("multi date", values);
+        parentNode.setProperty("multi uri", values);
         parentNode.getSession().save();
 
         Session session2 = getRepository().login();
         try {
-            Property property = session2.getProperty(testPath + "/multi date");
+            Property property = session2.getProperty(testPath + "/multi uri");
+            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 addNameProperty() throws RepositoryException {
+        Node parentNode = getNode(testPath);
+        addProperty(parentNode, "name", getSession().getValueFactory().createValue("jcr:something",
PropertyType.NAME));
+    }
+
+    @Test
+    public void addMultiValuedName() throws RepositoryException {
+        Node parentNode = getNode(testPath);
+        Value[] values = new Value[2];
+        values[0] = getSession().getValueFactory().createValue("jcr:foo", PropertyType.NAME);
+        values[1] = getSession().getValueFactory().createValue("bar", PropertyType.NAME);
+
+        parentNode.setProperty("multi name", values);
+        parentNode.getSession().save();
+
+        Session session2 = getRepository().login();
+        try {
+            Property property = session2.getProperty(testPath + "/multi name");
+            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 addPathProperty() throws RepositoryException {
+        Node parentNode = getNode(testPath);
+        addProperty(parentNode, "path", getSession().getValueFactory().createValue("/jcr:foo/bar",
PropertyType.PATH));
+    }
+
+    @Test
+    public void addMultiValuedPath() throws RepositoryException {
+        Node parentNode = getNode(testPath);
+        Value[] values = new Value[2];
+        values[0] = getSession().getValueFactory().createValue("/nt:foo/jcr:bar", PropertyType.PATH);
+        values[1] = getSession().getValueFactory().createValue("/", PropertyType.PATH);
+
+        parentNode.setProperty("multi path", values);
+        parentNode.getSession().save();
+
+        Session session2 = getRepository().login();
+        try {
+            Property property = session2.getProperty(testPath + "/multi path");
             assertTrue(property.isMultiple());
             Value[] values2 = property.getValues();
             assertEquals(2, values.length);



Mime
View raw message