You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by ju...@apache.org on 2012/04/11 13:38:12 UTC

svn commit: r1324710 - in /jackrabbit/oak/trunk: oak-core/src/test/java/org/apache/jackrabbit/mk/api/ oak-core/src/test/java/org/apache/jackrabbit/mk/simple/ oak-it/mk/src/main/java/org/apache/jackrabbit/mk/test/ oak-it/mk/src/test/java/ oak-it/mk/src/...

Author: jukka
Date: Wed Apr 11 11:38:11 2012
New Revision: 1324710

URL: http://svn.apache.org/viewvc?rev=1324710&view=rev
Log:
OAK-12: Implement a test suite for the MicroKernel

Move MicroKernelIT to the oak-it-mk component and set up initial integration test suite.

Put the SimpleKernel-specific reorderNode() test to a separate SimpleKernelTest class.

Added:
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/mk/simple/
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/mk/simple/SimpleKernelTest.java   (with props)
    jackrabbit/oak/trunk/oak-it/mk/src/main/java/org/apache/jackrabbit/mk/test/MicroKernelIT.java   (contents, props changed)
      - copied, changed from r1324698, jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/mk/api/MicroKernelIT.java
    jackrabbit/oak/trunk/oak-it/mk/src/test/java/
    jackrabbit/oak/trunk/oak-it/mk/src/test/java/org/
    jackrabbit/oak/trunk/oak-it/mk/src/test/java/org/apache/
    jackrabbit/oak/trunk/oak-it/mk/src/test/java/org/apache/jackrabbit/
    jackrabbit/oak/trunk/oak-it/mk/src/test/java/org/apache/jackrabbit/mk/
    jackrabbit/oak/trunk/oak-it/mk/src/test/java/org/apache/jackrabbit/mk/test/
    jackrabbit/oak/trunk/oak-it/mk/src/test/java/org/apache/jackrabbit/mk/test/EverythingIT.java   (with props)
    jackrabbit/oak/trunk/oak-it/mk/src/test/java/org/apache/jackrabbit/mk/test/MicroKernelImplFixture.java   (with props)
    jackrabbit/oak/trunk/oak-it/mk/src/test/resources/META-INF/
    jackrabbit/oak/trunk/oak-it/mk/src/test/resources/META-INF/services/
    jackrabbit/oak/trunk/oak-it/mk/src/test/resources/META-INF/services/org.apache.jackrabbit.mk.test.MicroKernelFixture
Removed:
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/mk/api/MicroKernelIT.java
Modified:
    jackrabbit/oak/trunk/oak-it/mk/src/main/java/org/apache/jackrabbit/mk/test/AbstractMicroKernelIT.java

Added: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/mk/simple/SimpleKernelTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/mk/simple/SimpleKernelTest.java?rev=1324710&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/mk/simple/SimpleKernelTest.java (added)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/mk/simple/SimpleKernelTest.java Wed Apr 11 11:38:11 2012
@@ -0,0 +1,37 @@
+/*
+ * 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 org.apache.jackrabbit.mk.simple;
+
+import org.apache.jackrabbit.mk.api.MicroKernel;
+import org.junit.Test;
+
+public class SimpleKernelTest {
+
+    private final MicroKernel mk = new SimpleKernelImpl("mem:SimpleKernelTest");
+
+    @Test
+    public void reorderNode() {
+        String head = mk.getHeadRevision();
+        String node = "reorderNode_" + System.currentTimeMillis();
+        head = mk.commit("/", "+\"" + node + "\" : {\"a\":{}, \"b\":{}, \"c\":{}}", head, "");
+        // System.out.println(mk.getNodes('/' + node, head).replaceAll("\"", "").replaceAll(":childNodeCount:.", ""));
+
+        head = mk.commit("/", ">\"" + node + "/a\" : {\"before\":\"" + node + "/c\"}", head, "");
+        // System.out.println(mk.getNodes('/' + node, head).replaceAll("\"", "").replaceAll(":childNodeCount:.", ""));
+    }
+
+}

Propchange: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/mk/simple/SimpleKernelTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: jackrabbit/oak/trunk/oak-it/mk/src/main/java/org/apache/jackrabbit/mk/test/AbstractMicroKernelIT.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-it/mk/src/main/java/org/apache/jackrabbit/mk/test/AbstractMicroKernelIT.java?rev=1324710&r1=1324709&r2=1324710&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-it/mk/src/main/java/org/apache/jackrabbit/mk/test/AbstractMicroKernelIT.java (original)
+++ jackrabbit/oak/trunk/oak-it/mk/src/main/java/org/apache/jackrabbit/mk/test/AbstractMicroKernelIT.java Wed Apr 11 11:38:11 2012
@@ -37,15 +37,14 @@ public abstract class AbstractMicroKerne
      * @return available {@link MicroKernelFixture} services
      */
     @Parameters
