Index: oak-it/osgi/src/test/java/org/apache/jackrabbit/oak/osgi/SlingRepositoryIT.java =================================================================== --- oak-it/osgi/src/test/java/org/apache/jackrabbit/oak/osgi/SlingRepositoryIT.java (revision 0) +++ oak-it/osgi/src/test/java/org/apache/jackrabbit/oak/osgi/SlingRepositoryIT.java (revision 0) @@ -0,0 +1,61 @@ +/* + * 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.osgi; + +import static junit.framework.Assert.assertNotNull; +import static junit.framework.Assert.assertTrue; + +import java.io.IOException; +import java.net.URISyntaxException; +import java.util.regex.Pattern; + +import javax.inject.Inject; + +import org.apache.sling.jcr.api.SlingRepository; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.ops4j.pax.exam.Option; +import org.ops4j.pax.exam.junit.Configuration; +import org.ops4j.pax.exam.junit.JUnit4TestRunner; + +@RunWith(JUnit4TestRunner.class) +public class SlingRepositoryIT { + + private static final Option [] SLING_BUNDLES = { + PaxConfig.jarBundle("oak-sling.jar"), + PaxConfig.jarBundle("org.apache.sling.jcr.api.jar") + }; + + @Configuration + public Option[] configuration() throws IOException, URISyntaxException { + return PaxConfig.configuration(SLING_BUNDLES); + } + + @Inject + private SlingRepository slingRepository; + + @Test + @Ignore("OAK-795") + public void slingRepositoryPresent() { + assertNotNull(slingRepository); + final String repoNameDesc = "jcr.repository.name"; + final String repoName = slingRepository.getDescriptor(repoNameDesc); + assertNotNull("Expecting " + repoNameDesc + " descriptor", repoName); + assertTrue(Pattern.matches(".*[Oo]ak.*", repoName)); + } +} Property changes on: oak-it/osgi/src/test/java/org/apache/jackrabbit/oak/osgi/SlingRepositoryIT.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Rev URL Added: svn:eol-style + native Index: oak-it/osgi/src/test/java/org/apache/jackrabbit/oak/osgi/OakServicesIT.java =================================================================== --- oak-it/osgi/src/test/java/org/apache/jackrabbit/oak/osgi/OakServicesIT.java (revision 1478748) +++ oak-it/osgi/src/test/java/org/apache/jackrabbit/oak/osgi/OakServicesIT.java (working copy) @@ -16,77 +16,48 @@ */ package org.apache.jackrabbit.oak.osgi; -import java.io.File; +import static junit.framework.Assert.assertNotNull; +import static junit.framework.Assert.assertTrue; + import java.io.IOException; -import java.net.MalformedURLException; import java.net.URISyntaxException; import java.util.regex.Pattern; import javax.inject.Inject; +import javax.jcr.Credentials; import javax.jcr.Repository; +import javax.jcr.Session; +import javax.jcr.SimpleCredentials; import org.apache.jackrabbit.mk.api.MicroKernel; import org.apache.jackrabbit.oak.api.ContentRepository; import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; -import org.ops4j.pax.exam.CoreOptions; import org.ops4j.pax.exam.Option; import org.ops4j.pax.exam.junit.Configuration; import org.ops4j.pax.exam.junit.JUnit4TestRunner; -import org.ops4j.pax.exam.options.SystemPropertyOption; -import org.ops4j.pax.exam.options.UrlProvisionOption; -import static junit.framework.Assert.assertNotNull; -import static junit.framework.Assert.assertTrue; -import static org.ops4j.pax.exam.CoreOptions.bundle; -import static org.ops4j.pax.exam.CoreOptions.junitBundles; -import static org.ops4j.pax.exam.CoreOptions.mavenBundle; -import static org.ops4j.pax.exam.CoreOptions.systemProperties; - @RunWith(JUnit4TestRunner.class) -public class OSGiIT { +public class OakServicesIT { + private static final Credentials ADMIN_CREDENTIALS = new SimpleCredentials("admin", "admin".toCharArray()); + @Configuration public Option[] configuration() throws IOException, URISyntaxException { - return CoreOptions.options( - junitBundles(), - mavenBundle("org.apache.felix", "org.apache.felix.scr", "1.6.0"), - mavenBundle( "org.apache.felix", "org.apache.felix.configadmin", "1.4.0" ), - mavenBundle( "org.apache.felix", "org.apache.felix.fileinstall", "3.2.6" ), - systemProperties(new SystemPropertyOption("felix.fileinstall.dir").value(getConfigDir())), - jarBundle("jcr.jar"), - jarBundle("guava.jar"), - jarBundle("jackrabbit-api.jar"), - jarBundle("jackrabbit-jcr-commons.jar"), - jarBundle("oak-commons.jar"), - jarBundle("oak-mk-api.jar"), - jarBundle("oak-mk.jar"), - jarBundle("oak-mk-remote.jar"), - jarBundle("oak-core.jar"), - jarBundle("oak-lucene.jar"), - jarBundle("oak-jcr.jar"), - jarBundle("tika-core.jar")); + return PaxConfig.configuration(); } - private String getConfigDir(){ - return new File(new File("src", "test"), "config").getAbsolutePath(); - } - - private UrlProvisionOption jarBundle(String jar) - throws MalformedURLException { - File target = new File("target"); - File bundles = new File(target, "test-bundles"); - return bundle(new File(bundles, jar).toURI().toURL().toString()); - } - @Inject private MicroKernel kernel; @Test - @Ignore("OAK-454") + @Ignore("OAK-795") public void testMicroKernel() { assertNotNull(kernel); + // TODO fails intermittently with + // java.lang.IllegalStateException: this instance has already been disposed + // at org.apache.jackrabbit.mk.core.MicroKernelImpl.getHeadRevision(MicroKernelImpl.java:109) assertTrue(Pattern.matches("[0-9a-f]+", kernel.getHeadRevision())); } @@ -95,9 +66,9 @@ @Test @Ignore("OAK-795") - public void testOakRepository() { + public void testOakRepository() throws Exception { assertNotNull(oakRepository); - // TODO: try something with oakRepository + // TODO do something with oakRepository } @Inject @@ -105,9 +76,13 @@ @Test @Ignore("OAK-795") - public void testJcrRepository() { + public void testJcrRepository() throws Exception { assertNotNull(jcrRepository); - // TODO: try something with jcrRepository + final Session s = jcrRepository.login(ADMIN_CREDENTIALS, null); + try { + assertNotNull("Expecting non-null Session", s); + } finally { + s.logout(); + } } - } Property changes on: oak-it/osgi/src/test/java/org/apache/jackrabbit/oak/osgi/OakServicesIT.java ___________________________________________________________________ Added: svn:eol-style + native Index: oak-it/osgi/src/test/java/org/apache/jackrabbit/oak/osgi/OSGiIT.java =================================================================== --- oak-it/osgi/src/test/java/org/apache/jackrabbit/oak/osgi/OSGiIT.java (revision 1478748) +++ oak-it/osgi/src/test/java/org/apache/jackrabbit/oak/osgi/OSGiIT.java (working copy) @@ -1,113 +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.osgi; - -import java.io.File; -import java.io.IOException; -import java.net.MalformedURLException; -import java.net.URISyntaxException; -import java.util.regex.Pattern; - -import javax.inject.Inject; -import javax.jcr.Repository; - -import org.apache.jackrabbit.mk.api.MicroKernel; -import org.apache.jackrabbit.oak.api.ContentRepository; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.ops4j.pax.exam.CoreOptions; -import org.ops4j.pax.exam.Option; -import org.ops4j.pax.exam.junit.Configuration; -import org.ops4j.pax.exam.junit.JUnit4TestRunner; -import org.ops4j.pax.exam.options.SystemPropertyOption; -import org.ops4j.pax.exam.options.UrlProvisionOption; - -import static junit.framework.Assert.assertNotNull; -import static junit.framework.Assert.assertTrue; -import static org.ops4j.pax.exam.CoreOptions.bundle; -import static org.ops4j.pax.exam.CoreOptions.junitBundles; -import static org.ops4j.pax.exam.CoreOptions.mavenBundle; -import static org.ops4j.pax.exam.CoreOptions.systemProperties; - -@RunWith(JUnit4TestRunner.class) -public class OSGiIT { - - @Configuration - public Option[] configuration() throws IOException, URISyntaxException { - return CoreOptions.options( - junitBundles(), - mavenBundle("org.apache.felix", "org.apache.felix.scr", "1.6.0"), - mavenBundle( "org.apache.felix", "org.apache.felix.configadmin", "1.4.0" ), - mavenBundle( "org.apache.felix", "org.apache.felix.fileinstall", "3.2.6" ), - systemProperties(new SystemPropertyOption("felix.fileinstall.dir").value(getConfigDir())), - jarBundle("jcr.jar"), - jarBundle("guava.jar"), - jarBundle("jackrabbit-api.jar"), - jarBundle("jackrabbit-jcr-commons.jar"), - jarBundle("oak-commons.jar"), - jarBundle("oak-mk-api.jar"), - jarBundle("oak-mk.jar"), - jarBundle("oak-mk-remote.jar"), - jarBundle("oak-core.jar"), - jarBundle("oak-lucene.jar"), - jarBundle("oak-jcr.jar"), - jarBundle("tika-core.jar")); - } - - private String getConfigDir(){ - return new File(new File("src", "test"), "config").getAbsolutePath(); - } - - private UrlProvisionOption jarBundle(String jar) - throws MalformedURLException { - File target = new File("target"); - File bundles = new File(target, "test-bundles"); - return bundle(new File(bundles, jar).toURI().toURL().toString()); - } - - @Inject - private MicroKernel kernel; - - @Test - @Ignore("OAK-454") - public void testMicroKernel() { - assertNotNull(kernel); - assertTrue(Pattern.matches("[0-9a-f]+", kernel.getHeadRevision())); - } - - @Inject - private ContentRepository oakRepository; - - @Test - @Ignore("OAK-795") - public void testOakRepository() { - assertNotNull(oakRepository); - // TODO: try something with oakRepository - } - - @Inject - private Repository jcrRepository; - - @Test - @Ignore("OAK-795") - public void testJcrRepository() { - assertNotNull(jcrRepository); - // TODO: try something with jcrRepository - } - -} Index: oak-it/osgi/src/test/java/org/apache/jackrabbit/oak/osgi/PaxConfig.java =================================================================== --- oak-it/osgi/src/test/java/org/apache/jackrabbit/oak/osgi/PaxConfig.java (revision 0) +++ oak-it/osgi/src/test/java/org/apache/jackrabbit/oak/osgi/PaxConfig.java (revision 0) @@ -0,0 +1,72 @@ +/* + * 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.osgi; + +import static org.ops4j.pax.exam.CoreOptions.bundle; +import static org.ops4j.pax.exam.CoreOptions.junitBundles; +import static org.ops4j.pax.exam.CoreOptions.mavenBundle; +import static org.ops4j.pax.exam.CoreOptions.systemProperties; + +import java.io.File; +import java.io.IOException; +import java.net.MalformedURLException; +import java.net.URISyntaxException; + +import org.ops4j.pax.exam.CoreOptions; +import org.ops4j.pax.exam.Option; +import org.ops4j.pax.exam.options.SystemPropertyOption; +import org.ops4j.pax.exam.options.UrlProvisionOption; + +class PaxConfig { + + static Option[] configuration(Option ... additionalOptions) throws IOException, URISyntaxException { + // Standard config, used by all tests + return CoreOptions.options( + junitBundles(), + mavenBundle("org.apache.felix", "org.apache.felix.scr", "1.6.0"), + mavenBundle( "org.apache.felix", "org.apache.felix.configadmin", "1.4.0" ), + mavenBundle( "org.apache.felix", "org.apache.felix.fileinstall", "3.2.6" ), + systemProperties(new SystemPropertyOption("felix.fileinstall.dir").value(getConfigDir())), + jarBundle("jcr.jar"), + jarBundle("guava.jar"), + jarBundle("jackrabbit-api.jar"), + jarBundle("jackrabbit-jcr-commons.jar"), + jarBundle("oak-commons.jar"), + jarBundle("oak-mk-api.jar"), + jarBundle("oak-mk.jar"), + jarBundle("oak-mk-remote.jar"), + jarBundle("oak-core.jar"), + jarBundle("oak-lucene.jar"), + jarBundle("oak-jcr.jar"), + jarBundle("tika-core.jar"), + CoreOptions.composite(additionalOptions)); + } + + private static String getConfigDir(){ + return new File(new File("src", "test"), "config").getAbsolutePath(); + } + + public static UrlProvisionOption jarBundle(String jar) { + try { + final File bundles = new File("target/test-bundles"); + return bundle(new File(bundles, jar).toURI().toURL().toString()); + } catch (MalformedURLException e) { + throw new Error("MalformedURLException: " + jar, e); + } + } + +} Property changes on: oak-it/osgi/src/test/java/org/apache/jackrabbit/oak/osgi/PaxConfig.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Rev URL Added: svn:eol-style + native Index: oak-it/osgi/test-bundles.xml =================================================================== --- oak-it/osgi/test-bundles.xml (revision 1478748) +++ oak-it/osgi/test-bundles.xml (working copy) @@ -39,7 +39,9 @@ org.apache.jackrabbit:oak-core org.apache.jackrabbit:oak-jcr org.apache.jackrabbit:oak-lucene + org.apache.jackrabbit:oak-sling org.apache.tika:tika-core + org.apache.sling:org.apache.sling.jcr.api Index: oak-it/osgi/pom.xml =================================================================== --- oak-it/osgi/pom.xml (revision 1478748) +++ oak-it/osgi/pom.xml (working copy) @@ -33,6 +33,7 @@ true 2.4.0 + WARN @@ -58,7 +59,7 @@ - WARN + ${org.ops4j.pax.logging.DefaultServiceLog.level} @@ -109,6 +110,18 @@ ${project.version} test + + org.apache.jackrabbit + oak-sling + ${project.version} + test + + + org.apache.sling + org.apache.sling.jcr.api + 2.1.0 + test + org.ops4j.pax.exam