diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/NodeStoreFixture.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/NodeStoreFixture.java deleted file mode 100644 index c6eaea1..0000000 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/NodeStoreFixture.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * 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.oak; - -import java.io.IOException; - -import org.apache.jackrabbit.oak.plugins.document.DocumentMK; -import org.apache.jackrabbit.oak.plugins.document.DocumentNodeStore; -import org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore; -import org.apache.jackrabbit.oak.plugins.segment.SegmentNodeStore; -import org.apache.jackrabbit.oak.plugins.segment.memory.MemoryStore; -import org.apache.jackrabbit.oak.spi.state.NodeStore; - -/** - * NodeStore fixture for parametrized tests. - */ -public abstract class NodeStoreFixture { - - public static final NodeStoreFixture SEGMENT_MK = new NodeStoreFixture() { - @Override - public String toString() { - return "SegmentMK Fixture"; - } - - @Override - public NodeStore createNodeStore() { - try { - return new SegmentNodeStore(new MemoryStore()); - } catch (IOException e) { - throw new RuntimeException(e); - } - } - - @Override - public void dispose(NodeStore nodeStore) { - } - }; - - public static final NodeStoreFixture MONGO_NS = new NodeStoreFixture() { - @Override - public String toString() { - return "MongoNS Fixture"; - } - - @Override - public NodeStore createNodeStore() { - return new DocumentMK.Builder().getNodeStore(); - } - - @Override - public void dispose(NodeStore nodeStore) { - if (nodeStore instanceof DocumentNodeStore) { - ((DocumentNodeStore) nodeStore).dispose(); - } - } - }; - - public static final NodeStoreFixture MEMORY_NS = new NodeStoreFixture() { - @Override - public NodeStore createNodeStore() { - return new MemoryNodeStore(); - } - - @Override - public void dispose(NodeStore nodeStore) { } - }; - - public abstract NodeStore createNodeStore(); - - public abstract void dispose(NodeStore nodeStore); - -} diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/OakBaseTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/OakBaseTest.java index 0e380c8..3a767db 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/OakBaseTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/OakBaseTest.java @@ -16,11 +16,6 @@ */ package org.apache.jackrabbit.oak; -import static org.apache.jackrabbit.oak.commons.FixturesHelper.Fixture.DOCUMENT_NS; -import static org.apache.jackrabbit.oak.commons.FixturesHelper.Fixture.MEMORY_NS; -import static org.apache.jackrabbit.oak.commons.FixturesHelper.Fixture.SEGMENT_MK; - -import java.util.ArrayList; import java.util.Collection; import java.util.Set; @@ -28,6 +23,7 @@ import org.apache.jackrabbit.oak.api.ContentRepository; import org.apache.jackrabbit.oak.api.ContentSession; import org.apache.jackrabbit.oak.commons.FixturesHelper; import org.apache.jackrabbit.oak.commons.FixturesHelper.Fixture; +import org.apache.jackrabbit.oak.fixture.NodeStoreFixture; import org.apache.jackrabbit.oak.spi.security.OpenSecurityProvider; import org.apache.jackrabbit.oak.spi.state.NodeStore; import org.junit.After; @@ -46,20 +42,9 @@ public abstract class OakBaseTest { @Parameterized.Parameters(name="{0}") public static Collection fixtures() { - Collection result = new ArrayList(); - if (FIXTURES.contains(DOCUMENT_NS)) { - result.add(new Object[] { NodeStoreFixture.MONGO_NS }); - } - if (FIXTURES.contains(SEGMENT_MK)) { - result.add(new Object[] { NodeStoreFixture.SEGMENT_MK }); - } - if (FIXTURES.contains(MEMORY_NS)) { - result.add(new Object[] { NodeStoreFixture.MEMORY_NS }); - } - return result; + return NodeStoreFixture.asJunitParameters(FIXTURES); } - protected final NodeStoreFixture fixture; protected final NodeStore store; diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/api/ContentSessionTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/api/ContentSessionTest.java index f6ed5dd..bddd41d 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/api/ContentSessionTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/api/ContentSessionTest.java @@ -23,8 +23,8 @@ import java.io.IOException; import javax.jcr.NoSuchWorkspaceException; import javax.security.auth.login.LoginException; -import org.apache.jackrabbit.oak.NodeStoreFixture; import org.apache.jackrabbit.oak.OakBaseTest; +import org.apache.jackrabbit.oak.fixture.NodeStoreFixture; import org.junit.After; import org.junit.Before; import org.junit.Test; diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/api/RootTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/api/RootTest.java index 25cef9a..0daac28 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/api/RootTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/api/RootTest.java @@ -18,8 +18,8 @@ */ package org.apache.jackrabbit.oak.api; -import org.apache.jackrabbit.oak.NodeStoreFixture; import org.apache.jackrabbit.oak.OakBaseTest; +import org.apache.jackrabbit.oak.fixture.NodeStoreFixture; import org.junit.After; import org.junit.Before; import org.junit.Test; diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/api/TreeTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/api/TreeTest.java index a284b08..6552f39 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/api/TreeTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/api/TreeTest.java @@ -29,9 +29,10 @@ import java.util.Set; import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; import com.google.common.collect.Sets; -import org.apache.jackrabbit.oak.NodeStoreFixture; + import org.apache.jackrabbit.oak.Oak; import org.apache.jackrabbit.oak.OakBaseTest; +import org.apache.jackrabbit.oak.fixture.NodeStoreFixture; import org.apache.jackrabbit.oak.plugins.commit.AnnotatingConflictHandler; import org.apache.jackrabbit.oak.plugins.commit.ChildOrderConflictHandler; import org.apache.jackrabbit.oak.plugins.commit.ConflictValidatorProvider; diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/core/ImmutableRootTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/core/ImmutableRootTest.java index 2604698..446b773 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/core/ImmutableRootTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/core/ImmutableRootTest.java @@ -18,12 +18,12 @@ package org.apache.jackrabbit.oak.core; import java.io.ByteArrayInputStream; -import org.apache.jackrabbit.oak.NodeStoreFixture; import org.apache.jackrabbit.oak.OakBaseTest; import org.apache.jackrabbit.oak.api.CommitFailedException; import org.apache.jackrabbit.oak.api.ContentSession; import org.apache.jackrabbit.oak.api.Root; import org.apache.jackrabbit.oak.api.Tree; +import org.apache.jackrabbit.oak.fixture.NodeStoreFixture; import org.junit.Before; import org.junit.Test; diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/core/MutableTreeTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/core/MutableTreeTest.java index 346158b..bc0c100 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/core/MutableTreeTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/core/MutableTreeTest.java @@ -30,7 +30,7 @@ import java.util.HashSet; import java.util.Set; import com.google.common.collect.Sets; -import org.apache.jackrabbit.oak.NodeStoreFixture; + import org.apache.jackrabbit.oak.OakBaseTest; import org.apache.jackrabbit.oak.api.Blob; import org.apache.jackrabbit.oak.api.CommitFailedException; @@ -39,6 +39,7 @@ import org.apache.jackrabbit.oak.api.PropertyState; import org.apache.jackrabbit.oak.api.Root; import org.apache.jackrabbit.oak.api.Tree; import org.apache.jackrabbit.oak.api.Tree.Status; +import org.apache.jackrabbit.oak.fixture.NodeStoreFixture; import org.apache.jackrabbit.oak.api.Type; import org.apache.jackrabbit.oak.plugins.memory.LongPropertyState; import org.apache.jackrabbit.oak.plugins.memory.StringBasedBlob; diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/core/RootFuzzIT.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/core/RootFuzzIT.java index a3bb5a4..f5c61d8 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/core/RootFuzzIT.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/core/RootFuzzIT.java @@ -26,18 +26,19 @@ import static org.apache.jackrabbit.oak.core.RootFuzzIT.Operation.Save; import static org.apache.jackrabbit.oak.core.RootFuzzIT.Operation.SetProperty; import static org.junit.Assert.assertEquals; -import java.util.Arrays; import java.util.Collection; +import java.util.EnumSet; import java.util.Iterator; import java.util.Random; -import org.apache.jackrabbit.oak.NodeStoreFixture; import org.apache.jackrabbit.oak.api.CommitFailedException; import org.apache.jackrabbit.oak.api.PropertyState; import org.apache.jackrabbit.oak.api.Root; import org.apache.jackrabbit.oak.api.Tree; +import org.apache.jackrabbit.oak.commons.FixturesHelper.Fixture; import org.apache.jackrabbit.oak.commons.PathUtils; import org.apache.jackrabbit.oak.core.RootFuzzIT.Operation.Rebase; +import org.apache.jackrabbit.oak.fixture.NodeStoreFixture; import org.apache.jackrabbit.oak.plugins.tree.RootFactory; import org.apache.jackrabbit.oak.spi.state.NodeStore; import org.junit.After; @@ -59,11 +60,7 @@ public class RootFuzzIT { @Parameters public static Collection fixtures() { - Object[][] fixtures = new Object[][] { - {NodeStoreFixture.MONGO_NS}, - {NodeStoreFixture.SEGMENT_MK}, - }; - return Arrays.asList(fixtures); + return NodeStoreFixture.asJunitParameters(EnumSet.of(Fixture.DOCUMENT_NS, Fixture.SEGMENT_MK)); } private static final int OP_COUNT = 5000; diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/core/RootTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/core/RootTest.java index f7c1e7f..a969e5b 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/core/RootTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/core/RootTest.java @@ -21,7 +21,6 @@ package org.apache.jackrabbit.oak.core; import java.util.ArrayList; import java.util.List; -import org.apache.jackrabbit.oak.NodeStoreFixture; import org.apache.jackrabbit.oak.OakBaseTest; import org.apache.jackrabbit.oak.api.CommitFailedException; import org.apache.jackrabbit.oak.api.ContentSession; @@ -29,6 +28,7 @@ import org.apache.jackrabbit.oak.api.PropertyState; import org.apache.jackrabbit.oak.api.Root; import org.apache.jackrabbit.oak.api.Tree; import org.apache.jackrabbit.oak.api.Tree.Status; +import org.apache.jackrabbit.oak.fixture.NodeStoreFixture; import org.apache.jackrabbit.oak.api.Type; import org.junit.After; import org.junit.Before; diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/fixture/DocumentMemoryFixture.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/fixture/DocumentMemoryFixture.java new file mode 100644 index 0000000..64df5c2 --- /dev/null +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/fixture/DocumentMemoryFixture.java @@ -0,0 +1,35 @@ +/* + * 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.oak.fixture; + +import org.apache.jackrabbit.oak.plugins.document.DocumentMK; +import org.apache.jackrabbit.oak.spi.state.NodeStore; + +public class DocumentMemoryFixture extends NodeStoreFixture { + + @Override + public NodeStore createNodeStore() { + return new DocumentMK.Builder().getNodeStore(); + } + + @Override + public String toString() { + return "DocumentNodeStore[Memory]"; + } +} \ No newline at end of file diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/fixture/DocumentMongoFixture.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/fixture/DocumentMongoFixture.java new file mode 100644 index 0000000..9a6ee11 --- /dev/null +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/fixture/DocumentMongoFixture.java @@ -0,0 +1,145 @@ +/* + * 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.oak.fixture; + +import java.net.UnknownHostException; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.atomic.AtomicInteger; + +import org.apache.jackrabbit.oak.plugins.document.DocumentMK; +import org.apache.jackrabbit.oak.plugins.document.DocumentNodeStore; +import org.apache.jackrabbit.oak.plugins.document.util.MongoConnection; +import org.apache.jackrabbit.oak.spi.blob.BlobStore; +import org.apache.jackrabbit.oak.spi.state.NodeStore; +import org.junit.AssumptionViolatedException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.mongodb.DB; +import com.mongodb.Mongo; +import com.mongodb.MongoClient; +import com.mongodb.MongoClientURI; + +public class DocumentMongoFixture extends NodeStoreFixture { + + private static final Logger log = LoggerFactory.getLogger(DocumentMongoFixture.class); + + public static final String DEFAULT_URI = "mongodb://localhost:27017/oak"; + + private final String uri; + + private final BlobStore blobStore; + + private final Map suffixes = new ConcurrentHashMap(); + + private Boolean isAvailable; + + private AtomicInteger sequence = new AtomicInteger(); + + public DocumentMongoFixture(String uri, BlobStore blobStore) { + this.uri = uri; + this.blobStore = blobStore; + } + + public DocumentMongoFixture() { + this(System.getProperty("mongo.url", DEFAULT_URI), null); + } + + @Override + public NodeStore createNodeStore() { + try { + String suffix = String.format("-%d-%d", System.currentTimeMillis(), sequence.incrementAndGet()); + + DocumentMK.Builder builder = new DocumentMK.Builder(); + if (blobStore != null) { + builder.setBlobStore(blobStore); + } + builder.setPersistentCache("target/persistentCache,time"); + builder.setMongoDB(getDb(suffix)); + DocumentNodeStore ns = builder.getNodeStore(); + suffixes.put(ns, suffix); + return ns; + } catch (Exception e) { + throw new AssumptionViolatedException("Mongo instance is not available", e); + } + } + + private DB getDb(String suffix) throws UnknownHostException { + String dbName = new MongoClientURI(uri).getDatabase(); + MongoConnection connection = new MongoConnection(uri); + return connection.getDB(dbName + "-" + suffix); + } + + @Override + public synchronized boolean isAvailable() { + if (isAvailable == null) { + isAvailable = testMongoAvailability(uri); + } + return isAvailable; + } + + private static boolean testMongoAvailability(String uri) { + Mongo mongo = null; + try { + StringBuilder uriWithTimeout = new StringBuilder(uri); + if (uri.contains("?")) { + uriWithTimeout.append("&"); + } else { + uriWithTimeout.append("?"); + } + uriWithTimeout.append("connectTimeoutMS=3000"); + MongoClientURI mongoUri = new MongoClientURI(uriWithTimeout.toString()); + mongo = new MongoClient(mongoUri); + mongo.getDatabaseNames(); + return true; + } catch (Exception e) { + return false; + } finally { + if (mongo != null) { + mongo.close(); + } + } + } + + @Override + public void dispose(NodeStore nodeStore) { + if (nodeStore instanceof DocumentNodeStore) { + ((DocumentNodeStore) nodeStore).dispose(); + } + if (nodeStore == null) { + return; + } + String suffix = suffixes.remove(nodeStore); + if (suffix != null) { + try { + DB db = getDb(suffix); + db.dropDatabase(); + db.getMongo().close(); + } catch (Exception e) { + log.error("Can't close Mongo", e); + } + } + } + + @Override + public String toString() { + return "DocumentNodeStore[Mongo] on " + this.uri; + } +} \ No newline at end of file diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/fixture/DocumentRdbFixture.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/fixture/DocumentRdbFixture.java new file mode 100644 index 0000000..342d991 --- /dev/null +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/fixture/DocumentRdbFixture.java @@ -0,0 +1,83 @@ +/* + * 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.oak.fixture; + +import java.io.Closeable; +import java.io.File; +import java.io.IOException; +import java.util.Map; +import java.util.UUID; +import java.util.concurrent.ConcurrentHashMap; + +import javax.sql.DataSource; + +import org.apache.commons.lang.StringUtils; +import org.apache.jackrabbit.oak.plugins.document.DocumentMK; +import org.apache.jackrabbit.oak.plugins.document.DocumentNodeStore; +import org.apache.jackrabbit.oak.plugins.document.rdb.RDBDataSourceFactory; +import org.apache.jackrabbit.oak.plugins.document.rdb.RDBOptions; +import org.apache.jackrabbit.oak.spi.state.NodeStore; + +public class DocumentRdbFixture extends NodeStoreFixture { + + private Map dataSources = new ConcurrentHashMap(); + + private String jdbcUrl; + + private String fname = (new File("target")).isDirectory() ? "target/" : ""; + + private final String pUrl = System.getProperty("rdb.jdbc-url", "jdbc:h2:file:./{fname}oaktest"); + + private final String pUser = System.getProperty("rdb.jdbc-user", "sa"); + + private final String pPasswd = System.getProperty("rdb.jdbc-passwd", ""); + + @Override + public NodeStore createNodeStore() { + String prefix = "T" + UUID.randomUUID().toString().replace("-", ""); + RDBOptions options = new RDBOptions().tablePrefix(prefix).dropTablesOnClose(true); + this.jdbcUrl = pUrl.replace("{fname}", fname); + DataSource ds = RDBDataSourceFactory.forJdbcUrl(jdbcUrl, pUser, pPasswd); + + NodeStore result = new DocumentMK.Builder().setPersistentCache("target/persistentCache,time") + .setRDBConnection(ds, options).getNodeStore(); + this.dataSources.put(result, ds); + return result; + } + + @Override + public void dispose(NodeStore nodeStore) { + if (nodeStore instanceof DocumentNodeStore) { + ((DocumentNodeStore) nodeStore).dispose(); + } + DataSource ds = this.dataSources.remove(nodeStore); + if (ds instanceof Closeable) { + try { + ((Closeable)ds).close(); + } catch (IOException ex) { + throw new RuntimeException(ex); + } + } + } + + @Override + public String toString() { + return "DocumentNodeStore[RDB] on " + StringUtils.defaultString(this.jdbcUrl, this.pUrl); + } +} \ No newline at end of file diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/fixture/MemoryFixture.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/fixture/MemoryFixture.java new file mode 100644 index 0000000..f62ca21 --- /dev/null +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/fixture/MemoryFixture.java @@ -0,0 +1,35 @@ +/* + * 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.oak.fixture; + +import org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore; +import org.apache.jackrabbit.oak.spi.state.NodeStore; + +public class MemoryFixture extends NodeStoreFixture { + + @Override + public NodeStore createNodeStore() { + return new MemoryNodeStore(); + } + + @Override + public String toString() { + return "MemoryNodeStore"; + } +} \ No newline at end of file diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/fixture/NodeStoreFixture.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/fixture/NodeStoreFixture.java new file mode 100644 index 0000000..81f6efd --- /dev/null +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/fixture/NodeStoreFixture.java @@ -0,0 +1,91 @@ +/* + * 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.oak.fixture; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Set; + +import org.apache.jackrabbit.oak.commons.FixturesHelper.Fixture; +import org.apache.jackrabbit.oak.spi.state.NodeStore; + +/** + * NodeStore fixture for parametrized tests. + */ +public abstract class NodeStoreFixture { + + public static final NodeStoreFixture MEMORY_NS = new MemoryFixture(); + + public static final NodeStoreFixture SEGMENT_MK = new SegmentFixture(); + + public static final NodeStoreFixture DOCUMENT_NS = new DocumentMongoFixture(); + + public static final NodeStoreFixture DOCUMENT_RDB = new DocumentRdbFixture(); + + /** + * Creates a new empty {@link NodeStore} instance. An implementation must + * ensure the returned node store is indeed empty and is independent from + * instances returned from previous calls to this method. + * + * @return a new node store instance. + */ + public abstract NodeStore createNodeStore(); + + /** + * Create a new cluster node that is attached to the same backend storage. + * + * @param clusterNodeId the cluster node id + * @return the node store, or null if clustering is not supported + */ + public NodeStore createNodeStore(int clusterNodeId) { + return null; + } + + public void dispose(NodeStore nodeStore) { + } + + public boolean isAvailable() { + return true; + } + + public static Collection asJunitParameters(Set fixtures) { + List configuredFixtures = new ArrayList(); + if (fixtures.contains(Fixture.DOCUMENT_NS)) { + configuredFixtures.add(NodeStoreFixture.DOCUMENT_NS); + } + if (fixtures.contains(Fixture.SEGMENT_MK)) { + configuredFixtures.add(NodeStoreFixture.SEGMENT_MK); + } + if (fixtures.contains(Fixture.MEMORY_NS)) { + configuredFixtures.add(NodeStoreFixture.MEMORY_NS); + } + if (fixtures.contains(Fixture.DOCUMENT_RDB)) { + configuredFixtures.add(NodeStoreFixture.DOCUMENT_RDB); + } + + Collection result = new ArrayList(); + for (NodeStoreFixture f : configuredFixtures) { + if (f.isAvailable()) { + result.add(new Object[]{f}); + } + } + return result; + } +} \ No newline at end of file diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/fixture/SegmentFixture.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/fixture/SegmentFixture.java new file mode 100644 index 0000000..2626c6b --- /dev/null +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/fixture/SegmentFixture.java @@ -0,0 +1,56 @@ +/* + * 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.oak.fixture; + +import java.io.IOException; + +import org.apache.jackrabbit.oak.plugins.segment.SegmentNodeStore; +import org.apache.jackrabbit.oak.plugins.segment.SegmentStore; +import org.apache.jackrabbit.oak.spi.state.NodeStore; + +public class SegmentFixture extends NodeStoreFixture { + + private final SegmentStore store; + + public SegmentFixture() { + this(null); + } + + public SegmentFixture(SegmentStore store) { + this.store = store; + } + + @Override + public NodeStore createNodeStore() { + if (store == null) { + try { + return new SegmentNodeStore(); + } catch (IOException e) { + throw new RuntimeException(e); + } + } else { + return SegmentNodeStore.newSegmentNodeStore(store).create(); + } + } + + @Override + public String toString() { + return "SegmentNodeStore"; + } +} \ No newline at end of file diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/AsyncIndexUpdateLeaseTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/AsyncIndexUpdateLeaseTest.java index 363ad59..1304bc0 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/AsyncIndexUpdateLeaseTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/AsyncIndexUpdateLeaseTest.java @@ -26,9 +26,9 @@ import static org.junit.Assert.assertTrue; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; -import org.apache.jackrabbit.oak.NodeStoreFixture; import org.apache.jackrabbit.oak.OakBaseTest; import org.apache.jackrabbit.oak.api.CommitFailedException; +import org.apache.jackrabbit.oak.fixture.NodeStoreFixture; import org.apache.jackrabbit.oak.plugins.index.AsyncIndexUpdate.AsyncIndexStats; import org.apache.jackrabbit.oak.plugins.index.AsyncIndexUpdate.AsyncUpdateCallback; import org.apache.jackrabbit.oak.plugins.index.property.PropertyIndexEditorProvider; diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/name/ReadWriteNamespaceRegistryTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/name/ReadWriteNamespaceRegistryTest.java index 6d0464f..5e10a5a 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/name/ReadWriteNamespaceRegistryTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/name/ReadWriteNamespaceRegistryTest.java @@ -20,11 +20,11 @@ import static org.junit.Assert.assertEquals; import javax.jcr.NamespaceRegistry; -import org.apache.jackrabbit.oak.NodeStoreFixture; import org.apache.jackrabbit.oak.Oak; import org.apache.jackrabbit.oak.OakBaseTest; import org.apache.jackrabbit.oak.api.ContentSession; import org.apache.jackrabbit.oak.api.Root; +import org.apache.jackrabbit.oak.fixture.NodeStoreFixture; import org.apache.jackrabbit.oak.plugins.nodetype.write.InitialContent; import org.apache.jackrabbit.oak.spi.security.OpenSecurityProvider; import org.junit.Test; diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/tree/TreeLocationTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/tree/TreeLocationTest.java index d4ae6cf..a86b15d 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/tree/TreeLocationTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/tree/TreeLocationTest.java @@ -22,12 +22,12 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; -import org.apache.jackrabbit.oak.NodeStoreFixture; import org.apache.jackrabbit.oak.OakBaseTest; import org.apache.jackrabbit.oak.api.CommitFailedException; import org.apache.jackrabbit.oak.api.ContentSession; import org.apache.jackrabbit.oak.api.Root; import org.apache.jackrabbit.oak.api.Tree; +import org.apache.jackrabbit.oak.fixture.NodeStoreFixture; import org.junit.After; import org.junit.Assert; import org.junit.Before; diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/tree/impl/ImmutableTreeTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/tree/impl/ImmutableTreeTest.java index d2f77bd..d102f64 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/tree/impl/ImmutableTreeTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/tree/impl/ImmutableTreeTest.java @@ -22,13 +22,13 @@ import java.util.List; import com.google.common.collect.Lists; import org.apache.jackrabbit.JcrConstants; -import org.apache.jackrabbit.oak.NodeStoreFixture; import org.apache.jackrabbit.oak.OakBaseTest; import org.apache.jackrabbit.oak.api.CommitFailedException; import org.apache.jackrabbit.oak.api.ContentSession; import org.apache.jackrabbit.oak.api.PropertyState; import org.apache.jackrabbit.oak.api.Root; import org.apache.jackrabbit.oak.api.Tree; +import org.apache.jackrabbit.oak.fixture.NodeStoreFixture; import org.apache.jackrabbit.oak.spi.commit.CommitInfo; import org.apache.jackrabbit.oak.spi.commit.EmptyHook; import org.apache.jackrabbit.oak.spi.state.NodeBuilder; diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/spi/state/CheckpointTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/spi/state/CheckpointTest.java index f757b30..f718bfc 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/spi/state/CheckpointTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/spi/state/CheckpointTest.java @@ -25,9 +25,10 @@ import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import com.google.common.collect.ImmutableMap; -import org.apache.jackrabbit.oak.NodeStoreFixture; + import org.apache.jackrabbit.oak.OakBaseTest; import org.apache.jackrabbit.oak.api.CommitFailedException; +import org.apache.jackrabbit.oak.fixture.NodeStoreFixture; import org.apache.jackrabbit.oak.spi.commit.CommitInfo; import org.apache.jackrabbit.oak.spi.commit.EmptyHook; import org.junit.After; diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/spi/state/LargeNodeStateTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/spi/state/LargeNodeStateTest.java index 93d4181..b49ca3c 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/spi/state/LargeNodeStateTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/spi/state/LargeNodeStateTest.java @@ -22,9 +22,9 @@ import static junit.framework.Assert.assertEquals; import static junit.framework.Assert.assertFalse; import static junit.framework.Assert.assertTrue; -import org.apache.jackrabbit.oak.NodeStoreFixture; import org.apache.jackrabbit.oak.OakBaseTest; import org.apache.jackrabbit.oak.api.CommitFailedException; +import org.apache.jackrabbit.oak.fixture.NodeStoreFixture; import org.apache.jackrabbit.oak.spi.commit.CommitInfo; import org.apache.jackrabbit.oak.spi.commit.EmptyHook; import org.junit.After; diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/spi/state/NodeBuilderTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/spi/state/NodeBuilderTest.java index 6fa595d..749590c 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/spi/state/NodeBuilderTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/spi/state/NodeBuilderTest.java @@ -23,9 +23,9 @@ import static junit.framework.Assert.assertFalse; import static junit.framework.Assert.assertTrue; import static org.junit.Assert.assertEquals; -import org.apache.jackrabbit.oak.NodeStoreFixture; import org.apache.jackrabbit.oak.OakBaseTest; import org.apache.jackrabbit.oak.api.CommitFailedException; +import org.apache.jackrabbit.oak.fixture.NodeStoreFixture; import org.apache.jackrabbit.oak.spi.commit.CommitInfo; import org.apache.jackrabbit.oak.spi.commit.EmptyHook; import org.junit.Test; diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/spi/state/NodeStateTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/spi/state/NodeStateTest.java index c396a08..9bae26d 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/spi/state/NodeStateTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/spi/state/NodeStateTest.java @@ -29,10 +29,10 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; -import org.apache.jackrabbit.oak.NodeStoreFixture; import org.apache.jackrabbit.oak.OakBaseTest; import org.apache.jackrabbit.oak.api.CommitFailedException; import org.apache.jackrabbit.oak.api.PropertyState; +import org.apache.jackrabbit.oak.fixture.NodeStoreFixture; import org.apache.jackrabbit.oak.spi.commit.CommitInfo; import org.apache.jackrabbit.oak.spi.commit.EmptyHook; import org.junit.After; diff --git a/oak-core/src/test/java/org/apache/jackrabbit/oak/spi/state/NodeStoreTest.java b/oak-core/src/test/java/org/apache/jackrabbit/oak/spi/state/NodeStoreTest.java index dfd350a..4fbba65 100644 --- a/oak-core/src/test/java/org/apache/jackrabbit/oak/spi/state/NodeStoreTest.java +++ b/oak-core/src/test/java/org/apache/jackrabbit/oak/spi/state/NodeStoreTest.java @@ -39,10 +39,10 @@ import java.util.concurrent.atomic.AtomicReference; import javax.annotation.Nonnull; import javax.annotation.Nullable; -import org.apache.jackrabbit.oak.NodeStoreFixture; import org.apache.jackrabbit.oak.OakBaseTest; import org.apache.jackrabbit.oak.api.CommitFailedException; import org.apache.jackrabbit.oak.api.PropertyState; +import org.apache.jackrabbit.oak.fixture.NodeStoreFixture; import org.apache.jackrabbit.oak.plugins.commit.ConflictHook; import org.apache.jackrabbit.oak.plugins.commit.ConflictValidatorProvider; import org.apache.jackrabbit.oak.plugins.commit.JcrConflictHandler; @@ -100,7 +100,7 @@ public class NodeStoreTest extends OakBaseTest { @Test public void addExistingNode() throws CommitFailedException { // FIXME OAK-1550 Incorrect handling of addExistingNode conflict in NodeStore - assumeTrue(fixture != NodeStoreFixture.MONGO_NS); + assumeTrue(fixture != NodeStoreFixture.DOCUMENT_NS); CommitHook hook = new CompositeHook( new ConflictHook(JcrConflictHandler.createJcrConflictHandler()), diff --git a/oak-jcr/pom.xml b/oak-jcr/pom.xml index 60033bf..ec52cc6 100644 --- a/oak-jcr/pom.xml +++ b/oak-jcr/pom.xml @@ -229,6 +229,13 @@ org.apache.jackrabbit + oak-core + ${project.version} + test-jar + test + + + org.apache.jackrabbit oak-commons ${project.version} diff --git a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/AbstractRepositoryTest.java b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/AbstractRepositoryTest.java index a000579..ea34f4d 100644 --- a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/AbstractRepositoryTest.java +++ b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/AbstractRepositoryTest.java @@ -31,6 +31,7 @@ import org.apache.jackrabbit.api.JackrabbitRepository; import org.apache.jackrabbit.commons.jackrabbit.authorization.AccessControlUtils; import org.apache.jackrabbit.oak.commons.FixturesHelper; import org.apache.jackrabbit.oak.commons.FixturesHelper.Fixture; +import org.apache.jackrabbit.oak.fixture.NodeStoreFixture; import org.apache.jackrabbit.oak.query.QueryEngineSettings; import org.apache.jackrabbit.oak.spi.security.principal.EveryonePrincipal; import org.apache.jackrabbit.oak.spi.security.user.UserConstants; @@ -70,17 +71,7 @@ public abstract class AbstractRepositoryTest { @Parameterized.Parameters(name="{0}") public static Collection fixtures() { - Collection result = new ArrayList(); - if (FIXTURES.contains(Fixture.DOCUMENT_NS)) { - result.add(new Object[] { NodeStoreFixture.DOCUMENT_NS }); - } - if (FIXTURES.contains(Fixture.SEGMENT_MK)) { - result.add(new Object[] { NodeStoreFixture.SEGMENT_MK }); - } - if (FIXTURES.contains(Fixture.DOCUMENT_RDB)) { - result.add(new Object[] { NodeStoreFixture.DOCUMENT_RDB }); - } - return result; + return NodeStoreFixture.asJunitParameters(FIXTURES); } @After diff --git a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/AtomicCounterIT.java b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/AtomicCounterIT.java index 49ceed8..5228809 100644 --- a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/AtomicCounterIT.java +++ b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/AtomicCounterIT.java @@ -37,6 +37,7 @@ import javax.jcr.Session; import org.apache.jackrabbit.oak.commons.FixturesHelper; import org.apache.jackrabbit.oak.commons.FixturesHelper.Fixture; +import org.apache.jackrabbit.oak.fixture.NodeStoreFixture; import org.junit.BeforeClass; import org.junit.Test; diff --git a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/AtomicCounterTest.java b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/AtomicCounterTest.java index 8a2dd20..54056b6 100644 --- a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/AtomicCounterTest.java +++ b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/AtomicCounterTest.java @@ -29,6 +29,7 @@ import javax.jcr.Node; import javax.jcr.RepositoryException; import javax.jcr.Session; +import org.apache.jackrabbit.oak.fixture.NodeStoreFixture; import org.junit.Test; public class AtomicCounterTest extends AbstractRepositoryTest { diff --git a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/AutoCreatedItemsTest.java b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/AutoCreatedItemsTest.java index 4fa98fb..4bb7a59 100644 --- a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/AutoCreatedItemsTest.java +++ b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/AutoCreatedItemsTest.java @@ -24,6 +24,7 @@ import javax.jcr.Node; import javax.jcr.Session; import javax.jcr.Value; +import org.apache.jackrabbit.oak.fixture.NodeStoreFixture; import org.junit.Test; /** diff --git a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/CRUDTest.java b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/CRUDTest.java index c62f64c..d36bb39 100644 --- a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/CRUDTest.java +++ b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/CRUDTest.java @@ -29,6 +29,7 @@ import javax.jcr.Session; import javax.jcr.nodetype.ConstraintViolationException; import javax.jcr.nodetype.NodeType; +import org.apache.jackrabbit.oak.fixture.NodeStoreFixture; import org.junit.Test; import static junit.framework.Assert.assertEquals; diff --git a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/CompatibilityIssuesTest.java b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/CompatibilityIssuesTest.java index af4389e..88de7f1 100644 --- a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/CompatibilityIssuesTest.java +++ b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/CompatibilityIssuesTest.java @@ -73,6 +73,7 @@ import org.apache.jackrabbit.api.security.JackrabbitAccessControlList; import org.apache.jackrabbit.commons.JcrUtils; import org.apache.jackrabbit.commons.jackrabbit.authorization.AccessControlUtils; import org.apache.jackrabbit.oak.api.CommitFailedException; +import org.apache.jackrabbit.oak.fixture.NodeStoreFixture; import org.apache.jackrabbit.oak.spi.security.principal.EveryonePrincipal; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/ConcurrentAddIT.java b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/ConcurrentAddIT.java index c232b82..6f1afcc 100644 --- a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/ConcurrentAddIT.java +++ b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/ConcurrentAddIT.java @@ -31,6 +31,8 @@ import javax.jcr.RepositoryException; import javax.jcr.Session; import com.google.common.collect.Iterators; + +import org.apache.jackrabbit.oak.fixture.NodeStoreFixture; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; diff --git a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/ConcurrentAddReferenceTest.java b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/ConcurrentAddReferenceTest.java index 7c4bdd6..f911a14 100644 --- a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/ConcurrentAddReferenceTest.java +++ b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/ConcurrentAddReferenceTest.java @@ -31,6 +31,8 @@ import javax.jcr.Session; import javax.jcr.nodetype.NodeType; import com.google.common.collect.Iterators; + +import org.apache.jackrabbit.oak.fixture.NodeStoreFixture; import org.junit.After; import org.junit.Before; import org.junit.Test; diff --git a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/ConcurrentAddRemoveIT.java b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/ConcurrentAddRemoveIT.java index 794adab..73bad7b 100644 --- a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/ConcurrentAddRemoveIT.java +++ b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/ConcurrentAddRemoveIT.java @@ -28,6 +28,7 @@ import javax.jcr.Node; import javax.jcr.RepositoryException; import javax.jcr.Session; +import org.apache.jackrabbit.oak.fixture.NodeStoreFixture; import org.junit.Test; /** diff --git a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/ConcurrentFileOperationsTest.java b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/ConcurrentFileOperationsTest.java index e41c7a5..60afb0f 100644 --- a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/ConcurrentFileOperationsTest.java +++ b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/ConcurrentFileOperationsTest.java @@ -34,6 +34,7 @@ import javax.jcr.util.TraversingItemVisitor; import org.apache.jackrabbit.commons.JcrUtils; import org.apache.jackrabbit.oak.commons.PathUtils; +import org.apache.jackrabbit.oak.fixture.NodeStoreFixture; import org.junit.Before; import org.junit.Test; import org.slf4j.Logger; diff --git a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/ConcurrentIndexUpdateIT.java b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/ConcurrentIndexUpdateIT.java index bf5b566..45d7d65 100644 --- a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/ConcurrentIndexUpdateIT.java +++ b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/ConcurrentIndexUpdateIT.java @@ -27,6 +27,7 @@ import javax.jcr.Session; import com.google.common.collect.Lists; import org.apache.jackrabbit.oak.commons.PathUtils; +import org.apache.jackrabbit.oak.fixture.NodeStoreFixture; import org.junit.BeforeClass; import org.junit.Test; diff --git a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/ConcurrentReadIT.java b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/ConcurrentReadIT.java index fbe2047..7212487 100644 --- a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/ConcurrentReadIT.java +++ b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/ConcurrentReadIT.java @@ -36,6 +36,8 @@ import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.ListeningExecutorService; import com.google.common.util.concurrent.MoreExecutors; + +import org.apache.jackrabbit.oak.fixture.NodeStoreFixture; import org.junit.Test; /** diff --git a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/ConflictResolutionTest.java b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/ConflictResolutionTest.java index 7feb761..9368d8f 100644 --- a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/ConflictResolutionTest.java +++ b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/ConflictResolutionTest.java @@ -30,6 +30,7 @@ import javax.jcr.RepositoryException; import javax.jcr.Session; import org.apache.jackrabbit.oak.commons.junit.LogCustomizer; +import org.apache.jackrabbit.oak.fixture.NodeStoreFixture; import org.junit.After; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/CopyTest.java b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/CopyTest.java index 64dec17..e51628c 100644 --- a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/CopyTest.java +++ b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/CopyTest.java @@ -27,6 +27,7 @@ import javax.jcr.version.VersionHistory; import javax.jcr.version.VersionIterator; import org.apache.jackrabbit.JcrConstants; +import org.apache.jackrabbit.oak.fixture.NodeStoreFixture; import org.apache.jackrabbit.oak.plugins.version.VersionConstants; import org.junit.After; import org.junit.Before; diff --git a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/ItemSaveTest.java b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/ItemSaveTest.java index 26c201d..4a4a877 100644 --- a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/ItemSaveTest.java +++ b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/ItemSaveTest.java @@ -30,6 +30,7 @@ import javax.jcr.Session; import javax.jcr.UnsupportedRepositoryOperationException; import org.apache.jackrabbit.oak.api.CommitFailedException; +import org.apache.jackrabbit.oak.fixture.NodeStoreFixture; import org.apache.jackrabbit.oak.jcr.session.NodeImpl; import org.junit.Before; import org.junit.Test; diff --git a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/LargeOperationIT.java b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/LargeOperationIT.java index 7438e61..f7c4b24 100644 --- a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/LargeOperationIT.java +++ b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/LargeOperationIT.java @@ -61,8 +61,9 @@ import org.apache.commons.math3.exception.NullArgumentException; import org.apache.commons.math3.exception.OutOfRangeException; import org.apache.commons.math3.exception.util.LocalizedFormats; import org.apache.jackrabbit.api.JackrabbitRepository; -import org.apache.jackrabbit.oak.jcr.NodeStoreFixture.DocumentFixture; -import org.apache.jackrabbit.oak.jcr.NodeStoreFixture.SegmentFixture; +import org.apache.jackrabbit.oak.fixture.DocumentMongoFixture; +import org.apache.jackrabbit.oak.fixture.NodeStoreFixture; +import org.apache.jackrabbit.oak.fixture.SegmentFixture; import org.apache.jackrabbit.oak.jcr.session.RefreshStrategy; import org.apache.jackrabbit.oak.plugins.document.DocumentNodeStore; import org.apache.jackrabbit.oak.plugins.segment.SegmentStore; @@ -142,7 +143,7 @@ public class LargeOperationIT { if (segmentFixture.isAvailable()) { fixtures.add(new Object[] {segmentFixture, SEGMENT_SCALES}); } - DocumentFixture documentFixture = new DocumentFixture(); + DocumentMongoFixture documentFixture = new DocumentMongoFixture(); if (documentFixture.isAvailable()) { fixtures.add(new Object[]{documentFixture, MONGO_SCALES}); } @@ -293,7 +294,7 @@ public class LargeOperationIT { executionTimes.add(t); LOG.info("Copying {} node took {} ns/node", scale, t); } - boolean knownIssue = fixture.getClass() == DocumentFixture.class; // FIXME OAK-1698 + boolean knownIssue = fixture.getClass() == DocumentMongoFixture.class; // FIXME OAK-1698 assertOnLgn("large copy", scales, executionTimes, knownIssue); } @@ -325,7 +326,7 @@ public class LargeOperationIT { executionTimes.add(t); LOG.info("Moving {} node took {} ns/node", scale, t); } - boolean knownIssue = fixture.getClass() == DocumentFixture.class; // FIXME OAK-1698 + boolean knownIssue = fixture.getClass() == DocumentMongoFixture.class; // FIXME OAK-1698 assertOnLgn("large move", scales, executionTimes, knownIssue); } @@ -353,7 +354,7 @@ public class LargeOperationIT { executionTimes.add(t); LOG.info("Removing {} node took {} ns/node", scale, t); } - boolean knownIssue = fixture.getClass() == DocumentFixture.class; // FIXME OAK-1698 + boolean knownIssue = fixture.getClass() == DocumentMongoFixture.class; // FIXME OAK-1698 assertOnLgn("large remove", scales, executionTimes, knownIssue); } @@ -390,7 +391,7 @@ public class LargeOperationIT { executionTimes.add(t); LOG.info("Adding 100 siblings next to {} siblings took {} ns/node", scale, t); } - boolean knownIssue = fixture.getClass() == DocumentFixture.class; // FIXME OAK-1698 + boolean knownIssue = fixture.getClass() == DocumentMongoFixture.class; // FIXME OAK-1698 assertOnLgn("many siblings", scales, executionTimes, knownIssue); } @@ -429,7 +430,7 @@ public class LargeOperationIT { } catch (Exception ignore) {} } } - boolean knownIssue = fixture.getClass() == DocumentFixture.class; // FIXME OAK-1698 + boolean knownIssue = fixture.getClass() == DocumentMongoFixture.class; // FIXME OAK-1698 assertOnLgn("large number of pending events", scales, executionTimes, knownIssue); } @@ -452,7 +453,7 @@ public class LargeOperationIT { executionTimes.add(t); LOG.info("Adding {} nodes took {} ns/node", scale, t); } - boolean knownIssue = fixture.getClass() == DocumentFixture.class; // FIXME OAK-1698 + boolean knownIssue = fixture.getClass() == DocumentMongoFixture.class; // FIXME OAK-1698 assertOnLgn("slow listeners", scales, executionTimes, knownIssue); } finally { delayedEventHandling.stop(); diff --git a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/LongPathTest.java b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/LongPathTest.java index 0a04dde..010876e 100644 --- a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/LongPathTest.java +++ b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/LongPathTest.java @@ -23,6 +23,7 @@ import java.util.ArrayList; import javax.jcr.Node; import javax.jcr.Session; +import org.apache.jackrabbit.oak.fixture.NodeStoreFixture; import org.junit.Test; public class LongPathTest extends AbstractRepositoryTest { diff --git a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/ManyChildrenIT.java b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/ManyChildrenIT.java index 967a7f2..947c0f5 100644 --- a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/ManyChildrenIT.java +++ b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/ManyChildrenIT.java @@ -20,6 +20,7 @@ import javax.jcr.Node; import javax.jcr.NodeIterator; import javax.jcr.Session; +import org.apache.jackrabbit.oak.fixture.NodeStoreFixture; import org.junit.Test; import static junit.framework.Assert.assertFalse; diff --git a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/MoveRemoveTest.java b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/MoveRemoveTest.java index ada530f..7e796d2 100644 --- a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/MoveRemoveTest.java +++ b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/MoveRemoveTest.java @@ -24,6 +24,7 @@ import javax.jcr.Node; import javax.jcr.RepositoryException; import javax.jcr.Session; +import org.apache.jackrabbit.oak.fixture.NodeStoreFixture; import org.junit.Test; public class MoveRemoveTest extends AbstractRepositoryTest { diff --git a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/NameAndPathPropertyTest.java b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/NameAndPathPropertyTest.java index 09e0df6..2b9d89b 100644 --- a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/NameAndPathPropertyTest.java +++ b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/NameAndPathPropertyTest.java @@ -21,6 +21,7 @@ import javax.jcr.PropertyType; import javax.jcr.RepositoryException; import javax.jcr.Session; +import org.apache.jackrabbit.oak.fixture.NodeStoreFixture; import org.junit.Test; import static org.junit.Assert.fail; diff --git a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/NodeStoreFixture.java b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/NodeStoreFixture.java deleted file mode 100644 index 221db86..0000000 --- a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/NodeStoreFixture.java +++ /dev/null @@ -1,236 +0,0 @@ -/* - * 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.oak.jcr; - -import java.io.Closeable; -import java.io.File; -import java.io.IOException; -import java.util.Map; -import java.util.UUID; -import java.util.concurrent.ConcurrentHashMap; - -import javax.sql.DataSource; - -import org.apache.jackrabbit.oak.plugins.document.DocumentMK; -import org.apache.jackrabbit.oak.plugins.document.DocumentNodeStore; -import org.apache.jackrabbit.oak.plugins.document.rdb.RDBDataSourceFactory; -import org.apache.jackrabbit.oak.plugins.document.rdb.RDBOptions; -import org.apache.jackrabbit.oak.plugins.document.util.MongoConnection; -import org.apache.jackrabbit.oak.plugins.segment.SegmentNodeStore; -import org.apache.jackrabbit.oak.plugins.segment.SegmentStore; -import org.apache.jackrabbit.oak.plugins.segment.memory.MemoryStore; -import org.apache.jackrabbit.oak.spi.blob.BlobStore; -import org.apache.jackrabbit.oak.spi.state.NodeStore; - -import com.mongodb.DB; - -/** - * NodeStore fixture for parametrized tests. - */ -public abstract class NodeStoreFixture { - - public static final NodeStoreFixture SEGMENT_MK = new SegmentFixture(); - - public static final NodeStoreFixture DOCUMENT_NS = createDocumentFixture("mongodb://localhost:27017/oak"); - - public static final NodeStoreFixture DOCUMENT_RDB = new NodeStoreFixture() { - - private Map dataSources = new ConcurrentHashMap(); - private String jdbcUrl; - private String fname = (new File("target")).isDirectory() ? "target/" : ""; - - private final String pUrl = System.getProperty("rdb.jdbc-url", "jdbc:h2:file:./{fname}oaktest"); - private final String pUser = System.getProperty("rdb.jdbc-user", "sa"); - private final String pPasswd = System.getProperty("rdb.jdbc-passwd", ""); - - @Override - public NodeStore createNodeStore() { - String prefix = "T" + UUID.randomUUID().toString().replace("-", ""); - RDBOptions options = new RDBOptions().tablePrefix(prefix).dropTablesOnClose(true); - this.jdbcUrl = pUrl.replace("{fname}", fname); - DataSource ds = RDBDataSourceFactory.forJdbcUrl(jdbcUrl, pUser, pPasswd); - - NodeStore result = new DocumentMK.Builder().setPersistentCache("target/persistentCache,time") - .setRDBConnection(ds, options).getNodeStore(); - this.dataSources.put(result, ds); - return result; - } - - @Override - public NodeStore createNodeStore(int clusterNodeId) { - throw new RuntimeException("clustered node store config not supported yet"); - } - - @Override - public void dispose(NodeStore nodeStore) { - if (nodeStore instanceof DocumentNodeStore) { - ((DocumentNodeStore) nodeStore).dispose(); - } - DataSource ds = this.dataSources.remove(nodeStore); - if (ds instanceof Closeable) { - try { - ((Closeable)ds).close(); - } catch (IOException ex) { - throw new RuntimeException(ex); - } - } - } - - @Override - public String toString() { - return "RDBDocumentStore on " + this.jdbcUrl; - } - }; - - public static NodeStoreFixture createDocumentFixture(final String uri) { - return new DocumentFixture(uri); - } - - /** - * Creates a new empty {@link NodeStore} instance. An implementation must - * ensure the returned node store is indeed empty and is independent from - * instances returned from previous calls to this method. - * - * @return a new node store instance. - */ - public abstract NodeStore createNodeStore(); - - /** - * Create a new cluster node that is attached to the same backend storage. - * - * @param clusterNodeId the cluster node id - * @return the node store, or null if clustering is not supported - */ - public NodeStore createNodeStore(int clusterNodeId) { - return null; - } - - public abstract void dispose(NodeStore nodeStore); - - public boolean isAvailable() { - return true; - } - - public static class SegmentFixture extends NodeStoreFixture { - private final SegmentStore store; - - public SegmentFixture() { - this(null); - } - - public SegmentFixture(SegmentStore store) { - this.store = store; - } - - @Override - public NodeStore createNodeStore() { - try { - return new SegmentNodeStore(store == null ? new MemoryStore() : store); - } catch (IOException e) { - throw new RuntimeException(e); - } - } - - @Override - public void dispose(NodeStore nodeStore) { - } - - @Override - public String toString() { - return "SegmentStore"; - } - } - - public static class DocumentFixture extends NodeStoreFixture { - public static final String DEFAULT_URI = "mongodb://localhost:27017/oak"; - - private final String uri; - private final boolean inMemory; - private final BlobStore blobStore; - - public DocumentFixture(String uri, boolean inMemory, BlobStore blobStore) { - this.uri = uri; - this.inMemory = inMemory; - this.blobStore = blobStore; - } - - public DocumentFixture(String uri) { - this(uri, true, null); - } - - public DocumentFixture() { - this(DEFAULT_URI, false, null); - } - - private static NodeStore createNodeStore(String uri, BlobStore blobStore) { - MongoConnection connection; - try { - connection = new MongoConnection(uri); - DB mongoDB = connection.getDB(); - DocumentMK.Builder builder = new DocumentMK.Builder(); - if(blobStore != null){ - builder.setBlobStore(blobStore); - } - builder.setPersistentCache("target/persistentCache,time"); - builder.setMongoDB(mongoDB); - return builder.getNodeStore(); - } catch (Exception e) { - return null; - } - } - - @Override - public NodeStore createNodeStore() { - if (inMemory) { - return new DocumentMK.Builder().getNodeStore(); - } else { - return createNodeStore(uri + '-' + System.nanoTime(), blobStore); - } - } - - @Override - public NodeStore createNodeStore(int clusterNodeId) { - return createNodeStore(uri, blobStore); - } - - @Override - public boolean isAvailable() { - // FIXME is there a better way to check whether MongoDB is available? - NodeStore nodeStore = createNodeStore(uri, blobStore); - if (nodeStore == null) { - return false; - } else { - dispose(nodeStore); - return true; - } - } - - @Override - public void dispose(NodeStore nodeStore) { - if (nodeStore instanceof DocumentNodeStore) { - ((DocumentNodeStore) nodeStore).dispose(); - } - } - - @Override - public String toString() { - return "MongoDocumentStore on " + this.uri; - } - } -} diff --git a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/OrderableNodesTest.java b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/OrderableNodesTest.java index 6007116..0f31c79 100644 --- a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/OrderableNodesTest.java +++ b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/OrderableNodesTest.java @@ -30,6 +30,7 @@ import javax.jcr.RepositoryException; import javax.jcr.Session; import org.apache.jackrabbit.commons.iterator.NodeIterable; +import org.apache.jackrabbit.oak.fixture.NodeStoreFixture; import org.junit.Test; public class OrderableNodesTest extends AbstractRepositoryTest { diff --git a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/PackageImportIT.java b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/PackageImportIT.java index 76553ac..0956970 100644 --- a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/PackageImportIT.java +++ b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/PackageImportIT.java @@ -25,6 +25,7 @@ import javax.jcr.RepositoryException; import javax.jcr.Session; import org.apache.jackrabbit.JcrConstants; +import org.apache.jackrabbit.oak.fixture.NodeStoreFixture; import org.junit.After; import org.junit.Before; import org.junit.Test; diff --git a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/ReferenceBinaryIT.java b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/ReferenceBinaryIT.java index 1c8f35f..51609b4 100644 --- a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/ReferenceBinaryIT.java +++ b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/ReferenceBinaryIT.java @@ -37,6 +37,9 @@ import org.apache.jackrabbit.api.JackrabbitRepository; import org.apache.jackrabbit.api.ReferenceBinary; import org.apache.jackrabbit.commons.jackrabbit.SimpleReferenceBinary; import org.apache.jackrabbit.core.data.RandomInputStream; +import org.apache.jackrabbit.oak.fixture.DocumentMongoFixture; +import org.apache.jackrabbit.oak.fixture.NodeStoreFixture; +import org.apache.jackrabbit.oak.fixture.SegmentFixture; import org.apache.jackrabbit.oak.plugins.blob.datastore.DataStoreBlobStore; import org.apache.jackrabbit.oak.plugins.blob.datastore.OakFileDataStore; import org.apache.jackrabbit.oak.plugins.segment.SegmentStore; @@ -50,7 +53,6 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; -import static org.apache.jackrabbit.oak.jcr.NodeStoreFixture.DocumentFixture; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; @@ -136,7 +138,7 @@ public class ReferenceBinaryIT { SegmentStore segmentStore = new FileStore(createBlobStore(), file, 266, true); List fixtures = Lists.newArrayList(); - NodeStoreFixture.SegmentFixture segmentFixture = new NodeStoreFixture.SegmentFixture(segmentStore); + SegmentFixture segmentFixture = new SegmentFixture(segmentStore); if (segmentFixture.isAvailable()) { fixtures.add(new Object[] {segmentFixture}); } @@ -144,12 +146,12 @@ public class ReferenceBinaryIT { FileBlobStore fbs = new FileBlobStore(getTestDir("fbs1").getAbsolutePath()); fbs.setReferenceKeyPlainText("foobar"); SegmentStore segmentStoreWithFBS = new FileStore(fbs, getTestDir("tar2"), 266, true); - NodeStoreFixture.SegmentFixture segmentFixtureFBS = new NodeStoreFixture.SegmentFixture(segmentStoreWithFBS); + SegmentFixture segmentFixtureFBS = new SegmentFixture(segmentStoreWithFBS); if (segmentFixtureFBS.isAvailable()) { fixtures.add(new Object[] {segmentFixtureFBS}); } - DocumentFixture documentFixture = new DocumentFixture(DocumentFixture.DEFAULT_URI, false, createBlobStore()); + DocumentMongoFixture documentFixture = new DocumentMongoFixture(DocumentMongoFixture.DEFAULT_URI, createBlobStore()); if (documentFixture.isAvailable()) { fixtures.add(new Object[]{documentFixture}); } diff --git a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/RepositoryTest.java b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/RepositoryTest.java index 4e22d92..fe2252b 100644 --- a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/RepositoryTest.java +++ b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/RepositoryTest.java @@ -85,6 +85,7 @@ import org.apache.jackrabbit.commons.cnd.CndImporter; import org.apache.jackrabbit.commons.cnd.ParseException; import org.apache.jackrabbit.commons.jackrabbit.SimpleReferenceBinary; import org.apache.jackrabbit.core.data.RandomInputStream; +import org.apache.jackrabbit.oak.fixture.NodeStoreFixture; import org.apache.jackrabbit.oak.jcr.repository.RepositoryImpl; import org.apache.jackrabbit.oak.plugins.nodetype.NodeTypeConstants; import org.apache.jackrabbit.spi.QValue; diff --git a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/SameNamePropertyNodeTest.java b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/SameNamePropertyNodeTest.java index b8db85a..e6d2942 100644 --- a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/SameNamePropertyNodeTest.java +++ b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/SameNamePropertyNodeTest.java @@ -22,6 +22,7 @@ import javax.jcr.Property; import javax.jcr.Repository; import org.apache.jackrabbit.api.JackrabbitRepository; +import org.apache.jackrabbit.oak.fixture.NodeStoreFixture; import org.apache.jackrabbit.oak.spi.state.NodeStore; import org.apache.jackrabbit.test.AbstractJCRTest; import org.apache.jackrabbit.test.NotExecutableException; diff --git a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/SameNameSiblingTest.java b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/SameNameSiblingTest.java index 7e222f9..feab9d4 100644 --- a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/SameNameSiblingTest.java +++ b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/SameNameSiblingTest.java @@ -37,6 +37,7 @@ import javax.jcr.Session; import org.apache.jackrabbit.api.JackrabbitNode; import org.apache.jackrabbit.oak.api.CommitFailedException; +import org.apache.jackrabbit.oak.fixture.NodeStoreFixture; import org.apache.jackrabbit.oak.spi.commit.CommitInfo; import org.apache.jackrabbit.oak.spi.commit.EmptyHook; import org.apache.jackrabbit.oak.spi.state.NodeBuilder; diff --git a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/ValueFactoryTest.java b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/ValueFactoryTest.java index 340d218..a2a12b2 100644 --- a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/ValueFactoryTest.java +++ b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/ValueFactoryTest.java @@ -21,6 +21,7 @@ import javax.jcr.RepositoryException; import javax.jcr.ValueFactory; import javax.jcr.ValueFormatException; +import org.apache.jackrabbit.oak.fixture.NodeStoreFixture; import org.junit.Before; import org.junit.Test; diff --git a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/cluster/AbstractClusterTest.java b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/cluster/AbstractClusterTest.java index f10a1b9..50ab136 100644 --- a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/cluster/AbstractClusterTest.java +++ b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/cluster/AbstractClusterTest.java @@ -25,8 +25,8 @@ import javax.jcr.SimpleCredentials; import junit.framework.Assert; +import org.apache.jackrabbit.oak.fixture.NodeStoreFixture; import org.apache.jackrabbit.oak.jcr.Jcr; -import org.apache.jackrabbit.oak.jcr.NodeStoreFixture; import org.apache.jackrabbit.oak.plugins.document.DocumentNodeStore; import org.apache.jackrabbit.oak.spi.state.NodeStore; import org.junit.After; diff --git a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/cluster/FailoverTest.java b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/cluster/FailoverTest.java index e0f33a1..c2d6fa5 100644 --- a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/cluster/FailoverTest.java +++ b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/cluster/FailoverTest.java @@ -16,7 +16,8 @@ */ package org.apache.jackrabbit.oak.jcr.cluster; -import org.apache.jackrabbit.oak.jcr.NodeStoreFixture; +import org.apache.jackrabbit.oak.fixture.DocumentMongoFixture; +import org.apache.jackrabbit.oak.fixture.NodeStoreFixture; import org.junit.Ignore; import org.junit.Test; @@ -28,8 +29,8 @@ public class FailoverTest extends AbstractClusterTest { @Override protected NodeStoreFixture getFixture() { - return NodeStoreFixture.createDocumentFixture( - "mongodb://localhost:27017,localhost:27018,localhost:27019/oak"); + return new DocumentMongoFixture( + "mongodb://localhost:27017,localhost:27018,localhost:27019/oak", null); } @Test diff --git a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/cluster/ManyChildrenTest.java b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/cluster/ManyChildrenTest.java index 2b3c481..75638e2 100644 --- a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/cluster/ManyChildrenTest.java +++ b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/cluster/ManyChildrenTest.java @@ -25,8 +25,8 @@ import javax.jcr.RepositoryException; import javax.jcr.Session; import javax.jcr.SimpleCredentials; +import org.apache.jackrabbit.oak.fixture.NodeStoreFixture; import org.apache.jackrabbit.oak.jcr.Jcr; -import org.apache.jackrabbit.oak.jcr.NodeStoreFixture; import org.apache.jackrabbit.oak.plugins.nodetype.NodeTypeConstants; import org.apache.jackrabbit.oak.spi.state.NodeStore; import org.h2.util.Profiler; diff --git a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/nodetype/NodeTypeTest.java b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/nodetype/NodeTypeTest.java index 3596c7a..452329d 100644 --- a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/nodetype/NodeTypeTest.java +++ b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/nodetype/NodeTypeTest.java @@ -35,8 +35,8 @@ import javax.jcr.nodetype.NodeTypeTemplate; import javax.jcr.nodetype.PropertyDefinitionTemplate; import org.apache.jackrabbit.JcrConstants; +import org.apache.jackrabbit.oak.fixture.NodeStoreFixture; import org.apache.jackrabbit.oak.jcr.AbstractRepositoryTest; -import org.apache.jackrabbit.oak.jcr.NodeStoreFixture; import org.junit.Test; public class NodeTypeTest extends AbstractRepositoryTest { diff --git a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/observation/ObservationRefreshTest.java b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/observation/ObservationRefreshTest.java index 986246b..f8ba68b 100644 --- a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/observation/ObservationRefreshTest.java +++ b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/observation/ObservationRefreshTest.java @@ -47,9 +47,9 @@ import javax.jcr.observation.ObservationManager; import org.apache.jackrabbit.JcrConstants; import org.apache.jackrabbit.api.JackrabbitRepository; +import org.apache.jackrabbit.oak.fixture.NodeStoreFixture; import org.apache.jackrabbit.oak.jcr.AbstractRepositoryTest; import org.apache.jackrabbit.oak.jcr.Jcr; -import org.apache.jackrabbit.oak.jcr.NodeStoreFixture; import org.apache.jackrabbit.oak.jcr.repository.RepositoryImpl; import org.apache.jackrabbit.test.api.util.Text; import org.junit.After; diff --git a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/observation/ObservationTest.java b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/observation/ObservationTest.java index 6b51e82..493b30b 100644 --- a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/observation/ObservationTest.java +++ b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/observation/ObservationTest.java @@ -76,8 +76,8 @@ import org.apache.jackrabbit.api.observation.JackrabbitEventFilter; import org.apache.jackrabbit.api.observation.JackrabbitObservationManager; import org.apache.jackrabbit.oak.api.PropertyState; import org.apache.jackrabbit.oak.commons.PathUtils; +import org.apache.jackrabbit.oak.fixture.NodeStoreFixture; import org.apache.jackrabbit.oak.jcr.AbstractRepositoryTest; -import org.apache.jackrabbit.oak.jcr.NodeStoreFixture; import org.apache.jackrabbit.oak.plugins.observation.filter.FilterBuilder; import org.apache.jackrabbit.oak.plugins.observation.filter.Selectors; import org.junit.After; diff --git a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/query/QueryFulltextTest.java b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/query/QueryFulltextTest.java index 0d11286..6f7b427 100644 --- a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/query/QueryFulltextTest.java +++ b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/query/QueryFulltextTest.java @@ -30,8 +30,8 @@ import javax.jcr.query.QueryResult; import javax.jcr.query.Row; import javax.jcr.query.RowIterator; +import org.apache.jackrabbit.oak.fixture.NodeStoreFixture; import org.apache.jackrabbit.oak.jcr.AbstractRepositoryTest; -import org.apache.jackrabbit.oak.jcr.NodeStoreFixture; import org.junit.Test; /** diff --git a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/query/QueryPlanTest.java b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/query/QueryPlanTest.java index 687a07a..a3a82a9 100644 --- a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/query/QueryPlanTest.java +++ b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/query/QueryPlanTest.java @@ -31,8 +31,8 @@ import javax.jcr.query.QueryManager; import javax.jcr.query.QueryResult; import javax.jcr.query.RowIterator; +import org.apache.jackrabbit.oak.fixture.NodeStoreFixture; import org.apache.jackrabbit.oak.jcr.AbstractRepositoryTest; -import org.apache.jackrabbit.oak.jcr.NodeStoreFixture; import org.junit.Ignore; import org.junit.Test; diff --git a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/query/QueryTest.java b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/query/QueryTest.java index f1ebb6c..6f54eb5 100644 --- a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/query/QueryTest.java +++ b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/query/QueryTest.java @@ -54,8 +54,11 @@ import org.apache.jackrabbit.commons.JcrUtils; import org.apache.jackrabbit.commons.cnd.CndImporter; import org.apache.jackrabbit.oak.commons.json.JsonObject; import org.apache.jackrabbit.oak.commons.json.JsopTokenizer; +import org.apache.jackrabbit.oak.fixture.NodeStoreFixture; import org.apache.jackrabbit.oak.jcr.AbstractRepositoryTest; -import org.apache.jackrabbit.oak.jcr.NodeStoreFixture; +import org.apache.jackrabbit.oak.plugins.index.property.OrderedPropertyIndexProvider; +import org.junit.AfterClass; +import org.junit.BeforeClass; import org.junit.Ignore; import org.junit.Test; diff --git a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/query/qom/QomTest.java b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/query/qom/QomTest.java index e1451e0..a9ec3bf 100644 --- a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/query/qom/QomTest.java +++ b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/query/qom/QomTest.java @@ -58,8 +58,8 @@ import javax.jcr.query.qom.Selector; import javax.jcr.query.qom.Source; import javax.jcr.query.qom.UpperCase; +import org.apache.jackrabbit.oak.fixture.NodeStoreFixture; import org.apache.jackrabbit.oak.jcr.AbstractRepositoryTest; -import org.apache.jackrabbit.oak.jcr.NodeStoreFixture; import org.junit.Before; import org.junit.Test; diff --git a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/random/RandomOpCompare.java b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/random/RandomOpCompare.java index 8f9db25..c72fdee 100644 --- a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/random/RandomOpCompare.java +++ b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/random/RandomOpCompare.java @@ -31,8 +31,8 @@ import javax.jcr.RepositoryException; import javax.jcr.Session; import javax.jcr.SimpleCredentials; +import org.apache.jackrabbit.oak.fixture.NodeStoreFixture; import org.apache.jackrabbit.oak.jcr.Jcr; -import org.apache.jackrabbit.oak.jcr.NodeStoreFixture; import org.apache.jackrabbit.oak.plugins.document.DocumentMK; import org.apache.jackrabbit.oak.plugins.document.util.MongoConnection; import org.apache.jackrabbit.oak.spi.state.NodeStore; diff --git a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/authorization/MiscTest.java b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/authorization/MiscTest.java index 2072977..47da15b 100644 --- a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/authorization/MiscTest.java +++ b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/authorization/MiscTest.java @@ -24,8 +24,8 @@ import javax.jcr.RepositoryException; import javax.jcr.Session; import org.apache.jackrabbit.commons.jackrabbit.authorization.AccessControlUtils; +import org.apache.jackrabbit.oak.fixture.NodeStoreFixture; import org.apache.jackrabbit.oak.jcr.AbstractRepositoryTest; -import org.apache.jackrabbit.oak.jcr.NodeStoreFixture; import org.junit.Test; public class MiscTest extends AbstractRepositoryTest { diff --git a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/version/VersionablePathNodeStoreTest.java b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/version/VersionablePathNodeStoreTest.java index c3ca82c..6ff1c0f 100644 --- a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/version/VersionablePathNodeStoreTest.java +++ b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/version/VersionablePathNodeStoreTest.java @@ -22,8 +22,8 @@ import javax.jcr.Node; import javax.jcr.RepositoryException; import javax.jcr.Session; +import org.apache.jackrabbit.oak.fixture.NodeStoreFixture; import org.apache.jackrabbit.oak.jcr.AbstractRepositoryTest; -import org.apache.jackrabbit.oak.jcr.NodeStoreFixture; import org.junit.Before; import org.junit.Test; diff --git a/oak-parent/pom.xml b/oak-parent/pom.xml index 72152b2..8f601ac 100644 --- a/oak-parent/pom.xml +++ b/oak-parent/pom.xml @@ -193,6 +193,7 @@ ${mongo.port} ${mongo.db} ${mongo.db2} + ${mongo.url} ${segment.db} ${fixtures} diff --git a/oak-remote/pom.xml b/oak-remote/pom.xml index b8e41e3..b766364 100644 --- a/oak-remote/pom.xml +++ b/oak-remote/pom.xml @@ -166,6 +166,17 @@ 1.9.10 compile + + commons-lang + commons-lang + test + + + com.h2database + h2 + ${h2.version} + test + diff --git a/oak-remote/src/test/java/org/apache/jackrabbit/oak/remote/http/handler/RemoteServerIT.java b/oak-remote/src/test/java/org/apache/jackrabbit/oak/remote/http/handler/RemoteServerIT.java index bd86ce8..5ddf2f4 100644 --- a/oak-remote/src/test/java/org/apache/jackrabbit/oak/remote/http/handler/RemoteServerIT.java +++ b/oak-remote/src/test/java/org/apache/jackrabbit/oak/remote/http/handler/RemoteServerIT.java @@ -21,7 +21,6 @@ import com.google.common.base.Charsets; import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.JsonNode; import org.apache.commons.io.IOUtils; -import org.apache.jackrabbit.oak.NodeStoreFixture; import org.apache.jackrabbit.oak.Oak; import org.apache.jackrabbit.oak.OakBaseTest; import org.apache.jackrabbit.oak.api.ContentRepository; @@ -29,6 +28,7 @@ import org.apache.jackrabbit.oak.api.ContentSession; import org.apache.jackrabbit.oak.api.Root; import org.apache.jackrabbit.oak.api.Tree; import org.apache.jackrabbit.oak.api.Type; +import org.apache.jackrabbit.oak.fixture.NodeStoreFixture; import org.apache.jackrabbit.oak.jcr.Jcr; import org.apache.jackrabbit.oak.remote.RemoteRepository; import org.apache.jackrabbit.oak.remote.content.ContentRemoteRepository;