jackrabbit-oak-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1300978 - in /jackrabbit/oak/trunk/oak-jcr/src: main/java/org/apache/jackrabbit/oak/jcr/util/Arrays.java test/java/org/apache/jackrabbit/oak/jcr/RepositoryTest.java test/java/util/ test/java/util/NumberStream.java
Date Thu, 15 Mar 2012 13:46:18 GMT
Author: mduerig
Date: Thu Mar 15 13:46:18 2012
New Revision: 1300978

URL: http://svn.apache.org/viewvc?rev=1300978&view=rev
Log:
OAK-5: JCR bindings for Oak
add additional test cases

Added:
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/util/Arrays.java
      - copied, changed from r1299739, jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/utils/Arrays.java
    jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/RepositoryTest.java
      - copied, changed from r1299713, jackrabbit/sandbox/jackrabbit-microkernel/src/test/java/org/apache/jackrabbit/RepositoryTest.java
    jackrabbit/oak/trunk/oak-jcr/src/test/java/util/
    jackrabbit/oak/trunk/oak-jcr/src/test/java/util/NumberStream.java

Copied: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/util/Arrays.java
(from r1299739, jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/utils/Arrays.java)
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/util/Arrays.java?p2=jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/util/Arrays.java&p1=jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/utils/Arrays.java&r1=1299739&r2=1300978&rev=1300978&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/utils/Arrays.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/util/Arrays.java
Thu Mar 15 13:46:18 2012
@@ -17,7 +17,7 @@
  * under the License.
  */
 
-package org.apache.jackrabbit.utils;
+package org.apache.jackrabbit.oak.jcr.util;
 
 import java.util.ArrayList;
 import java.util.HashSet;

Copied: jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/RepositoryTest.java
(from r1299713, jackrabbit/sandbox/jackrabbit-microkernel/src/test/java/org/apache/jackrabbit/RepositoryTest.java)
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/RepositoryTest.java?p2=jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/RepositoryTest.java&p1=jackrabbit/sandbox/jackrabbit-microkernel/src/test/java/org/apache/jackrabbit/RepositoryTest.java&r1=1299713&r2=1300978&rev=1300978&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-microkernel/src/test/java/org/apache/jackrabbit/RepositoryTest.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/RepositoryTest.java
Thu Mar 15 13:46:18 2012
@@ -16,20 +16,17 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.jackrabbit;
+package org.apache.jackrabbit.oak.jcr;
 
-import org.apache.jackrabbit.configuration.RepositoryConfiguration;
+import org.apache.jackrabbit.commons.JcrUtils;
 import org.apache.jackrabbit.mk.MicroKernelFactory;
 import org.apache.jackrabbit.mk.api.MicroKernel;
-import org.apache.jackrabbit.util.Loop;
-import org.apache.jackrabbit.util.NumberStream;
-import org.apache.jackrabbit.utils.Arrays;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Ignore;
 import org.junit.Test;
+import util.NumberStream;
 
-import javax.imageio.spi.ServiceRegistry;
 import javax.jcr.Binary;
 import javax.jcr.GuestCredentials;
 import javax.jcr.Item;
@@ -43,7 +40,6 @@ import javax.jcr.PropertyIterator;
 import javax.jcr.PropertyType;
 import javax.jcr.Repository;
 import javax.jcr.RepositoryException;
-import javax.jcr.RepositoryFactory;
 import javax.jcr.Session;
 import javax.jcr.Value;
 import javax.jcr.nodetype.NodeType;
@@ -59,9 +55,7 @@ import java.io.InputStream;
 import java.math.BigDecimal;
 import java.util.ArrayList;
 import java.util.Calendar;
-import java.util.HashMap;
 import java.util.HashSet;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Set;
 import java.util.concurrent.Callable;
@@ -72,7 +66,8 @@ import java.util.concurrent.TimeUnit;
 import java.util.concurrent.TimeoutException;
 
 import static java.util.Arrays.asList;
-import static org.apache.jackrabbit.utils.Arrays.contains;
+import static org.apache.jackrabbit.oak.jcr.util.Arrays.contains;
+import static org.apache.jackrabbit.oak.jcr.util.Arrays.toSet;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
@@ -81,8 +76,7 @@ import static org.junit.Assert.fail;
 
 public class RepositoryTest {
     private static final String NODE_STATE_CACHE_SIZE = "65536";
-    private static final String URL = "fs:target/repository-test/repository";
-    // private static final String URL = "mem:";
+    private static final String URL = "simple:target/repository-test/repository";
 
     private static final String TEST_NODE = "test_node";
     private static final String TEST_PATH = '/' + TEST_NODE;
@@ -875,7 +869,7 @@ public class RepositoryTest {
         }
     }
     
