jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1133341 - /jackrabbit/sandbox/spi2microkernel/src/test/java/org/apache/jackrabbit/spi2microkernel/RepositoryTest.java
Date Wed, 08 Jun 2011 10:58:43 GMT
Author: mduerig
Date: Wed Jun  8 10:58:43 2011
New Revision: 1133341

URL: http://svn.apache.org/viewvc?rev=1133341&view=rev
Log:
spi2microkernel prototype (WIP)
write support: improved 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=1133341&r1=1133340&r2=1133341&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:58:43 2011
@@ -47,7 +47,9 @@ import static org.junit.Assert.*;
 
 public class RepositoryTest {
     private static final File REPO_HOME_DIR = new File("target/repository-test/repository");
-    
+
+    private final String testNode = "node_" + System.currentTimeMillis();
+    private final String testPath = '/' + testNode;
     private Repository repository;
     private Session session;
 
@@ -57,7 +59,7 @@ public class RepositoryTest {
         String head = mk.getHeadRevision();
 
         if (!mk.nodeExists("/default", head)) {
-            mk.commit("/",
+            head = mk.commit("/",
                 "+default : {" +
                     "\"{}foo\" : {" +
                         "\"{}stringProp\":\"stringVal\"," +
@@ -65,6 +67,10 @@ public class RepositoryTest {
                         "\"{}mvProp\":[1,2,3]} " +
                     "\"{}bar\" : {}}", head);
         }
+
+        if (!mk.nodeExists("/default/{}" + testNode, head)) {
+            mk.commit("/default", "+{}" + testNode + " : {}", head);
+        }
     }
 
     @After
@@ -168,7 +174,7 @@ public class RepositoryTest {
     }
 
     @Test(expected = PathNotFoundException.class)
-    public void getNonexNode() throws RepositoryException {
+    public void getNonExistingNode() throws RepositoryException {
         getNode("/qoo");
     }
 
@@ -205,15 +211,16 @@ public class RepositoryTest {
     @Test
     public void addNode() throws RepositoryException {
         Session session = getSession();
-        assertFalse(session.nodeExists("/bar/new"));
+        String newNode = testPath + "/new";
+        assertFalse(session.nodeExists(newNode));
 
-        Node node = getNode("/bar");
+        Node node = getNode(testPath);
         node.addNode("new");
         session.save();
 
         Session session2 = getRepository().login();
         try {
-            assertTrue(session2.nodeExists("/bar/new"));
+            assertTrue(session2.nodeExists(newNode));
         }
         finally {
             session2.logout();
@@ -222,42 +229,42 @@ public class RepositoryTest {
 
     @Test
     public void addStringProperty() throws RepositoryException {
-        Node parentNode = getNode("/bar");
+        Node parentNode = getNode(testPath);
         addProperty(parentNode, "string", getSession().getValueFactory().createValue("string
value"));
     }
 
     @Ignore  // todo fix in microkernel
     @Test
     public void addLongProperty() throws RepositoryException {
-        Node parentNode = getNode("/bar");
+        Node parentNode = getNode(testPath);
         addProperty(parentNode, "long", getSession().getValueFactory().createValue(42L));
     }
 
     @Ignore  // todo fix in microkernel
     @Test
     public void addDoubleProperty() throws RepositoryException {
-        Node parentNode = getNode("/bar");
+        Node parentNode = getNode(testPath);
         addProperty(parentNode, "double", getSession().getValueFactory().createValue(42.2D));
     }
 
     @Ignore  // todo fix in microkernel
     @Test
     public void addBooleanProperty() throws RepositoryException {
-        Node parentNode = getNode("/bar");
+        Node parentNode = getNode(testPath);
         addProperty(parentNode, "boolean", getSession().getValueFactory().createValue(true));
     }
 
     @Ignore  // todo fix in microkernel
     @Test
     public void addDecimalProperty() throws RepositoryException {
-        Node parentNode = getNode("/bar");
+        Node parentNode = getNode(testPath);
         addProperty(parentNode, "decimal", getSession().getValueFactory().createValue(BigDecimal.valueOf(21)));
     }
 
     @Ignore  // todo fix in microkernel
     @Test
     public void addMultiValuedProperty() throws RepositoryException {
-        Node parentNode = getNode("/bar");
+        Node parentNode = getNode(testPath);
         Value[] values = new Value[2];
         values[0] = getSession().getValueFactory().createValue("one");
         values[1] = getSession().getValueFactory().createValue("two");
@@ -267,7 +274,7 @@ public class RepositoryTest {
 
         Session session2 = getRepository().login();
         try {
-            Property property = session2.getProperty("/bar/multi string");
+            Property property = session2.getProperty(testPath + "/multi string");
             assertTrue(property.isMultiple());
             Value[] values2 = property.getValues();
             assertEquals(2, values.length);
@@ -281,16 +288,16 @@ public class RepositoryTest {
 
     @Test
     public void setStringProperty() throws RepositoryException {
-        Node parentNode = getNode("/bar");
-        addProperty(parentNode, "string2", getSession().getValueFactory().createValue("string
value"));
+        Node parentNode = getNode(testPath);
+        addProperty(parentNode, "string", getSession().getValueFactory().createValue("string
value"));
 
-        Property property = parentNode.getProperty("string2");
+        Property property = parentNode.getProperty("string");
         property.setValue("new value");
         property.getSession().save();
 
         Session session2 = getRepository().login();
         try {
-            Property property2 = session2.getProperty("/bar/string2");
+            Property property2 = session2.getProperty(testPath + "/string");
             assertEquals("new value", property2.getString());
         }
         finally {
@@ -301,7 +308,7 @@ public class RepositoryTest {
     @Ignore  // todo fix in microkernel
     @Test
     public void setMultiValuedProperty() throws RepositoryException {
-        Node parentNode = getNode("/bar");
+        Node parentNode = getNode(testPath);
         Value[] values = new Value[2];
         values[0] = getSession().getValueFactory().createValue("one");
         values[1] = getSession().getValueFactory().createValue("two");
@@ -316,7 +323,7 @@ public class RepositoryTest {
 
         Session session2 = getRepository().login();
         try {
-            Property property = session2.getProperty("/bar/multi string2");
+            Property property = session2.getProperty(testPath + "/multi string2");
             assertTrue(property.isMultiple());
             Value[] values2 = property.getValues();
             assertEquals(2, values.length);



Mime
View raw message