-    public static Collection<MicroKernelFixture> loadFixtures() {
-        Collection<MicroKernelFixture> fixtures =
-                new ArrayList<MicroKernelFixture>();
+    public static Collection<Object[]> loadFixtures() {
+        Collection<Object[]> fixtures = new ArrayList<Object[]>();
 
         Class<MicroKernelFixture> iface = MicroKernelFixture.class;
         ServiceLoader<MicroKernelFixture> loader =
                 ServiceLoader.load(iface, iface.getClassLoader());
         for (MicroKernelFixture fixture : loader) {
-            fixtures.add(fixture);
+            fixtures.add(new Object[] { fixture });
         }
 
         return fixtures;
@@ -90,6 +89,17 @@ public abstract class AbstractMicroKerne
     public void setUp() {
         fixture.setUpCluster(mks);
         mk = mks[0];
+        addInitialTestContent();
+    }
+
+    /**
+     * Adds initial content used by the test case. This method is
+     * called by the {@link #setUp()} method after the {@link MicroKernel}
+     * cluster has been set up and before the actual test is run.
+     * The default implementation does nothing, but subclasses can
+     * override this method to perform extra initialization.
+     */
+    protected void addInitialTestContent() {
     }
 
     /**

Copied: jackrabbit/oak/trunk/oak-it/mk/src/main/java/org/apache/jackrabbit/mk/test/MicroKernelIT.java (from r1324698, jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/mk/api/MicroKernelIT.java)
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-it/mk/src/main/java/org/apache/jackrabbit/mk/test/MicroKernelIT.java?p2=jackrabbit/oak/trunk/oak-it/mk/src/main/java/org/apache/jackrabbit/mk/test/MicroKernelIT.java&p1=jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/mk/api/MicroKernelIT.java&r1=1324698&r2=1324710&rev=1324710&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/mk/api/MicroKernelIT.java (original)
+++ jackrabbit/oak/trunk/oak-it/mk/src/main/java/org/apache/jackrabbit/mk/test/MicroKernelIT.java Wed Apr 11 11:38:11 2012
@@ -14,11 +14,11 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.jackrabbit.mk.api;
+package org.apache.jackrabbit.mk.test;
 
 import junit.framework.Assert;
-import org.apache.jackrabbit.mk.MultiMkTestBase;
-import org.junit.Before;
+
+import org.apache.jackrabbit.mk.api.MicroKernelException;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.junit.runners.Parameterized;
@@ -29,22 +29,19 @@ import static org.junit.Assert.assertTru
 import static org.junit.Assert.fail;
 
 @RunWith(Parameterized.class)
-public class MicroKernelIT extends MultiMkTestBase {
+public class MicroKernelIT extends AbstractMicroKernelIT {
 
-    public MicroKernelIT(String url) {
-        super(url);
+    public MicroKernelIT(MicroKernelFixture fixture) {
+        super(fixture, 1);
     }
 
-    @Before
-    public void setUp() throws Exception {
-        super.setUp();
-
-        String head = mk.getHeadRevision();
+    @Override
+    protected void addInitialTestContent() {
         mk.commit("/", "+\"test\" : {" +
                 "\"stringProp\":\"stringVal\"," +
                 "\"intProp\":42," +
                 "\"floatProp\":42.2," +
-                "\"multiIntProp\":[1,2,3]} ", head, "");
+                "\"multiIntProp\":[1,2,3]}", null, "");
     }
 
     @Test
@@ -246,20 +243,6 @@ public class MicroKernelIT extends Multi
     }
 
     @Test
-    public void reorderNode() {
-        if (!isSimpleKernel(mk)) {
-            return;
-        }
-        String head = mk.getHeadRevision();
-        String node = "reorderNode_" + System.currentTimeMillis();
-        head = mk.commit("/", "+\"" + node + "\" : {\"a\":{}, \"b\":{}, \"c\":{}}", head, "");
-        // System.out.println(mk.getNodes('/' + node, head).replaceAll("\"", "").replaceAll(":childNodeCount:.", ""));
-
-        head = mk.commit("/", ">\"" + node + "/a\" : {\"before\":\"" + node + "/c\"}", head, "");
-        // System.out.println(mk.getNodes('/' + node, head).replaceAll("\"", "").replaceAll(":childNodeCount:.", ""));
-    }
-
-    @Test
     public void removeProperty() {
         String head = mk.getHeadRevision();
         long t = System.currentTimeMillis();

Propchange: jackrabbit/oak/trunk/oak-it/mk/src/main/java/org/apache/jackrabbit/mk/test/MicroKernelIT.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/oak/trunk/oak-it/mk/src/test/java/org/apache/jackrabbit/mk/test/EverythingIT.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-it/mk/src/test/java/org/apache/jackrabbit/mk/test/EverythingIT.java?rev=1324710&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-it/mk/src/test/java/org/apache/jackrabbit/mk/test/EverythingIT.java (added)
+++ jackrabbit/oak/trunk/oak-it/mk/src/test/java/org/apache/jackrabbit/mk/test/EverythingIT.java Wed Apr 11 11:38:11 2012
@@ -0,0 +1,27 @@
+/*
+ * 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 org.apache.jackrabbit.mk.test;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+@RunWith(Suite.class)
+@Suite.SuiteClasses({
+    MicroKernelIT.class
+})
+public class EverythingIT {
+}

Propchange: jackrabbit/oak/trunk/oak-it/mk/src/test/java/org/apache/jackrabbit/mk/test/EverythingIT.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/oak/trunk/oak-it/mk/src/test/java/org/apache/jackrabbit/mk/test/MicroKernelImplFixture.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-it/mk/src/test/java/org/apache/jackrabbit/mk/test/MicroKernelImplFixture.java?rev=1324710&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-it/mk/src/test/java/org/apache/jackrabbit/mk/test/MicroKernelImplFixture.java (added)
+++ jackrabbit/oak/trunk/oak-it/mk/src/test/java/org/apache/jackrabbit/mk/test/MicroKernelImplFixture.java Wed Apr 11 11:38:11 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 org.apache.jackrabbit.mk.test;
+
+import org.apache.jackrabbit.mk.api.MicroKernel;
+import org.apache.jackrabbit.mk.core.MicroKernelImpl;
+
+public class MicroKernelImplFixture implements MicroKernelFixture {
+
+    @Override
+    public void setUpCluster(MicroKernel[] cluster) {
+        MicroKernel mk = new MicroKernelImpl();
+        for (int i = 0; i < cluster.length; i++) {
+            cluster[i] = mk;
+        }
+    }
+
+    @Override
+    public void syncMicroKernelCluster(MicroKernel... nodes) {
+    }
+
+    @Override
+    public void tearDownCluster(MicroKernel[] cluster) {
+    }
+
+}

Propchange: jackrabbit/oak/trunk/oak-it/mk/src/test/java/org/apache/jackrabbit/mk/test/MicroKernelImplFixture.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/oak/trunk/oak-it/mk/src/test/resources/META-INF/services/org.apache.jackrabbit.mk.test.MicroKernelFixture
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-it/mk/src/test/resources/META-INF/services/org.apache.jackrabbit.mk.test.MicroKernelFixture?rev=1324710&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-it/mk/src/test/resources/META-INF/services/org.apache.jackrabbit.mk.test.MicroKernelFixture (added)
+++ jackrabbit/oak/trunk/oak-it/mk/src/test/resources/META-INF/services/org.apache.jackrabbit.mk.test.MicroKernelFixture Wed Apr 11 11:38:11 2012
@@ -0,0 +1,16 @@
+#  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.
+
+org.apache.jackrabbit.mk.test.MicroKernelImplFixture