-    @Test 
+    @Test
     public void transientChanges() throws RepositoryException {
         Node parentNode = getNode(TEST_PATH);
 
@@ -1360,15 +1354,15 @@ public class RepositoryTest {
     @Test
     @Ignore // todo implement observation
     public void observation() throws RepositoryException {
-        final Set<String> addNodes = Arrays.toSet(
+        final Set<String> addNodes = toSet(
                 TEST_PATH + "/1",
                 TEST_PATH + "/2",
                 TEST_PATH + "/3");
 
-        final Set<String> removeNodes = Arrays.toSet(
+        final Set<String> removeNodes = toSet(
                 TEST_PATH + "/2");
 
-        final Set<String> addProperties = Arrays.toSet(
+        final Set<String> addProperties = toSet(
                 TEST_PATH + "/property",
                 TEST_PATH + "/prop0",
                 TEST_PATH + "/1/prop1",
@@ -1378,10 +1372,10 @@ public class RepositoryTest {
                 TEST_PATH + "/3/jcr:primaryType",
                 TEST_PATH + "/3/prop3");
 
-        final Set<String> setProperties = Arrays.toSet(
+        final Set<String> setProperties = toSet(
                 TEST_PATH + "/1/prop1");
 
-        final Set<String> removeProperties = Arrays.toSet(
+        final Set<String> removeProperties = toSet(
                 TEST_PATH + "/1/prop2");
 
         final List<Event> failedEvents = new ArrayList<Event>();
@@ -1448,27 +1442,25 @@ public class RepositoryTest {
         n.getNode("2").remove();
         getSession().save();
 
-        new Loop() { @Override public void test() {
-            assertTrue(failedEvents.isEmpty());
-            assertTrue(addNodes.isEmpty());
-            assertTrue(removeNodes.isEmpty());
-            assertTrue(addProperties.isEmpty());
-            assertTrue(removeProperties.isEmpty());
-            assertTrue(setProperties.isEmpty());
-        }};
+        assertTrue(failedEvents.isEmpty());
+        assertTrue(addNodes.isEmpty());
+        assertTrue(removeNodes.isEmpty());
+        assertTrue(addProperties.isEmpty());
+        assertTrue(removeProperties.isEmpty());
+        assertTrue(setProperties.isEmpty());
     }
 
     @Test
     @Ignore // todo implement observation
     public void observation2() throws RepositoryException {
-        final Set<String> addNodes = Arrays.toSet(
+        final Set<String> addNodes = toSet(
                 TEST_PATH + "/1",
                 TEST_PATH + "/2");
 
-        final Set<String> removeNodes = Arrays.toSet(
+        final Set<String> removeNodes = toSet(
                 TEST_PATH + "/1");
 
-        final Set<String> addProperties = Arrays.toSet(
+        final Set<String> addProperties = toSet(
                 TEST_PATH + "/1/jcr:primaryType",
                 TEST_PATH + "/2/jcr:primaryType");
 
@@ -1520,12 +1512,10 @@ public class RepositoryTest {
         n.getNode("1").remove();
         getSession().save();
 
-        new Loop() { @Override public void test() {
-            assertTrue(failedEvents.isEmpty());
-            assertTrue(addNodes.isEmpty());
-            assertTrue(removeNodes.isEmpty());
-            assertTrue(addProperties.isEmpty());
-        }};
+        assertTrue(failedEvents.isEmpty());
+        assertTrue(addNodes.isEmpty());
+        assertTrue(removeNodes.isEmpty());
+        assertTrue(addProperties.isEmpty());
     }
 
     @Test
@@ -1716,14 +1706,7 @@ public class RepositoryTest {
 
     private Repository getRepository() throws RepositoryException {
         if (repository == null) {
-            Iterator<RepositoryFactory> factories = ServiceRegistry.lookupProviders(RepositoryFactory.class);
-            while (repository == null && factories.hasNext()) {
-                RepositoryFactory factory = factories.next();
-                repository = factory.getRepository(new HashMap<String, String>() {{
-                    put(RepositoryConfiguration.MICROKERNEL_URL, URL);
-                    put(RepositoryConfiguration.NODE_STATE_CACHE_SIZE, NODE_STATE_CACHE_SIZE);
-                }}); 
-            }
+            repository = JcrUtils.getRepository("jcr-oak://inmemory/CRUDTest");
         }
 
         return repository;

Added: jackrabbit/oak/trunk/oak-jcr/src/test/java/util/NumberStream.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/test/java/util/NumberStream.java?rev=1300978&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/test/java/util/NumberStream.java (added)
+++ jackrabbit/oak/trunk/oak-jcr/src/test/java/util/NumberStream.java Thu Mar 15 13:46:18
2012
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package util;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+public class NumberStream extends InputStream {
+    private final int limit;
+    private int counter;
+
+    public NumberStream(int limit) {
+        this.limit = limit;
+    }
+
+    @Override
+    public int read() throws IOException {
+        return counter < limit
+            ? counter++ & 0xff
+            : -1;
+    }
+
+}



Mime
View raw message