You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by st...@apache.org on 2021/04/12 14:41:10 UTC
[sling-org-apache-sling-event] branch master updated: SLING-10120 :
switch to parent 41 (#10)
This is an automated email from the ASF dual-hosted git repository.
stefanegli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-event.git
The following commit(s) were added to refs/heads/master by this push:
new 7cf52ab SLING-10120 : switch to parent 41 (#10)
7cf52ab is described below
commit 7cf52abc89587d3ac0736e3a9fab8fc8791b4cd9
Author: stefan-egli <st...@apache.org>
AuthorDate: Mon Apr 12 16:41:01 2021 +0200
SLING-10120 : switch to parent 41 (#10)
* SLING-10120 : switched to parent 41
* SLING-10120 : switched to sling-bundle-parent based on work done by joerghoh in his feature/update-sling-parent40 branch - still some flakyness in ITs to be followed up
* SLING-10120 : javax.servlet import also set to optional
* SLING-10120 : fixing flakyness by waiting for topology event via TopologyEventListener
* SLING-10120 : parent 41 and bnd.bnd factored out of pom.xml
* SLING-10120 : reproducible builds : project.build.outputTimestamp property added
* SLING-10120 : remove duplicate maven-jar-plugin config
* SLING-10120 : remove unnecessary plugin def
* SLING-10120 : replaced maven-dependency-plugin config with bnd.bnd magic
* SLING-10120 : indentation fix for org.apache.sling.testing.paxexam
* SLING-10120 : remove duplicate bnd definition
* SLING-10120 : fixed more indentation mistakes
* SLING-10120 : exporting event.api again, got lost in translation
---
bnd.bnd | 27 ++
pom.xml | 160 ++++++-----
.../sling/event/it/AbstractJobHandlingTest.java | 313 +++++++--------------
.../org/apache/sling/event/it/JobHandlingTest.java | 12 +-
src/test/resources/logback.xml | 32 +++
5 files changed, 260 insertions(+), 284 deletions(-)
diff --git a/bnd.bnd b/bnd.bnd
new file mode 100644
index 0000000..798356e
--- /dev/null
+++ b/bnd.bnd
@@ -0,0 +1,27 @@
+Sling-Namespaces: slingevent=http://sling.apache.org/jcr/event/1.0
+Sling-Nodetypes: SLING-INF/nodetypes/event.cnd
+
+# javax.annotation import for build compatibility with Java 11
+Import-Package: \
+ javax.servlet.http;resolution:=optional,\
+ org.apache.felix.inventory;resolution:=optional,\
+ javax.servlet;resolution:=optional,\
+ javax.annotation;version="[0.0,2)",\
+ *
+Export-Package: \
+ org.apache.sling.event.jobs,\
+ org.apache.sling.event.jobs.consumer,\
+ org.apache.sling.event.jobs.jmx
+
+-conditionalpackage: \
+ org.apache.jackrabbit.util,\
+ org.apache.sling.commons.osgi,\
+ org.apache.sling.event.api
+-includeresource: \
+ @org.apache.sling.event.api-[0-9.]*.jar;lib:=true,\
+ @quartz-[0-9.]*.jar!/org/quartz/CronExpression.class,\
+ @quartz-[0-9.]*.jar!/org/quartz/ValueSet.class,\
+ @org.apache.sling.commons.osgi-[0-9.]*.jar!/org/apache/sling/commons/osgi/PropertiesUtil.class,\
+ @jackrabbit-jcr-commons-[0-9.]*.jar!/org/apache/jackrabbit/util/ISO9075.class,\
+ @jackrabbit-jcr-commons-[0-9.]*.jar!/org/apache/jackrabbit/util/ISO8601.class,\
+ @jackrabbit-jcr-commons-[0-9.]*.jar!/org/apache/jackrabbit/util/XMLChar.class
diff --git a/pom.xml b/pom.xml
index 4409527..99fd047 100644
--- a/pom.xml
+++ b/pom.xml
@@ -22,13 +22,13 @@
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.sling</groupId>
- <artifactId>sling</artifactId>
- <version>33</version>
+ <artifactId>sling-bundle-parent</artifactId>
+ <version>41</version>
<relativePath />
</parent>
<artifactId>org.apache.sling.event</artifactId>
- <packaging>bundle</packaging>
+ <packaging>jar</packaging>
<version>4.2.15-SNAPSHOT</version>
<name>Apache Sling Event Support</name>
@@ -40,59 +40,24 @@
<connection>scm:git:https://gitbox.apache.org/repos/asf/sling-org-apache-sling-event.git</connection>
<developerConnection>scm:git:https://gitbox.apache.org/repos/asf/sling-org-apache-sling-event.git</developerConnection>
<url>https://gitbox.apache.org/repos/asf?p=sling-org-apache-sling-event.git</url>
- <tag>HEAD</tag>
- </scm>
+ <tag>HEAD</tag>
+ </scm>
<properties>
<site.jira.version.id>12315369</site.jira.version.id>
- <exam.version>4.11.0</exam.version>
+ <exam.version>4.13.4</exam.version>
<url.version>2.5.2</url.version>
<bundle.build.dir>${basedir}/target</bundle.build.dir>
<bundle.file.name>${bundle.build.dir}/${project.build.finalName}.jar</bundle.file.name>
<min.port>37000</min.port>
<max.port>37999</max.port>
+ <project.build.outputTimestamp>2021-04-12T10:00:00Z</project.build.outputTimestamp>
</properties>
<build>
<plugins>
<plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Import-Package>
- javax.servlet;javax.servlet.http;resolution:=optional,
- org.apache.felix.inventory;resolution:=optional,
- *
- </Import-Package>
- <Export-Package>
- org.apache.sling.event.jobs,
- org.apache.sling.event.jobs.consumer,
- org.apache.sling.event.jobs.jmx
- </Export-Package>
- <DynamicImport-Package>
- javax.servlet,
- javax.servlet.http,
- org.apache.felix.inventory
- </DynamicImport-Package>
- <Sling-Nodetypes>
- SLING-INF/nodetypes/event.cnd
- </Sling-Nodetypes>
- <Sling-Namespaces>
- slingevent=http://sling.apache.org/jcr/event/1.0
- </Sling-Namespaces>
- <Embed-Dependency>
- jackrabbit-jcr-commons;inline="org/apache/jackrabbit/util/ISO9075.*|org/apache/jackrabbit/util/ISO8601.*|org/apache/jackrabbit/util/XMLChar.*",
- org.apache.sling.commons.osgi;inline="org/apache/sling/commons/osgi/PropertiesUtil.*",
- quartz;inline="org/quartz/CronExpression.*|org/quartz/ValueSet.*",
- org.apache.sling.event.api
- </Embed-Dependency>
- </instructions>
- </configuration>
- </plugin>
- <plugin>
<groupId>org.apache.rat</groupId>
<artifactId>apache-rat-plugin</artifactId>
<configuration>
@@ -134,26 +99,26 @@
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<executions>
- <execution>
- <goals>
- <goal>integration-test</goal>
- <goal>verify</goal>
- </goals>
- </execution>
+ <execution>
+ <goals>
+ <goal>integration-test</goal>
+ <goal>verify</goal>
+ </goals>
+ </execution>
</executions>
<configuration>
<systemProperties>
<property>
- <name>project.bundle.file</name>
- <value>${bundle.file.name}</value>
+ <name>bundle.filename</name>
+ <value>${basedir}/target/${project.build.finalName}.jar</value>
</property>
<property>
- <name>bundle.build.dir</name>
- <value>${bundle.build.dir}</value>
+ <name>org.ops4j.pax.url.mvn.useFallbackRepositories</name>
+ <value>false</value>
</property>
<property>
- <name>org.osgi.service.http.port</name>
- <value>${http.port}</value>
+ <name>org.ops4j.pax.url.mvn.repositories</name>
+ <value>https://repo1.maven.org/maven2@id=central</value>
</property>
</systemProperties>
<argLine>
@@ -165,6 +130,10 @@
</configuration>
</plugin>
<plugin>
+ <groupId>org.apache.servicemix.tooling</groupId>
+ <artifactId>depends-maven-plugin</artifactId>
+ </plugin>
+ <plugin>
<artifactId>maven-clean-plugin</artifactId>
<configuration>
<filesets>
@@ -226,6 +195,12 @@
<dependency>
<groupId>org.osgi</groupId>
<artifactId>osgi.core</artifactId>
+ <version>6.0.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>osgi.cmpn</artifactId>
+ <version>6.0.0</version>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
@@ -263,7 +238,7 @@
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
- <dependency>
+ <dependency>
<artifactId>metrics-core</artifactId>
<version>3.2.4</version>
<groupId>io.dropwizard.metrics</groupId>
@@ -287,12 +262,12 @@
<version>2.2.0</version>
<scope>provided</scope>
</dependency>
- <!-- Webconsole -->
+ <!-- Webconsole -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
</dependency>
- <!-- Testing -->
+ <!-- Testing -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
@@ -300,7 +275,6 @@
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.service.cm</artifactId>
- <version>1.5.0</version>
<scope>test</scope>
</dependency>
<dependency>
@@ -316,12 +290,17 @@
<scope>test</scope>
</dependency>
<dependency>
- <groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.testing.sling-mock</artifactId>
- <version>2.2.6</version>
- <scope>test</scope>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.testing.sling-mock</artifactId>
+ <version>2.2.6</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.testing.sling-mock-oak</artifactId>
+ <version>2.1.10-1.16.0</version>
+ <scope>test</scope>
</dependency>
-
<dependency>
<groupId>org.ops4j.pax.exam</groupId>
<artifactId>pax-exam-container-forked</artifactId>
@@ -369,27 +348,60 @@
<version>1</version>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.event.api</artifactId>
- <version>1.0.0</version>
- </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.event.api</artifactId>
+ <version>1.0.0</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.serviceusermapper</artifactId>
+ <version>1.4.6</version>
+ <scope>provided</scope>
+ </dependency>
+
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.commons.testing</artifactId>
<version>2.0.10</version>
</dependency>
<dependency>
- <groupId>org.mockito</groupId>
- <artifactId>mockito-all</artifactId>
- <version>1.9.5</version>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.testing.paxexam</artifactId>
+ <version>3.1.0</version>
<scope>test</scope>
</dependency>
+
+ <!-- an OSGi framework -->
<dependency>
- <groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.testing.sling-mock-oak</artifactId>
- <version>2.0.0</version>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.framework</artifactId>
+ <version>6.0.3</version>
<scope>test</scope>
</dependency>
+
+ <!-- JUnit -->
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ <version>4.12</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jmock</groupId>
+ <artifactId>jmock-junit4</artifactId>
+ <version>2.8.2</version>
+ <scope>test</scope>
+ </dependency>
+
+ <!-- Pax Exam -->
+ <dependency>
+ <groupId>org.ops4j.pax.exam</groupId>
+ <artifactId>pax-exam</artifactId>
+ <version>4.13.4</version>
+ <scope>test</scope>
+ </dependency>
+
</dependencies>
</project>
diff --git a/src/test/java/org/apache/sling/event/it/AbstractJobHandlingTest.java b/src/test/java/org/apache/sling/event/it/AbstractJobHandlingTest.java
index 87e296c..e8bc0ac 100644
--- a/src/test/java/org/apache/sling/event/it/AbstractJobHandlingTest.java
+++ b/src/test/java/org/apache/sling/event/it/AbstractJobHandlingTest.java
@@ -19,13 +19,17 @@
package org.apache.sling.event.it;
-import static org.ops4j.pax.exam.CoreOptions.frameworkProperty;
+import static org.apache.sling.testing.paxexam.SlingOptions.backing;
+import static org.apache.sling.testing.paxexam.SlingOptions.paxTinybundles;
+import static org.apache.sling.testing.paxexam.SlingOptions.spyfly;
+import static org.ops4j.pax.exam.CoreOptions.composite;
import static org.ops4j.pax.exam.CoreOptions.junitBundles;
+import static org.ops4j.pax.exam.CoreOptions.keepCaches;
import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
import static org.ops4j.pax.exam.CoreOptions.options;
import static org.ops4j.pax.exam.CoreOptions.repository;
-import static org.ops4j.pax.exam.CoreOptions.systemProperty;
-import static org.ops4j.pax.exam.CoreOptions.when;
+import static org.ops4j.pax.exam.cm.ConfigurationAdminOptions.factoryConfiguration;
+import static org.ops4j.pax.exam.cm.ConfigurationAdminOptions.newConfiguration;
import java.io.File;
import java.io.IOException;
@@ -34,6 +38,7 @@ import java.util.Collection;
import java.util.Dictionary;
import java.util.Hashtable;
import java.util.List;
+import java.util.concurrent.atomic.AtomicReference;
import javax.inject.Inject;
@@ -43,17 +48,21 @@ import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ResourceResolver;
import org.apache.sling.api.resource.ResourceResolverFactory;
import org.apache.sling.discovery.PropertyProvider;
+import org.apache.sling.discovery.TopologyEvent;
+import org.apache.sling.discovery.TopologyEventListener;
import org.apache.sling.event.impl.jobs.config.JobManagerConfiguration;
import org.apache.sling.event.jobs.JobManager;
import org.apache.sling.event.jobs.consumer.JobConsumer;
import org.apache.sling.event.jobs.consumer.JobExecutor;
+import org.apache.sling.jcr.api.SlingRepository;
+import org.apache.sling.testing.paxexam.SlingOptions;
+import org.apache.sling.testing.paxexam.SlingVersionResolver;
+import org.apache.sling.testing.paxexam.TestSupport;
import org.ops4j.pax.exam.Configuration;
import org.ops4j.pax.exam.CoreOptions;
import org.ops4j.pax.exam.Option;
-import org.ops4j.pax.exam.cm.ConfigurationAdminOptions;
-import org.osgi.framework.Bundle;
+import org.ops4j.pax.exam.options.ModifiableCompositeOption;
import org.osgi.framework.BundleContext;
-import org.osgi.framework.BundleException;
import org.osgi.framework.InvalidSyntaxException;
import org.osgi.framework.ServiceReference;
import org.osgi.framework.ServiceRegistration;
@@ -61,18 +70,14 @@ import org.osgi.service.cm.ConfigurationAdmin;
import org.osgi.service.event.EventAdmin;
import org.osgi.service.event.EventConstants;
import org.osgi.service.event.EventHandler;
+import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public abstract class AbstractJobHandlingTest {
+public abstract class AbstractJobHandlingTest extends TestSupport {
- private static final String BUNDLE_JAR_SYS_PROP = "project.bundle.file";
+ private final Logger log = LoggerFactory.getLogger(this.getClass());
- /** The property containing the build directory. */
- private static final String SYS_PROP_BUILD_DIR = "bundle.build.dir";
-
- private static final String DEFAULT_BUILD_DIR = "target";
-
- private static final String PORT_CONFIG = "org.osgi.service.http.port";
+ private static final String PROPERTY_BUNDLE_FILENAME = "bundle.filename";
protected static final int DEFAULT_TEST_TIMEOUT = 1000*60*5;
@@ -85,189 +90,75 @@ public abstract class AbstractJobHandlingTest {
@Inject
protected BundleContext bc;
+ @Inject // just to block the dependencies
+ protected SlingRepository repo;
+
protected List<ServiceRegistration<?>> registrations = new ArrayList<>();
+ public static SlingVersionResolver versionResolver = new SlingVersionResolver();
+
@Configuration
public Option[] config() {
- final String buildDir = System.getProperty(SYS_PROP_BUILD_DIR, DEFAULT_BUILD_DIR);
- final String bundleFileName = System.getProperty( BUNDLE_JAR_SYS_PROP );
+
+ final String workingDirectory = workingDirectory(); // from TestSupport
+ final int httpPort = findFreePort(); // from TestSupport
+
+ final String bundleFileName = System.getProperty(PROPERTY_BUNDLE_FILENAME );
final File bundleFile = new File( bundleFileName );
if ( !bundleFile.canRead() ) {
throw new IllegalArgumentException( "Cannot read from bundle file " + bundleFileName + " specified in the "
- + BUNDLE_JAR_SYS_PROP + " system property" );
+ + PROPERTY_BUNDLE_FILENAME + " system property" );
}
- String localRepo = System.getProperty("maven.repo.local", "");
-
- 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(
- repository("https://repo.maven.apache.org/maven2/").id("central"),
- frameworkProperty("sling.home").value(slingHome),
- frameworkProperty("repository.home").value(slingHome + File.separatorChar + "repository"),
- when( localRepo.length() > 0 ).useOptions(
- systemProperty("org.ops4j.pax.url.mvn.localRepository").value(localRepo)
- ),
- when( System.getProperty(PORT_CONFIG) != null ).useOptions(
- systemProperty(PORT_CONFIG).value(System.getProperty(PORT_CONFIG))),
- 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")
+ newConfiguration("org.apache.sling.event.impl.jobs.jcr.PersistenceHandler")
+ .put(JobManagerConfiguration.PROPERTY_BACKGROUND_LOAD_DELAY, 3L)
+ .put("startup.delay", 1L)
.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)
+ baseConfiguration(),
+ SlingOptions.slingQuickstartOakTar(workingDirectory, httpPort),
+ SlingOptions.logback(), testBundle(PROPERTY_BUNDLE_FILENAME), // this bundle
+ SlingOptions.slingDiscovery(),
+ mavenBundle().groupId("org.apache.sling").artifactId("org.apache.sling.event.dea").version(versionResolver),
+ mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.inventory").version(versionResolver),
+ mavenBundle().groupId("org.apache.sling").artifactId("org.apache.sling.serviceusermapper").version("1.5.2"),
+ factoryConfiguration("org.apache.sling.jcr.repoinit.RepositoryInitializer")
+ .put("scripts", new String[]{"create service user sling-event\n\n create path (sling:Folder) /var/eventing\n\n set ACL for sling-event\n\n allow jcr:all on /var/eventing\n\n end"})
.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")
+ factoryConfiguration("org.apache.sling.serviceusermapping.impl.ServiceUserMapperImpl.amended")
+ .put("user.mapping", new String[]{"org.apache.sling.event=[sling-event]", "org.apache.sling.event.dea=[sling-event]"})
.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)
+ newConfiguration("org.apache.sling.commons.scheduler.impl.QuartzScheduler")
+ .put("allowedPoolNames",new String[] {"oak"})
.asOption(),
- ConfigurationAdminOptions.newConfiguration("org.apache.jackrabbit.oak.security.authentication.AuthenticationConfigurationImpl")
- .create(true)
- .put("org.apache.jackrabbit.oak.authentication.configSpiName", "FelixJaasProvider")
+ // this test code uses loginAdministrative!
+ newConfiguration("org.apache.sling.jcr.base.internal.LoginAdminWhitelist")
+ .put("whitelist.bundles.regexp", "PAXEXAM-PROBE-.*")
.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("io.dropwizard.metrics", "metrics-core", "3.2.4"),
-
- 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.commons.metrics", "1.2.6"),
-
- 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.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"),
-
-
- // SLING-5560: delaying start of the sling.event bundle to
- // ensure the parameter 'startup.delay' is properly set to 1sec
- // for these ITs - as otherwise, the default of 30sec applies -
- // which will cause the tests to fail
- // @see setup() where the bundle is finally started - after reconfig
- CoreOptions.bundle( bundleFile.toURI().toString() ).start(false),
-
+ // otherwise we get ignored events
+ newConfiguration("org.apache.felix.eventadmin.impl.EventAdmin")
+ .put("org.apache.felix.eventadmin.IgnoreTimeout", "*")
+ .asOption(),
+ mavenBundle().groupId("org.apache.sling").artifactId("org.apache.sling.testing.tools").version("1.0.14"),
+ mavenBundle().groupId("org.apache.sling").artifactId("org.apache.sling.commons.json").version("2.0.20"),
junitBundles()
);
}
+ protected ModifiableCompositeOption baseConfiguration() {
+ return composite(
+ failOnUnresolvedBundles(),
+ keepCaches(),
+ localMavenRepo(),
+ repository("https://repo1.maven.org/maven2/").id("apache-snapshots").allowSnapshots(),
+ CoreOptions.workingDirectory(workingDirectory()),
+ mavenBundle().groupId("org.apache.sling").artifactId("org.apache.sling.testing.paxexam").versionAsInProject(),
+ paxTinybundles(),
+ backing(),
+ spyfly()
+ );
+ }
+
protected JobManager getJobManager() {
JobManager result = null;
int count = 0;
@@ -297,36 +188,14 @@ public abstract class AbstractJobHandlingTest {
}
public void setup() throws IOException {
- // set load delay to 3 sec
- final org.osgi.service.cm.Configuration c2 = this.configAdmin.getConfiguration("org.apache.sling.event.impl.jobs.jcr.PersistenceHandler", null);
- Dictionary<String, Object> p2 = new Hashtable<>();
- p2.put(JobManagerConfiguration.PROPERTY_BACKGROUND_LOAD_DELAY, 3L);
- // and startup.delay to 1sec - otherwise default of 30sec breaks tests!
- p2.put("startup.delay", 1L);
- c2.update(p2);
-
- // SLING-5560 : since the above (re)config is now applied, we're safe
- // to go ahead and start the sling.event bundle.
- // this time, the JobManagerConfiguration will be activated
- // with the 'startup.delay' set to 1sec - so that ITs actually succeed
- try {
- Bundle[] bundles = bc.getBundles();
- for (Bundle bundle : bundles) {
- if (bundle.getSymbolicName().contains("sling.event")) {
- // assuming we only have 1 bundle that contains 'sling.event'
- LoggerFactory.getLogger(getClass()).info("starting bundle... "+bundle);
- bundle.start();
- break;
- }
- }
- } catch (BundleException e) {
- LoggerFactory.getLogger(getClass()).error("could not start sling.event bundle: "+e, e);
- throw new RuntimeException(e);
- }
+ log.info("starting setup");
+ registerTopologyListener();
}
private int deleteCount;
+ protected AtomicReference<TopologyEvent> lastTopologyEvent = new AtomicReference<>();
+
private void delete(final Resource rsrc )
throws PersistenceException {
final ResourceResolver resolver = rsrc.getResourceResolver();
@@ -342,6 +211,7 @@ public abstract class AbstractJobHandlingTest {
}
public void cleanup() {
+ log.info("starting cleanup");
// clean job area
final ServiceReference<ResourceResolverFactory> ref = this.bc.getServiceReference(ResourceResolverFactory.class);
final ResourceResolverFactory factory = this.bc.getService(ref);
@@ -389,6 +259,7 @@ public abstract class AbstractJobHandlingTest {
// ignore
}
this.sleep(1000);
+ log.info("cleanup completed");
}
/**
@@ -408,8 +279,10 @@ public abstract class AbstractJobHandlingTest {
long result = -1;
try {
final Collection<ServiceReference<PropertyProvider>> refs = this.bc.getServiceReferences(PropertyProvider.class, "(changeCount=*)");
+ log.info("GetConsumerChangeCount refs.size = {}", refs.size());
if ( !refs.isEmpty() ) {
- result = (Long)refs.iterator().next().getProperty("changeCount");
+ result = refs.stream().mapToLong(r -> (Long) r.getProperty("changeCount")).max().getAsLong();
+ log.info("GetConsumerChangeCount changeCount = {} ", result);
}
} catch ( final InvalidSyntaxException ignore ) {
// ignore
@@ -421,14 +294,22 @@ public abstract class AbstractJobHandlingTest {
do {
final long cc = getConsumerChangeCount();
if ( cc >= minimum ) {
- // we need to wait for the topology events (TODO)
- sleep(200);
- return;
+ if (isTopologyInitialized()) {
+ return;
+ }
+ log.info("waitConsumerChangeCount (topology not yet initialized)");
+ } else {
+ log.info("waitConsumerChangeCount (is={}, expected={})",cc, minimum);
}
sleep(50);
} while ( true );
}
+ protected boolean isTopologyInitialized() {
+ final TopologyEvent event = lastTopologyEvent.get();
+ return (event != null) && (event.getNewView() != null);
+ }
+
/**
* Helper method to register a job consumer
*/
@@ -440,10 +321,26 @@ public abstract class AbstractJobHandlingTest {
final ServiceRegistration<JobConsumer> reg = this.bc.registerService(JobConsumer.class,
handler, props);
this.registrations.add(reg);
+ log.info("registered JobConsumer for topic {} and changecount={}",topic, cc);
this.waitConsumerChangeCount(cc + 1);
+ log.info("registered2 JobConsumer for topic {} and changecount={}",topic, cc);
return reg;
}
+ protected void registerTopologyListener() {
+ final Dictionary<String, Object> props = new Hashtable<>();
+ final ServiceRegistration<TopologyEventListener> reg = this.bc.registerService(TopologyEventListener.class,
+ new TopologyEventListener() {
+
+ @Override
+ public void handleTopologyEvent(TopologyEvent event) {
+ log.info("handleTopologyEvent : GOT EVENT : " + event);
+ lastTopologyEvent.set(event);
+ }
+ }, props);
+ this.registrations.add(reg);
+ }
+
/**
* Helper method to register a job executor
*/
diff --git a/src/test/java/org/apache/sling/event/it/JobHandlingTest.java b/src/test/java/org/apache/sling/event/it/JobHandlingTest.java
index 54867ce..d69d036 100644
--- a/src/test/java/org/apache/sling/event/it/JobHandlingTest.java
+++ b/src/test/java/org/apache/sling/event/it/JobHandlingTest.java
@@ -51,12 +51,16 @@ import org.junit.runner.RunWith;
import org.ops4j.pax.exam.junit.PaxExam;
import org.osgi.service.event.Event;
import org.osgi.service.event.EventHandler;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
@RunWith(PaxExam.class)
public class JobHandlingTest extends AbstractJobHandlingTest {
public static final String TOPIC = "sling/test";
+ private final Logger log = LoggerFactory.getLogger(this.getClass());
+
@Override
@Before
public void setup() throws IOException {
@@ -404,19 +408,21 @@ public class JobHandlingTest extends AbstractJobHandlingTest {
public void testNoJobProcessor() throws Exception {
final AtomicInteger count = new AtomicInteger(0);
+ log.info("testNoJobProcessor : registering job consumer");
this.registerJobConsumer(TOPIC,
new JobConsumer() {
@Override
public JobResult process(final Job job) {
- count.incrementAndGet();
-
+ final int got = count.incrementAndGet();
+ log.info("testNoJobProcessor.process : got " + got + " jobs");
return JobResult.OK;
}
});
final JobManager jobManager = this.getJobManager();
+ log.info("testNoJobProcessor : starting 20 jobs, 10 on " + TOPIC + " and 10 on " + TOPIC + "2");
// we start 20 jobs, every second job has no processor
final int COUNT = 20;
for(int i = 0; i < COUNT; i++ ) {
@@ -424,6 +430,8 @@ public class JobHandlingTest extends AbstractJobHandlingTest {
jobManager.addJob(jobTopic, null);
}
+
+ log.info("testNoJobProcessor : waiting for jobs to be received ...");
while ( jobManager.getStatistics().getNumberOfFinishedJobs() < COUNT / 2) {
this.sleep(50);
}
diff --git a/src/test/resources/logback.xml b/src/test/resources/logback.xml
new file mode 100644
index 0000000..c3fc5ba
--- /dev/null
+++ b/src/test/resources/logback.xml
@@ -0,0 +1,32 @@
+<!--
+ 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.
+-->
+<configuration>
+ <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+ <!-- encoders are assigned the type
+ ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
+ <encoder>
+ <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
+ </encoder>
+ </appender>
+
+
+ <root level="INFO">
+ <appender-ref ref="STDOUT" />
+ </root>
+</configuration>
\ No newline at end of file