You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ol...@apache.org on 2018/09/13 16:31:19 UTC
[sling-org-apache-sling-jcr-contentloader] branch master updated:
SLING-7923 Simplify integration tests
This is an automated email from the ASF dual-hosted git repository.
olli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-contentloader.git
The following commit(s) were added to refs/heads/master by this push:
new f4e4679 SLING-7923 Simplify integration tests
f4e4679 is described below
commit f4e467903b6b5ecca901492de3642773f3b30967
Author: Oliver Lietz <ol...@apache.org>
AuthorDate: Thu Sep 13 18:31:05 2018 +0200
SLING-7923 Simplify integration tests
* remove boilerplate code and use Testing PaxExam instead
* use Sling Parent 34 and bnd Maven plugins
---
bnd.bnd | 8 +
pom.xml | 288 ++++++++++-----------
.../contentloader/it/BasicInitialContentIT.java | 22 +-
.../contentloader/it/ContentBundleTestBase.java | 195 --------------
.../contentloader/it/ContentloaderTestSupport.java | 155 +++++++++++
.../jcr/contentloader/it/I18nInitialContentIT.java | 22 +-
.../contentloader/it/OrderedInitialContentIT.java | 20 +-
.../jcr/contentloader/it/PaxExamUtilities.java | 217 ----------------
.../it/SLING7268InitialContentIT.java | 21 +-
9 files changed, 333 insertions(+), 615 deletions(-)
diff --git a/bnd.bnd b/bnd.bnd
new file mode 100644
index 0000000..9e22f40
--- /dev/null
+++ b/bnd.bnd
@@ -0,0 +1,8 @@
+Bundle-Category:\
+ sling,\
+ jcr,\
+ jackrabbit
+
+-includeresource:\
+ @kxml2-*.jar,\
+ @org.apache.sling.jcr.contentparser-*.jar!/org/apache/sling/jcr/contentparser/impl/JsonTicksConverter.class
diff --git a/pom.xml b/pom.xml
index 398575e..fd2cb52 100644
--- a/pom.xml
+++ b/pom.xml
@@ -24,60 +24,39 @@
<parent>
<groupId>org.apache.sling</groupId>
<artifactId>sling</artifactId>
- <version>31</version>
+ <version>34</version>
<relativePath />
</parent>
<artifactId>org.apache.sling.jcr.contentloader</artifactId>
<version>2.2.7-SNAPSHOT</version>
- <packaging>bundle</packaging>
<name>Apache Sling Initial Content Loader</name>
<description>This bundle provides initial content installation through bundles.</description>
- <properties>
- <exam.version>4.11.0</exam.version>
- <url.version>2.5.2</url.version>
- <bundle.file.name>${basedir}/target/${project.build.finalName}.jar</bundle.file.name>
- <sling.launchpad.version>9</sling.launchpad.version>
- <pax.vm.options>-Xmx256M -XX:MaxPermSize=256m</pax.vm.options>
- <dump.test.bundles>false</dump.test.bundles>
- <!-- argLine needs to be here so that jacoco plugin adds its own stuff to it -->
- <argLine>${pax.vm.options}</argLine>
- </properties>
+ <properties>
+ <sling.java.version>8</sling.java.version>
+ <org.ops4j.pax.exam.version>4.12.0</org.ops4j.pax.exam.version>
+ </properties>
- <scm>
- <connection>scm:git:https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-contentloader.git</connection>
- <developerConnection>scm:git:https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-contentloader.git</developerConnection>
- <url>https://gitbox.apache.org/repos/asf?p=sling-org-apache-sling-jcr-contentloader.git</url>
- <tag>HEAD</tag>
+ <scm>
+ <connection>scm:git:https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-contentloader.git</connection>
+ <developerConnection>scm:git:https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-contentloader.git
+ </developerConnection>
+ <url>https://gitbox.apache.org/repos/asf?p=sling-org-apache-sling-jcr-contentloader.git</url>
+ <tag>HEAD</tag>
</scm>
<build>
<plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Bundle-Category>
- sling,
- jcr,
- jackrabbit
- </Bundle-Category>
- <Private-Package>
- org.apache.sling.jcr.contentloader.internal.*,
- org.kxml2.io,
- org.xmlpull.v1
- </Private-Package>
- <Embed-Dependency>
- kxml2,
- org.apache.sling.jcr.contentparser;inline="org/apache/sling/jcr/contentparser/impl/JsonTicksConverter.class"
- </Embed-Dependency>
- </instructions>
- </configuration>
- </plugin>
+ <plugin>
+ <groupId>biz.aQute.bnd</groupId>
+ <artifactId>bnd-maven-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>biz.aQute.bnd</groupId>
+ <artifactId>bnd-baseline-maven-plugin</artifactId>
+ </plugin>
<plugin>
<groupId>org.apache.rat</groupId>
<artifactId>apache-rat-plugin</artifactId>
@@ -92,44 +71,31 @@
</excludes>
</configuration>
</plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-failsafe-plugin</artifactId>
- <executions>
- <execution>
- <goals>
- <goal>integration-test</goal>
- <goal>verify</goal>
- </goals>
- </execution>
- </executions>
- <configuration>
- <systemPropertyVariables>
- <java.protocol.handler.pkgs>org.ops4j.pax.url</java.protocol.handler.pkgs>
- <bundle.file.name>${bundle.file.name}</bundle.file.name>
- <sling.launchpad.version>${sling.launchpad.version}</sling.launchpad.version>
- <dump.test.bundles>${dump.test.bundles}</dump.test.bundles>
- </systemPropertyVariables>
- <classpathDependencyExcludes>
- <!-- The osgi.org dependencies cause trouble with pax exam -->
- <classpathDependencyExcludes>org.osgi:org.osgi.core</classpathDependencyExcludes>
- <classpathDependencyExcludes>org.osgi:org.osgi.compendium</classpathDependencyExcludes>
- </classpathDependencyExcludes>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.servicemix.tooling</groupId>
- <artifactId>depends-maven-plugin</artifactId>
- <version>1.3.1</version>
- <executions>
- <execution>
- <id>generate-depends-file</id>
- <goals>
- <goal>generate-depends-file</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-failsafe-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>integration-test</goal>
+ <goal>verify</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <redirectTestOutputToFile>true</redirectTestOutputToFile>
+ <systemProperties>
+ <property>
+ <name>bundle.filename</name>
+ <value>${basedir}/target/${project.build.finalName}.jar</value>
+ </property>
+ </systemProperties>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.servicemix.tooling</groupId>
+ <artifactId>depends-maven-plugin</artifactId>
+ </plugin>
</plugins>
</build>
@@ -146,16 +112,27 @@
</reporting>
<dependencies>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.service.component.annotations</artifactId>
- <version>1.3.0</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>osgi.core</artifactId>
- </dependency>
+ <!-- OSGi -->
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.annotation.versioning</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>osgi.core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.service.component.annotations</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.service.metatype.annotations</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <!-- -->
<dependency>
<groupId>javax.jcr</groupId>
<artifactId>jcr</artifactId>
@@ -169,8 +146,7 @@
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.jcr.contentparser</artifactId>
- <version>1.2.2</version>
- <scope>provided</scope>
+ <version>1.2.6</version>
<exclusions>
<exclusion>
<groupId>*</groupId>
@@ -194,7 +170,7 @@
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.commons.testing</artifactId>
- <version>2.0.18</version>
+ <version>2.1.2</version>
<scope>test</scope>
</dependency>
<dependency>
@@ -223,7 +199,6 @@
<groupId>net.sf.kxml</groupId>
<artifactId>kxml2</artifactId>
<version>2.2.2</version>
- <scope>provided</scope>
<exclusions>
<exclusion>
<groupId>xmlpull</groupId>
@@ -237,13 +212,28 @@
<version>2.4</version>
<scope>provided</scope>
</dependency>
+ <!-- Apache Felix -->
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.framework</artifactId>
+ <version>5.6.10</version>
+ <scope>test</scope>
+ </dependency>
+ <!-- Apache Sling -->
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.resource.presence</artifactId>
+ <version>0.0.2</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.testing.paxexam</artifactId>
+ <version>2.0.0</version>
+ <scope>test</scope>
+ </dependency>
<!-- testing -->
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
<groupId>org.jmock</groupId>
<artifactId>jmock-junit4</artifactId>
<scope>test</scope>
@@ -302,70 +292,52 @@
<scope>test</scope>
</dependency>
<dependency>
- <groupId>org.ops4j.pax.exam</groupId>
- <artifactId>pax-exam-container-forked</artifactId>
- <version>${exam.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.ops4j.pax.exam</groupId>
- <artifactId>pax-exam-junit4</artifactId>
- <version>${exam.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.ops4j.pax.exam</groupId>
- <artifactId>pax-exam-link-mvn</artifactId>
- <version>${exam.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.ops4j.pax.url</groupId>
- <artifactId>pax-url-aether</artifactId>
- <version>${url.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.ops4j.pax.exam</groupId>
- <artifactId>pax-exam-cm</artifactId>
- <version>${exam.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.ops4j.pax.url</groupId>
- <artifactId>pax-url-wrap</artifactId>
- <version>2.5.2</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.ops4j.pax.tinybundles</groupId>
- <artifactId>tinybundles</artifactId>
- <version>2.0.0</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>biz.aQute.bnd</groupId>
- <artifactId>bndlib</artifactId>
- <version>2.1.0</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.framework</artifactId>
- <version>5.6.6</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.launchpad.api</artifactId>
- <version>1.2.0</version>
- <type>bundle</type>
- <scope>test</scope>
- </dependency>
- <dependency>
<groupId>org.apache.jackrabbit</groupId>
<artifactId>jackrabbit-jcr-commons</artifactId>
<version>2.2.9</version>
</dependency>
+ <!-- testing -->
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.servicemix.bundles</groupId>
+ <artifactId>org.apache.servicemix.bundles.hamcrest</artifactId>
+ <version>1.3_1</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.ops4j.pax.exam</groupId>
+ <artifactId>pax-exam</artifactId>
+ <version>${org.ops4j.pax.exam.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.ops4j.pax.exam</groupId>
+ <artifactId>pax-exam-cm</artifactId>
+ <version>${org.ops4j.pax.exam.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.ops4j.pax.exam</groupId>
+ <artifactId>pax-exam-container-forked</artifactId>
+ <version>${org.ops4j.pax.exam.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.ops4j.pax.exam</groupId>
+ <artifactId>pax-exam-junit4</artifactId>
+ <version>${org.ops4j.pax.exam.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.ops4j.pax.exam</groupId>
+ <artifactId>pax-exam-link-mvn</artifactId>
+ <version>${org.ops4j.pax.exam.version}</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
+
</project>
diff --git a/src/test/java/org/apache/sling/jcr/contentloader/it/BasicInitialContentIT.java b/src/test/java/org/apache/sling/jcr/contentloader/it/BasicInitialContentIT.java
index c5df7e3..5dbd02c 100644
--- a/src/test/java/org/apache/sling/jcr/contentloader/it/BasicInitialContentIT.java
+++ b/src/test/java/org/apache/sling/jcr/contentloader/it/BasicInitialContentIT.java
@@ -18,25 +18,27 @@
*/
package org.apache.sling.jcr.contentloader.it;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
import java.io.IOException;
import javax.jcr.RepositoryException;
-import org.apache.sling.commons.testing.junit.Retry;
import org.junit.Test;
import org.junit.runner.RunWith;
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.ops4j.pax.tinybundles.core.TinyBundle;
import org.osgi.framework.Bundle;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
/** Basic test of a bundle that provides initial content */
@RunWith(PaxExam.class)
-public class BasicInitialContentIT extends ContentBundleTestBase {
-
+@ExamReactorStrategy(PerClass.class)
+public class BasicInitialContentIT extends ContentloaderTestSupport {
+
protected TinyBundle setupTestBundle(TinyBundle b) throws IOException {
b.set(SLING_INITIAL_CONTENT_HEADER, DEFAULT_PATH_IN_BUNDLE + ";path:=" + contentRootPath);
addContent(b, DEFAULT_PATH_IN_BUNDLE, "basic-content.json");
@@ -47,15 +49,13 @@ public class BasicInitialContentIT extends ContentBundleTestBase {
}
@Test
- @Retry(intervalMsec=RETRY_INTERVAL, timeoutMsec=RETRY_TIMEOUT)
public void bundleStarted() {
- final Bundle b = PaxExamUtilities.findBundle(bundleContext, bundleSymbolicName);
+ final Bundle b = findBundle(bundleSymbolicName);
assertNotNull("Expecting bundle to be found:" + bundleSymbolicName, b);
assertEquals("Expecting bundle to be active:" + bundleSymbolicName, Bundle.ACTIVE, b.getState());
}
@Test
- @Retry(intervalMsec=RETRY_INTERVAL, timeoutMsec=RETRY_TIMEOUT)
public void initialContentInstalled() throws RepositoryException {
final String testNodePath = contentRootPath + "/basic-content/test-node";
assertTrue("Expecting initial content to be installed", session.itemExists(testNodePath));
@@ -63,7 +63,6 @@ public class BasicInitialContentIT extends ContentBundleTestBase {
}
@Test
- @Retry(intervalMsec=RETRY_INTERVAL, timeoutMsec=RETRY_TIMEOUT)
public void folderWithoutDescriptor() throws RepositoryException {
final String folderPath = contentRootPath + "/simple-folder";
assertTrue("folder node " + folderPath + " exists", session.itemExists(folderPath));
@@ -75,7 +74,6 @@ public class BasicInitialContentIT extends ContentBundleTestBase {
}
@Test
- @Retry(intervalMsec=RETRY_INTERVAL, timeoutMsec=RETRY_TIMEOUT)
public void folderWithDescriptor() throws RepositoryException {
final String folderPath = contentRootPath + "/folder-with-descriptor";
assertTrue("folder node " + folderPath + " exists", session.itemExists(folderPath));
diff --git a/src/test/java/org/apache/sling/jcr/contentloader/it/ContentBundleTestBase.java b/src/test/java/org/apache/sling/jcr/contentloader/it/ContentBundleTestBase.java
deleted file mode 100644
index 8204a64..0000000
--- a/src/test/java/org/apache/sling/jcr/contentloader/it/ContentBundleTestBase.java
+++ /dev/null
@@ -1,195 +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.sling.jcr.contentloader.it;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.UUID;
-
-import javax.inject.Inject;
-import javax.jcr.Session;
-
-import org.apache.commons.io.IOUtils;
-import org.apache.sling.commons.testing.junit.RetryRule;
-import org.apache.sling.jcr.api.SlingRepository;
-import org.apache.sling.launchpad.api.StartupHandler;
-import org.apache.sling.launchpad.api.StartupMode;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Rule;
-import org.junit.runner.RunWith;
-import org.ops4j.pax.exam.Option;
-import org.ops4j.pax.exam.junit.PaxExam;
-import org.ops4j.pax.tinybundles.core.TinyBundle;
-import org.ops4j.pax.tinybundles.core.TinyBundles;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.BundleException;
-import org.osgi.framework.Constants;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/** Base class for testing bundles that provide initial content */
-@RunWith(PaxExam.class)
-public abstract class ContentBundleTestBase {
-
- private final Logger log = LoggerFactory.getLogger(getClass());
-
- @Rule
- public final RetryRule retry = new RetryRule(RETRY_TIMEOUT, RETRY_INTERVAL);
-
- @Inject
- protected BundleContext bundleContext;
-
- @Inject
- protected SlingRepository repository;
-
- protected static Session session;
- protected static String bundleSymbolicName;
- protected static String contentRootPath;
- private static final List<Bundle> bundlesToRemove = new ArrayList<>();
-
- protected static final int RETRY_TIMEOUT = 5000;
- protected static final int RETRY_INTERVAL = 100;
- protected static final String SLING_INITIAL_CONTENT_HEADER = "Sling-Initial-Content";
- protected static final String DEFAULT_PATH_IN_BUNDLE = "test-initial-content";
-
- @org.ops4j.pax.exam.Configuration
- public Option[] config() {
- return PaxExamUtilities.paxConfig();
- }
-
- @BeforeClass
- public static void setupClass() {
- bundleSymbolicName = "TEST-" + UUID.randomUUID();
- contentRootPath = "/test-content/" + bundleSymbolicName;
- }
-
- @Before
- public void setup() throws Exception {
- registerStartupHandler();
-
- session = repository.loginAdministrative(null);
-
- // The RetryRule executes this method on every retry, make
- // sure to install our test bundle only once
- if(!bundlesToRemove.isEmpty()) {
- return;
- }
- assertFalse("Expecting no content before test", session.itemExists(contentRootPath));
-
- // Create, install and start a bundle that has initial content
- final InputStream is = getTestBundleStream();
- try {
- final Bundle b = bundleContext.installBundle(bundleSymbolicName, is);
- bundlesToRemove.add(b);
- b.start();
- } finally {
- is.close();
- }
-
- maybeDumpTestBundle();
- }
-
- /** Optionally dump our test bundle, for troubleshooting it */
- private void maybeDumpTestBundle() throws Exception {
- final boolean doDump = Boolean.valueOf(System.getProperty("dump.test.bundles", "false"));
- if(doDump) {
- final File target = File.createTempFile(bundleSymbolicName, ".jar");
- FileOutputStream fos = new FileOutputStream(target);
- try {
- IOUtils.copy(getTestBundleStream(), fos);
- log.info("Dumped test bundle to {} for troubleshooting", target.getAbsolutePath());
- } finally {
- IOUtils.closeQuietly(fos);
- }
- }
- }
-
- private InputStream getTestBundleStream() throws Exception {
- return setupTestBundle(TinyBundles.bundle()
- .set(Constants.BUNDLE_SYMBOLICNAME, bundleSymbolicName)
- ).build(TinyBundles.withBnd());
- }
-
- abstract protected TinyBundle setupTestBundle(TinyBundle b) throws Exception;
-
- /** Add content to our test bundle */
- protected void addContent(TinyBundle b, String pathInBundle, String resourcePath) throws IOException {
- pathInBundle += "/" + resourcePath;
- resourcePath = "/initial-content/" + resourcePath;
- final InputStream is = getClass().getResourceAsStream(resourcePath);
- try {
- assertNotNull("Expecting resource to be found:" + resourcePath, is);
- log.info("Adding resource to bundle, path={}, resource={}", pathInBundle, resourcePath);
- b.add(pathInBundle, is);
- } finally {
- if(is != null) {
- is.close();
- }
- }
- }
-
- @AfterClass
- public static void cleanupClass() throws BundleException {
- for(Bundle b : bundlesToRemove) {
- b.uninstall();
- }
- bundlesToRemove.clear();
-
- session.logout();
- session = null;
- }
-
- private void registerStartupHandler() {
- // SLING-4917 (org.apache.sling.paxexam.util.SlingSetupTest)
- // In Sling launchpad 7 the SlingSettings service
- // requires a StartupHandler, and that's usually provided
- // by the launchpad bootstrap code. Supply our own so that
- // everything starts properly.
- // TODO should be provided by a utility/bootstrap bundle
- final StartupHandler h = new StartupHandler() {
-
- @Override
- public void waitWithStartup(boolean b) {
- }
-
- @Override
- public boolean isFinished() {
- return true;
- }
-
- @Override
- public StartupMode getMode() {
- return StartupMode.INSTALL;
- }
-
- };
-
- bundleContext.registerService(StartupHandler.class.getName(), h, null);
- }
-}
\ No newline at end of file
diff --git a/src/test/java/org/apache/sling/jcr/contentloader/it/ContentloaderTestSupport.java b/src/test/java/org/apache/sling/jcr/contentloader/it/ContentloaderTestSupport.java
new file mode 100644
index 0000000..7e71609
--- /dev/null
+++ b/src/test/java/org/apache/sling/jcr/contentloader/it/ContentloaderTestSupport.java
@@ -0,0 +1,155 @@
+/*
+ * 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.jcr.contentloader.it;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Arrays;
+import java.util.Objects;
+import java.util.UUID;
+
+import javax.inject.Inject;
+import javax.jcr.Session;
+
+import org.apache.sling.jcr.api.SlingRepository;
+import org.apache.sling.testing.paxexam.SlingOptions;
+import org.apache.sling.testing.paxexam.TestSupport;
+import org.junit.After;
+import org.junit.Before;
+import org.ops4j.pax.exam.Configuration;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.options.CompositeOption;
+import org.ops4j.pax.exam.options.DefaultCompositeOption;
+import org.ops4j.pax.tinybundles.core.TinyBundle;
+import org.ops4j.pax.tinybundles.core.TinyBundles;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import static org.apache.sling.testing.paxexam.SlingOptions.slingQuickstartOakTar;
+import static org.apache.sling.testing.paxexam.SlingOptions.slingResourcePresence;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.ops4j.pax.exam.CoreOptions.junitBundles;
+import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
+import static org.ops4j.pax.exam.cm.ConfigurationAdminOptions.newConfiguration;
+
+public abstract class ContentloaderTestSupport extends TestSupport {
+
+ @Inject
+ protected BundleContext bundleContext;
+
+ @Inject
+ protected SlingRepository repository;
+
+ protected Session session;
+
+ protected String bundleSymbolicName;
+
+ protected String contentRootPath;
+
+ protected static final String SLING_INITIAL_CONTENT_HEADER = "Sling-Initial-Content";
+
+ protected static final String DEFAULT_PATH_IN_BUNDLE = "test-initial-content";
+
+ private final Logger logger = LoggerFactory.getLogger(ContentloaderTestSupport.class);
+
+ ContentloaderTestSupport() {
+ }
+
+ @Before
+ public void setup() throws Exception {
+ bundleSymbolicName = "TEST-" + UUID.randomUUID();
+ contentRootPath = "/test-content/" + bundleSymbolicName;
+ session = repository.loginAdministrative(null);
+
+ assertFalse("Expecting no content before test", session.itemExists(contentRootPath));
+
+ // Create, install and start a bundle that has initial content
+ try (InputStream is = getTestBundleStream()) {
+ final Bundle bundle = bundleContext.installBundle(bundleSymbolicName, is);
+ bundle.start();
+ }
+ }
+
+ @After
+ public void teardown() {
+ session.logout();
+ }
+
+ @Configuration
+ public Option[] configuration() {
+ CompositeOption quickstart = (CompositeOption) quickstart();
+ final Option[] options = Arrays.stream(quickstart.getOptions()).filter(e -> !Objects.deepEquals(e,
+ mavenBundle().groupId("org.apache.sling").artifactId("org.apache.sling.jcr.contentloader").version(SlingOptions.versionResolver.getVersion("org.apache.sling", "org.apache.sling.jcr.contentloader"))
+ )).toArray(Option[]::new);
+ quickstart = new DefaultCompositeOption(options);
+ return new Option[]{
+ super.baseConfiguration(),
+ quickstart,
+ // Sling JCR ContentLoader
+ testBundle("bundle.filename"),
+ // testing
+ newConfiguration("org.apache.sling.jcr.base.internal.LoginAdminWhitelist")
+ .put("whitelist.bundles.regexp", "PAXEXAM-PROBE-.*")
+ .asOption(),
+ slingResourcePresence(),
+ junitBundles()
+ };
+ }
+
+ protected Option quickstart() {
+ final int httpPort = findFreePort();
+ final String workingDirectory = workingDirectory();
+ return slingQuickstartOakTar(workingDirectory, httpPort);
+ }
+
+
+ private InputStream getTestBundleStream() throws Exception {
+ final TinyBundle bundle = TinyBundles.bundle().set(Constants.BUNDLE_SYMBOLICNAME, bundleSymbolicName);
+ return setupTestBundle(bundle).build(TinyBundles.withBnd());
+ }
+
+ abstract protected TinyBundle setupTestBundle(TinyBundle b) throws Exception;
+
+ /**
+ * Add content to our test bundle
+ */
+ protected void addContent(TinyBundle b, String pathInBundle, String resourcePath) throws IOException {
+ pathInBundle += "/" + resourcePath;
+ resourcePath = "/initial-content/" + resourcePath;
+ try (final InputStream is = getClass().getResourceAsStream(resourcePath)) {
+ assertNotNull("Expecting resource to be found:" + resourcePath, is);
+ logger.info("Adding resource to bundle, path={}, resource={}", pathInBundle, resourcePath);
+ b.add(pathInBundle, is);
+ }
+ }
+
+ protected Bundle findBundle(final String symbolicName) {
+ for (final Bundle bundle : bundleContext.getBundles()) {
+ if (symbolicName.equals(bundle.getSymbolicName())) {
+ return bundle;
+ }
+ }
+ return null;
+ }
+
+}
diff --git a/src/test/java/org/apache/sling/jcr/contentloader/it/I18nInitialContentIT.java b/src/test/java/org/apache/sling/jcr/contentloader/it/I18nInitialContentIT.java
index 41ce7a6..2d8238c 100644
--- a/src/test/java/org/apache/sling/jcr/contentloader/it/I18nInitialContentIT.java
+++ b/src/test/java/org/apache/sling/jcr/contentloader/it/I18nInitialContentIT.java
@@ -18,28 +18,30 @@
*/
package org.apache.sling.jcr.contentloader.it;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
import java.io.IOException;
import javax.jcr.Node;
import javax.jcr.RepositoryException;
import javax.jcr.nodetype.NodeType;
-import org.apache.sling.commons.testing.junit.Retry;
import org.junit.Test;
import org.junit.runner.RunWith;
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.ops4j.pax.tinybundles.core.TinyBundle;
import org.osgi.framework.Bundle;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
/** Basic test of a bundle that provides initial content */
@RunWith(PaxExam.class)
-public class I18nInitialContentIT extends ContentBundleTestBase {
-
+@ExamReactorStrategy(PerClass.class)
+public class I18nInitialContentIT extends ContentloaderTestSupport {
+
protected TinyBundle setupTestBundle(TinyBundle b) throws IOException {
b.set(SLING_INITIAL_CONTENT_HEADER, DEFAULT_PATH_IN_BUNDLE + ";ignoreImportProviders:=json;path:=" + contentRootPath);
addContent(b, DEFAULT_PATH_IN_BUNDLE, "i18n/en.json");
@@ -48,15 +50,13 @@ public class I18nInitialContentIT extends ContentBundleTestBase {
}
@Test
- @Retry(intervalMsec=RETRY_INTERVAL, timeoutMsec=RETRY_TIMEOUT)
public void bundleStarted() {
- final Bundle b = PaxExamUtilities.findBundle(bundleContext, bundleSymbolicName);
+ final Bundle b = findBundle(bundleSymbolicName);
assertNotNull("Expecting bundle to be found:" + bundleSymbolicName, b);
assertEquals("Expecting bundle to be active:" + bundleSymbolicName, Bundle.ACTIVE, b.getState());
}
@Test
- @Retry(intervalMsec=RETRY_INTERVAL, timeoutMsec=RETRY_TIMEOUT)
public void i18nJsonFile() throws RepositoryException {
final String filePath = contentRootPath + "/i18n/en.json";
assertTrue("file node " + filePath + " exists", session.itemExists(filePath));
diff --git a/src/test/java/org/apache/sling/jcr/contentloader/it/OrderedInitialContentIT.java b/src/test/java/org/apache/sling/jcr/contentloader/it/OrderedInitialContentIT.java
index 51aff7b..268fc74 100644
--- a/src/test/java/org/apache/sling/jcr/contentloader/it/OrderedInitialContentIT.java
+++ b/src/test/java/org/apache/sling/jcr/contentloader/it/OrderedInitialContentIT.java
@@ -18,26 +18,28 @@
*/
package org.apache.sling.jcr.contentloader.it;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
import java.io.IOException;
import javax.jcr.RepositoryException;
import javax.jcr.Session;
-import org.apache.sling.commons.testing.junit.Retry;
import org.junit.Test;
import org.junit.runner.RunWith;
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.ops4j.pax.tinybundles.core.TinyBundle;
import org.osgi.framework.Bundle;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
/** Test the SLING-5682 ordered content loading */
@RunWith(PaxExam.class)
-public class OrderedInitialContentIT extends ContentBundleTestBase {
-
+@ExamReactorStrategy(PerClass.class)
+public class OrderedInitialContentIT extends ContentloaderTestSupport {
+
protected TinyBundle setupTestBundle(TinyBundle b) throws IOException {
b.set(SLING_INITIAL_CONTENT_HEADER, DEFAULT_PATH_IN_BUNDLE + ";path:=" + contentRootPath);
addContent(b, DEFAULT_PATH_IN_BUNDLE, "ordered-content.ordered-json");
@@ -45,9 +47,8 @@ public class OrderedInitialContentIT extends ContentBundleTestBase {
}
@Test
- @Retry(intervalMsec=RETRY_INTERVAL, timeoutMsec=RETRY_TIMEOUT)
public void bundleStarted() {
- final Bundle b = PaxExamUtilities.findBundle(bundleContext, bundleSymbolicName);
+ final Bundle b = findBundle(bundleSymbolicName);
assertNotNull("Expecting bundle to be found:" + bundleSymbolicName, b);
assertEquals("Expecting bundle to be active:" + bundleSymbolicName, Bundle.ACTIVE, b.getState());
}
@@ -59,7 +60,6 @@ public class OrderedInitialContentIT extends ContentBundleTestBase {
}
@Test
- @Retry(intervalMsec=RETRY_INTERVAL, timeoutMsec=RETRY_TIMEOUT)
public void initialContentInstalled() throws RepositoryException {
assertProperty(session, contentRootPath + "/ordered-content/first/title", "This comes first");
assertProperty(session, contentRootPath + "/ordered-content/second/title", "This comes second");
diff --git a/src/test/java/org/apache/sling/jcr/contentloader/it/PaxExamUtilities.java b/src/test/java/org/apache/sling/jcr/contentloader/it/PaxExamUtilities.java
deleted file mode 100644
index 68f7337..0000000
--- a/src/test/java/org/apache/sling/jcr/contentloader/it/PaxExamUtilities.java
+++ /dev/null
@@ -1,217 +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.sling.jcr.contentloader.it;
-
-import static org.ops4j.pax.exam.CoreOptions.bundle;
-import static org.ops4j.pax.exam.CoreOptions.frameworkProperty;
-import static org.ops4j.pax.exam.CoreOptions.junitBundles;
-import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
-import static org.ops4j.pax.exam.CoreOptions.options;
-import static org.ops4j.pax.exam.CoreOptions.provision;
-import static org.ops4j.pax.exam.CoreOptions.systemProperty;
-import static org.ops4j.pax.exam.CoreOptions.wrappedBundle;
-
-import java.io.File;
-
-import org.ops4j.pax.exam.Option;
-import org.ops4j.pax.exam.cm.ConfigurationAdminOptions;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-
-/** Utilities for Pax Exam testing */
-public final class PaxExamUtilities {
-
- private static final String SYS_PROP_BUILD_DIR = "bundle.build.dir";
-
- private static final String DEFAULT_BUILD_DIR = "target";
-
- public static Option[] paxConfig() {
- final File thisProjectsBundle = new File(System.getProperty( "bundle.file.name", "BUNDLE_FILE_NOT_SET" ));
-
- final String buildDir = System.getProperty(SYS_PROP_BUILD_DIR, DEFAULT_BUILD_DIR);
-
- final String jackrabbitVersion = "2.13.1";
- final String oakVersion = "1.5.7";
-
- final String slingHome = new File(buildDir + File.separatorChar + "sling_" + System.currentTimeMillis()).getAbsolutePath();
-
- return options(
- frameworkProperty("sling.home").value(slingHome),
- frameworkProperty("repository.home").value(slingHome + File.separatorChar + "repository"),
- systemProperty("pax.exam.osgi.unresolved.fail").value("true"),
-
- ConfigurationAdminOptions.newConfiguration("org.apache.felix.jaas.ConfigurationSpi")
- .create(true)
- .put("jaas.defaultRealmName", "jackrabbit.oak")
- .put("jaas.configProviderName", "FelixJaasProvider")
- .asOption(),
- ConfigurationAdminOptions.factoryConfiguration("org.apache.felix.jaas.Configuration.factory")
- .create(true)
- .put("jaas.controlFlag", "optional")
- .put("jaas.classname", "org.apache.jackrabbit.oak.spi.security.authentication.GuestLoginModule")
- .put("jaas.ranking", 300)
- .asOption(),
- ConfigurationAdminOptions.factoryConfiguration("org.apache.felix.jaas.Configuration.factory")
- .create(true)
- .put("jaas.controlFlag", "required")
- .put("jaas.classname", "org.apache.jackrabbit.oak.security.authentication.user.LoginModuleImpl")
- .asOption(),
- ConfigurationAdminOptions.factoryConfiguration("org.apache.felix.jaas.Configuration.factory")
- .create(true)
- .put("jaas.controlFlag", "sufficient")
- .put("jaas.classname", "org.apache.jackrabbit.oak.security.authentication.token.TokenLoginModule")
- .put("jaas.ranking", 200)
- .asOption(),
- ConfigurationAdminOptions.newConfiguration("org.apache.jackrabbit.oak.security.authentication.AuthenticationConfigurationImpl")
- .create(true)
- .put("org.apache.jackrabbit.oak.authentication.configSpiName", "FelixJaasProvider")
- .asOption(),
- ConfigurationAdminOptions.newConfiguration("org.apache.jackrabbit.oak.security.user.UserConfigurationImpl")
- .create(true)
- .put("groupsPath", "/home/groups")
- .put("usersPath", "/home/users")
- .put("defaultPath", "1")
- .put("importBehavior", "besteffort")
- .asOption(),
- ConfigurationAdminOptions.newConfiguration("org.apache.jackrabbit.oak.security.user.RandomAuthorizableNodeName")
- .create(true)
- .put("enabledActions", new String[] {"org.apache.jackrabbit.oak.spi.security.user.action.AccessControlAction"})
- .put("userPrivilegeNames", new String[] {"jcr:all"})
- .put("groupPrivilegeNames", new String[] {"jcr:read"})
- .asOption(),
- ConfigurationAdminOptions.newConfiguration("org.apache.jackrabbit.oak.spi.security.user.action.DefaultAuthorizableActionProvider")
- .create(true)
- .put("length", 21)
- .asOption(),
- ConfigurationAdminOptions.newConfiguration("org.apache.jackrabbit.oak.plugins.segment.SegmentNodeStoreService")
- .create(true)
- .put("name", "Default NodeStore")
- .asOption(),
-
- ConfigurationAdminOptions.factoryConfiguration("org.apache.sling.serviceusermapping.impl.ServiceUserMapperImpl.amended")
- .create(true)
- .put("user.mapping", "org.apache.sling.event=admin")
- .asOption(),
- ConfigurationAdminOptions.newConfiguration("org.apache.sling.jcr.resource.internal.JcrSystemUserValidator")
- .create(true)
- .put("allow.only.system.user", "false")
- .asOption(),
-
- // logging
- systemProperty("pax.exam.logging").value("none"),
- mavenBundle("org.apache.sling", "org.apache.sling.commons.log", "4.0.6"),
- mavenBundle("org.apache.sling", "org.apache.sling.commons.logservice", "1.0.6"),
- mavenBundle("org.slf4j", "slf4j-api", "1.7.13"),
- mavenBundle("org.slf4j", "jcl-over-slf4j", "1.7.13"),
- mavenBundle("org.slf4j", "log4j-over-slf4j", "1.7.13"),
-
- mavenBundle("commons-io", "commons-io", "2.4"),
- mavenBundle("commons-fileupload", "commons-fileupload", "1.3.1"),
- mavenBundle("commons-collections", "commons-collections", "3.2.2"),
- mavenBundle("commons-codec", "commons-codec", "1.10"),
- mavenBundle("commons-lang", "commons-lang", "2.6"),
- mavenBundle("org.apache.commons", "commons-lang3", "3.5"),
- mavenBundle("commons-pool", "commons-pool", "1.6"),
-
- mavenBundle("org.apache.servicemix.bundles", "org.apache.servicemix.bundles.concurrent", "1.3.4_1"),
-
- mavenBundle("org.apache.geronimo.bundles", "commons-httpclient", "3.1_1"),
- mavenBundle("org.apache.tika", "tika-core", "1.9"),
- mavenBundle("org.apache.tika", "tika-bundle", "1.9"),
-
- // infrastructure
- mavenBundle("org.apache.felix", "org.apache.felix.http.servlet-api", "1.1.2"),
- mavenBundle("org.apache.felix", "org.apache.felix.http.jetty", "3.1.6"),
- mavenBundle("org.apache.felix", "org.apache.felix.eventadmin", "1.4.8"),
- mavenBundle("org.apache.felix", "org.apache.felix.scr", "2.0.6"),
- mavenBundle("org.apache.felix", "org.apache.felix.configadmin", "1.8.10"),
- mavenBundle("org.apache.felix", "org.apache.felix.inventory", "1.0.4"),
- mavenBundle("org.apache.felix", "org.apache.felix.metatype", "1.1.2"),
-
- // sling
- mavenBundle("org.apache.sling", "org.apache.sling.settings", "1.3.8"),
- mavenBundle("org.apache.sling", "org.apache.sling.commons.osgi", "2.3.0"),
- mavenBundle("org.apache.sling", "org.apache.sling.commons.mime", "2.1.8"),
- mavenBundle("org.apache.sling", "org.apache.sling.commons.classloader", "1.3.2"),
- mavenBundle("org.apache.sling", "org.apache.sling.commons.johnzon", "1.0.0"),
- mavenBundle("org.apache.sling", "org.apache.sling.commons.scheduler", "2.4.14"),
- mavenBundle("org.apache.sling", "org.apache.sling.commons.threads", "3.2.4"),
-
- mavenBundle("org.apache.sling", "org.apache.sling.auth.core", "1.3.12"),
- mavenBundle("org.apache.sling", "org.apache.sling.discovery.api", "1.0.2"),
- mavenBundle("org.apache.sling", "org.apache.sling.discovery.commons", "1.0.20"),
- mavenBundle("org.apache.sling", "org.apache.sling.discovery.standalone", "1.0.2"),
-
- mavenBundle("org.apache.sling", "org.apache.sling.launchpad.api", "1.2.0"),
- mavenBundle("org.apache.sling", "org.apache.sling.api", "2.14.2"),
- mavenBundle("org.apache.sling", "org.apache.sling.resourceresolver", "1.4.18"),
- mavenBundle("org.apache.sling", "org.apache.sling.adapter", "2.1.10"),
- mavenBundle("org.apache.sling", "org.apache.sling.jcr.resource", "2.8.0"),
- mavenBundle("org.apache.sling", "org.apache.sling.jcr.classloader", "3.2.2"),
- mavenBundle("org.apache.sling", "org.apache.sling.jcr.contentloader", "2.2.4"),
- mavenBundle("org.apache.sling", "org.apache.sling.engine", "2.6.2"),
- mavenBundle("org.apache.sling", "org.apache.sling.serviceusermapper", "1.3.2"),
-
- mavenBundle("org.apache.sling", "org.apache.sling.jcr.jcr-wrapper", "2.0.0"),
- mavenBundle("org.apache.sling", "org.apache.sling.jcr.api", "2.4.0"),
- mavenBundle("org.apache.sling", "org.apache.sling.jcr.base", "2.4.0"),
-
- mavenBundle("com.google.guava", "guava", "15.0"),
- mavenBundle("org.apache.jackrabbit", "jackrabbit-api", jackrabbitVersion),
- mavenBundle("org.apache.jackrabbit", "jackrabbit-jcr-commons", jackrabbitVersion),
- mavenBundle("org.apache.jackrabbit", "jackrabbit-spi", jackrabbitVersion),
- mavenBundle("org.apache.jackrabbit", "jackrabbit-spi-commons", jackrabbitVersion),
- mavenBundle("org.apache.jackrabbit", "jackrabbit-jcr-rmi", jackrabbitVersion),
-
- mavenBundle("org.apache.felix", "org.apache.felix.jaas", "0.0.4"),
-
- mavenBundle("org.apache.jackrabbit", "oak-core", oakVersion),
- mavenBundle("org.apache.jackrabbit", "oak-commons", oakVersion),
- mavenBundle("org.apache.jackrabbit", "oak-lucene", oakVersion),
- mavenBundle("org.apache.jackrabbit", "oak-blob", oakVersion),
- mavenBundle("org.apache.jackrabbit", "oak-jcr", oakVersion),
-
- mavenBundle("org.apache.jackrabbit", "oak-segment", oakVersion),
-
- mavenBundle("org.apache.sling", "org.apache.sling.jcr.oak.server", "1.1.0"),
-
- mavenBundle("org.apache.sling", "org.apache.sling.testing.tools", "1.0.16"),
- mavenBundle("org.apache.httpcomponents", "httpcore-osgi", "4.1.2"),
- mavenBundle("org.apache.httpcomponents", "httpclient-osgi", "4.1.2"),
-
- provision(bundle(thisProjectsBundle.toURI().toString())),
- wrappedBundle(mavenBundle("org.apache.sling", "org.apache.sling.commons.testing").versionAsInProject()),
- wrappedBundle(mavenBundle("org.ops4j.pax.tinybundles", "tinybundles").versionAsInProject()),
- mavenBundle("org.apache.sling", "org.apache.sling.commons.johnzon").versionAsInProject(),
- mavenBundle("biz.aQute.bnd", "bndlib").versionAsInProject(),
-
- junitBundles()
- );
-
- }
-
- public static Bundle findBundle(BundleContext ctx, String symbolicName) {
- for(Bundle b : ctx.getBundles()) {
- if(symbolicName.equals(b.getSymbolicName())) {
- return b;
- }
- }
- return null;
- }
-}
diff --git a/src/test/java/org/apache/sling/jcr/contentloader/it/SLING7268InitialContentIT.java b/src/test/java/org/apache/sling/jcr/contentloader/it/SLING7268InitialContentIT.java
index 0e36e65..164c3af 100644
--- a/src/test/java/org/apache/sling/jcr/contentloader/it/SLING7268InitialContentIT.java
+++ b/src/test/java/org/apache/sling/jcr/contentloader/it/SLING7268InitialContentIT.java
@@ -18,10 +18,6 @@
*/
package org.apache.sling.jcr.contentloader.it;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
@@ -41,19 +37,25 @@ import javax.jcr.security.Privilege;
import org.apache.jackrabbit.api.security.user.Authorizable;
import org.apache.jackrabbit.api.security.user.Group;
import org.apache.jackrabbit.api.security.user.UserManager;
-import org.apache.sling.commons.testing.junit.Retry;
import org.apache.sling.jcr.base.util.AccessControlUtil;
import org.junit.Test;
import org.junit.runner.RunWith;
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.ops4j.pax.tinybundles.core.TinyBundle;
import org.osgi.framework.Bundle;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
/** test of a bundle that provides initial content that creates a user/group and defines an ace
* for those principals within the same transaction
*/
@RunWith(PaxExam.class)
-public class SLING7268InitialContentIT extends ContentBundleTestBase {
+@ExamReactorStrategy(PerClass.class)
+public class SLING7268InitialContentIT extends ContentloaderTestSupport {
protected TinyBundle setupTestBundle(TinyBundle b) throws IOException {
b.set(SLING_INITIAL_CONTENT_HEADER, DEFAULT_PATH_IN_BUNDLE + ";path:=" + contentRootPath);
@@ -62,15 +64,13 @@ public class SLING7268InitialContentIT extends ContentBundleTestBase {
}
@Test
- @Retry(intervalMsec=RETRY_INTERVAL, timeoutMsec=RETRY_TIMEOUT)
public void bundleStarted() {
- final Bundle b = PaxExamUtilities.findBundle(bundleContext, bundleSymbolicName);
+ final Bundle b = findBundle(bundleSymbolicName);
assertNotNull("Expecting bundle to be found:" + bundleSymbolicName, b);
assertEquals("Expecting bundle to be active:" + bundleSymbolicName, Bundle.ACTIVE, b.getState());
}
@Test
- @Retry(intervalMsec=RETRY_INTERVAL, timeoutMsec=RETRY_TIMEOUT)
public void initialContentInstalled() throws RepositoryException {
final String folderPath = contentRootPath + "/SLING-7268";
assertTrue("Expecting initial content to be installed", session.itemExists(folderPath));
@@ -78,7 +78,6 @@ public class SLING7268InitialContentIT extends ContentBundleTestBase {
}
@Test
- @Retry(intervalMsec=RETRY_INTERVAL, timeoutMsec=RETRY_TIMEOUT)
public void userCreated() throws RepositoryException {
UserManager userManager = AccessControlUtil.getUserManager(session);
Authorizable authorizable = userManager.getAuthorizable("sling7268_user");
@@ -86,7 +85,6 @@ public class SLING7268InitialContentIT extends ContentBundleTestBase {
}
@Test
- @Retry(intervalMsec=RETRY_INTERVAL, timeoutMsec=RETRY_TIMEOUT)
public void groupCreated() throws RepositoryException {
UserManager userManager = AccessControlUtil.getUserManager(session);
Authorizable authorizable = userManager.getAuthorizable("sling7268_group");
@@ -99,7 +97,6 @@ public class SLING7268InitialContentIT extends ContentBundleTestBase {
}
@Test
- @Retry(intervalMsec=RETRY_INTERVAL, timeoutMsec=RETRY_TIMEOUT)
public void aceCreated() throws RepositoryException {
final String folderPath = contentRootPath + "/SLING-7268";
assertTrue("Expecting test folder to exist", session.itemExists(folderPath));