| /* |
| * 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.sling.karaf.tests.bootstrap; |
| |
| import java.io.IOException; |
| |
| import de.flapdoodle.embed.mongo.MongodExecutable; |
| import de.flapdoodle.embed.mongo.MongodProcess; |
| import de.flapdoodle.embed.mongo.MongodStarter; |
| import de.flapdoodle.embed.mongo.config.IMongodConfig; |
| import de.flapdoodle.embed.mongo.config.MongodConfigBuilder; |
| import de.flapdoodle.embed.mongo.config.Net; |
| import de.flapdoodle.embed.mongo.distribution.Version; |
| import de.flapdoodle.embed.process.runtime.Network; |
| import org.junit.AfterClass; |
| import org.junit.Test; |
| import org.junit.runner.RunWith; |
| import org.ops4j.pax.exam.Configuration; |
| import org.ops4j.pax.exam.Option; |
| import org.ops4j.pax.exam.OptionUtils; |
| import org.ops4j.pax.exam.junit.PaxExam; |
| import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy; |
| import org.ops4j.pax.exam.spi.reactors.PerClass; |
| import org.osgi.framework.Bundle; |
| |
| import static org.junit.Assert.assertEquals; |
| import static org.junit.Assert.assertNotNull; |
| import static org.ops4j.pax.exam.CoreOptions.mavenBundle; |
| import static org.ops4j.pax.exam.CoreOptions.wrappedBundle; |
| import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.editConfigurationFilePut; |
| |
| @RunWith(PaxExam.class) |
| @ExamReactorStrategy(PerClass.class) |
| public class SlingQuickstartOakMongoIT extends AbstractSlingQuickstartOakTestSupport { |
| |
| private static MongodExecutable executable; |
| |
| private static MongodProcess process; |
| |
| protected void startMongo(final int port) throws IOException { |
| final MongodStarter starter = MongodStarter.getDefaultInstance(); |
| final Net net = new Net(port, Network.localhostIsIPv6()); |
| final IMongodConfig mongodConfig = new MongodConfigBuilder().version(Version.Main.PRODUCTION).net(net).build(); |
| executable = starter.prepare(mongodConfig); |
| process = executable.start(); |
| } |
| |
| @AfterClass // TODO does it work? (no - not supported by Pax Exam) |
| public static void stopMongo() throws Exception { |
| if (executable != null) { |
| executable.stop(); |
| } |
| } |
| |
| @Configuration |
| public Option[] configuration() throws IOException { |
| final int port = Network.getFreeServerPort(); |
| startMongo(port); |
| final String mongoUri = String.format("mongodb://localhost:%s", port); |
| return OptionUtils.combine(baseConfiguration(), |
| editConfigurationFilePut("etc/org.apache.karaf.features.cfg", "featuresBoot", "(wrap)"), |
| editConfigurationFilePut("etc/org.apache.jackrabbit.oak.plugins.document.DocumentNodeStoreService.config", "mongouri", mongoUri), |
| wrappedBundle(mavenBundle().groupId("de.flapdoodle.embed").artifactId("de.flapdoodle.embed.mongo").versionAsInProject()), |
| wrappedBundle(mavenBundle().groupId("de.flapdoodle.embed").artifactId("de.flapdoodle.embed.process").versionAsInProject()), |
| wrappedBundle(mavenBundle().groupId("net.java.dev.jna").artifactId("jna").versionAsInProject()), |
| wrappedBundle(mavenBundle().groupId("net.java.dev.jna").artifactId("jna-platform").versionAsInProject()), |
| mavenBundle().groupId("org.apache.commons").artifactId("commons-compress").versionAsInProject(), |
| addSlingFeatures("sling-quickstart-oak-mongo") |
| ); |
| } |
| |
| @Test |
| public void testOrgApacheSlingJcrOakServer() { |
| final Bundle bundle = findBundle("org.apache.sling.jcr.oak.server"); |
| assertNotNull(bundle); |
| assertEquals(Bundle.ACTIVE, bundle.getState()); |
| } |
| |
| @Test |
| public void testOrgApacheJackrabbitOakStoreDocument() { |
| final Bundle bundle = findBundle("org.apache.jackrabbit.oak-store-document"); |
| assertNotNull(bundle); |
| assertEquals(Bundle.ACTIVE, bundle.getState()); |
| } |
| |
| @Test |
| public void testOrgApacheJackrabbitOakLucene() { |
| final Bundle bundle = findBundle("org.apache.jackrabbit.oak-lucene"); |
| assertNotNull(bundle); |
| assertEquals(Bundle.ACTIVE, bundle.getState()); |
| } |
| |
| @Test |
| public void testOrgMongodbMongoJavaDriver() { |
| final Bundle bundle = findBundle("org.mongodb.mongo-java-driver"); |
| assertNotNull(bundle); |
| assertEquals(Bundle.ACTIVE, bundle.getState()); |
| } |
| |
| @Test |
| public void testComH2databaseH2Mvstore() { |
| final Bundle bundle = findBundle("org.h2.mvstore"); |
| assertNotNull(bundle); |
| assertEquals(Bundle.ACTIVE, bundle.getState()); |
| } |
| |
| } |