SLING-10730 Improve configurations of integration tests
* Use factoryConfiguration from Pax Exam instead of ConfigurationAdmin
* Drop useless cleanup
* Use slingEvent option
* Use injected JobManager
* Extract base configuration into new JobsTestSupport
diff --git a/pom.xml b/pom.xml
index 166d260..177f82a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -95,6 +95,7 @@
</plugin>
<!-- integration tests run with pax-exam -->
<plugin>
+ <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<executions>
<execution>
@@ -105,23 +106,10 @@
</execution>
</executions>
<configuration>
- <systemProperties>
- <property>
- <name>bundle.filename</name>
- <value>${basedir}/target/${project.build.finalName}.jar</value>
- </property>
- <property>
- <name>org.ops4j.pax.url.mvn.useFallbackRepositories</name>
- <value>false</value>
- </property>
- <property>
- <name>org.ops4j.pax.url.mvn.repositories</name>
- <value>https://repo1.maven.org/maven2@id=central</value>
- </property>
- </systemProperties>
- <argLine>
- -Xmx2048m -XX:MaxPermSize=512m
- </argLine>
+ <redirectTestOutputToFile>true</redirectTestOutputToFile>
+ <systemPropertyVariables combine.children="append">
+ <bundle.filename>${basedir}/target/${project.build.finalName}.jar</bundle.filename>
+ </systemPropertyVariables>
<includes>
<include>**/it/*</include>
</includes>
@@ -281,6 +269,12 @@
</dependency>
<dependency>
<groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.commons.json</artifactId>
+ <version>2.0.20</version>
+ <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>
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 47931c6..8eb6572 100644
--- a/src/test/java/org/apache/sling/event/it/AbstractJobHandlingTest.java
+++ b/src/test/java/org/apache/sling/event/it/AbstractJobHandlingTest.java
@@ -18,20 +18,6 @@
*/
package org.apache.sling.event.it;
-
-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.cm.ConfigurationAdminOptions.factoryConfiguration;
-import static org.ops4j.pax.exam.cm.ConfigurationAdminOptions.newConfiguration;
-
-import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
@@ -40,148 +26,24 @@
import java.util.List;
import java.util.concurrent.atomic.AtomicReference;
-import javax.inject.Inject;
-
-import org.apache.sling.api.resource.LoginException;
-import org.apache.sling.api.resource.PersistenceException;
-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.options.ModifiableCompositeOption;
-import org.osgi.framework.BundleContext;
+import org.junit.Before;
import org.osgi.framework.InvalidSyntaxException;
import org.osgi.framework.ServiceReference;
import org.osgi.framework.ServiceRegistration;
-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 extends TestSupport {
-
- private final Logger log = LoggerFactory.getLogger(this.getClass());
-
- private static final String PROPERTY_BUNDLE_FILENAME = "bundle.filename";
+public abstract class AbstractJobHandlingTest extends JobsTestSupport {
protected static final int DEFAULT_TEST_TIMEOUT = 1000*60*5;
- @Inject
- protected EventAdmin eventAdmin;
-
- @Inject
- protected ConfigurationAdmin configAdmin;
-
- @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 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 "
- + PROPERTY_BUNDLE_FILENAME + " system property" );
- }
-
- return options(
- newConfiguration("org.apache.sling.event.impl.jobs.jcr.PersistenceHandler")
- .put(JobManagerConfiguration.PROPERTY_BACKGROUND_LOAD_DELAY, backgroundLoadDelay())
- .put("startup.delay", 1L)
- .asOption(),
- 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(),
- 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(),
- newConfiguration("org.apache.sling.commons.scheduler.impl.QuartzScheduler")
- .put("allowedPoolNames",new String[] {"oak"})
- .asOption(),
- // this test code uses loginAdministrative!
- newConfiguration("org.apache.sling.jcr.base.internal.LoginAdminWhitelist")
- .put("whitelist.bundles.regexp", "PAXEXAM-PROBE-.*")
- .asOption(),
- // 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()
- );
- }
-
- long backgroundLoadDelay() {
- return 3L;
- }
-
- 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;
- do {
- final ServiceReference<JobManager> sr = this.bc.getServiceReference(JobManager.class);
- if ( sr != null ) {
- result = this.bc.getService(sr);
- } else {
- count++;
- if ( count == 10 ) {
- break;
- }
- sleep(500);
- }
-
- } while ( result == null );
- return result;
- }
-
protected void sleep(final long time) {
try {
Thread.sleep(time);
@@ -191,81 +53,14 @@
}
}
+ @Before
public void setup() throws IOException {
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();
- for(final Resource child : rsrc.getChildren()) {
- delete(child);
- }
- resolver.delete(rsrc);
- deleteCount++;
- if ( deleteCount >= 20 ) {
- resolver.commit();
- deleteCount = 0;
- }
- }
-
- 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);
- ResourceResolver resolver = null;
- try {
- resolver = factory.getAdministrativeResourceResolver(null);
- final Resource rsrc = resolver.getResource("/var/eventing");
- if ( rsrc != null ) {
- delete(rsrc);
- resolver.commit();
- }
- } catch ( final LoginException le ) {
- // ignore
- } catch (final PersistenceException e) {
- // ignore
- } catch ( final Exception e ) {
- // sometimes an NPE is thrown from the repository, as we
- // are in the cleanup, we can ignore this
- } finally {
- if ( resolver != null ) {
- resolver.close();
- }
- }
- // unregister all services
- for(final ServiceRegistration<?> reg : this.registrations) {
- reg.unregister();
- }
- this.registrations.clear();
-
- // remove all configurations
- try {
- final org.osgi.service.cm.Configuration[] cfgs = this.configAdmin.listConfigurations(null);
- if ( cfgs != null ) {
- for(final org.osgi.service.cm.Configuration c : cfgs) {
- try {
- c.delete();
- } catch (final IOException io) {
- // ignore
- }
- }
- }
- } catch (final IOException io) {
- // ignore
- } catch (final InvalidSyntaxException e) {
- // ignore
- }
- this.sleep(1000);
- log.info("cleanup completed");
- }
-
/**
* Helper method to register an event handler
*/
diff --git a/src/test/java/org/apache/sling/event/it/AbstractMaxParallelTest.java b/src/test/java/org/apache/sling/event/it/AbstractMaxParallelTest.java
index cf3ec2f..407fc80 100644
--- a/src/test/java/org/apache/sling/event/it/AbstractMaxParallelTest.java
+++ b/src/test/java/org/apache/sling/event/it/AbstractMaxParallelTest.java
@@ -41,7 +41,6 @@
import org.apache.sling.event.jobs.JobManager;
import org.apache.sling.event.jobs.NotificationConstants;
import org.apache.sling.event.jobs.consumer.JobConsumer;
-import org.junit.After;
import org.osgi.framework.InvalidSyntaxException;
import org.osgi.framework.ServiceReference;
import org.osgi.framework.ServiceRegistration;
@@ -52,8 +51,6 @@
public abstract class AbstractMaxParallelTest extends AbstractJobHandlingTest {
- private final Logger log = LoggerFactory.getLogger(this.getClass());
-
private static final int BACKGROUND_LOAD_DELAY_SECONDS = 1;
private static final int EXTRA_CHAOS_DURATION_SECONDS = 20;
@@ -71,16 +68,10 @@
protected int max = -1;
@Override
- long backgroundLoadDelay() {
+ protected long backgroundLoadDelay() {
return BACKGROUND_LOAD_DELAY_SECONDS;
}
- @Override
- @After
- public void cleanup() {
- super.cleanup();
- }
-
private void registerMax(int cnt) {
synchronized(syncObj) {
max = Math.max(max, cnt);
@@ -231,7 +222,6 @@
}
void doTestMaxParallel(int numJobs, long jobRunMillis, long duration) throws Exception {
- final JobManager jobManager = this.getJobManager();
final Map<String, AtomicLong> added = new HashMap<>();
final Map<String, AtomicLong> created = new HashMap<>();
diff --git a/src/test/java/org/apache/sling/event/it/ChaosTest.java b/src/test/java/org/apache/sling/event/it/ChaosTest.java
index 1538593..ae8c245 100644
--- a/src/test/java/org/apache/sling/event/it/ChaosTest.java
+++ b/src/test/java/org/apache/sling/event/it/ChaosTest.java
@@ -18,16 +18,10 @@
*/
package org.apache.sling.event.it;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-
-import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.Dictionary;
import java.util.HashMap;
import java.util.HashSet;
-import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -45,18 +39,26 @@
import org.apache.sling.event.jobs.NotificationConstants;
import org.apache.sling.event.jobs.QueueConfiguration;
import org.apache.sling.event.jobs.consumer.JobConsumer;
-import org.junit.After;
-import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Configuration;
+import org.ops4j.pax.exam.Option;
import org.ops4j.pax.exam.junit.PaxExam;
+import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
+import org.ops4j.pax.exam.spi.reactors.PerMethod;
import org.osgi.framework.InvalidSyntaxException;
import org.osgi.framework.ServiceReference;
import org.osgi.framework.ServiceRegistration;
import org.osgi.service.event.Event;
import org.osgi.service.event.EventHandler;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.ops4j.pax.exam.CoreOptions.options;
+import static org.ops4j.pax.exam.cm.ConfigurationAdminOptions.factoryConfiguration;
+
@RunWith(PaxExam.class)
+@ExamReactorStrategy(PerMethod.class)
public class ChaosTest extends AbstractJobHandlingTest {
/** Duration for firing jobs in seconds. */
@@ -90,39 +92,28 @@
}
}
- @Override
- @Before
- public void setup() throws IOException {
- super.setup();
-
- // create ordered test queue
- final org.osgi.service.cm.Configuration orderedConfig = this.configAdmin.createFactoryConfiguration("org.apache.sling.event.jobs.QueueConfiguration", null);
- final Dictionary<String, Object> orderedProps = new Hashtable<>();
- orderedProps.put(ConfigurationConstants.PROP_NAME, "chaos-ordered");
- orderedProps.put(ConfigurationConstants.PROP_TYPE, QueueConfiguration.Type.ORDERED.name());
- orderedProps.put(ConfigurationConstants.PROP_TOPICS, ORDERED_TOPICS);
- orderedProps.put(ConfigurationConstants.PROP_RETRIES, 2);
- orderedProps.put(ConfigurationConstants.PROP_RETRY_DELAY, 2000L);
- orderedConfig.update(orderedProps);
-
- // create round robin test queue
- final org.osgi.service.cm.Configuration rrConfig = this.configAdmin.createFactoryConfiguration("org.apache.sling.event.jobs.QueueConfiguration", null);
- final Dictionary<String, Object> rrProps = new Hashtable<>();
- rrProps.put(ConfigurationConstants.PROP_NAME, "chaos-roundrobin");
- rrProps.put(ConfigurationConstants.PROP_TYPE, QueueConfiguration.Type.TOPIC_ROUND_ROBIN.name());
- rrProps.put(ConfigurationConstants.PROP_TOPICS, ROUND_TOPICS);
- rrProps.put(ConfigurationConstants.PROP_RETRIES, 2);
- rrProps.put(ConfigurationConstants.PROP_RETRY_DELAY, 2000L);
- rrProps.put(ConfigurationConstants.PROP_MAX_PARALLEL, 5);
- rrConfig.update(rrProps);
-
- this.sleep(1000L);
- }
-
- @Override
- @After
- public void cleanup() {
- super.cleanup();
+ @Configuration
+ public Option[] configuration() {
+ return options(
+ baseConfiguration(),
+ // create ordered test queue
+ factoryConfiguration("org.apache.sling.event.jobs.QueueConfiguration")
+ .put(ConfigurationConstants.PROP_NAME, "chaos-ordered")
+ .put(ConfigurationConstants.PROP_TYPE, QueueConfiguration.Type.ORDERED.name())
+ .put(ConfigurationConstants.PROP_TOPICS, ORDERED_TOPICS)
+ .put(ConfigurationConstants.PROP_RETRIES, 2)
+ .put(ConfigurationConstants.PROP_RETRY_DELAY, 2000L)
+ .asOption(),
+ // create round robin test queue
+ factoryConfiguration("org.apache.sling.event.jobs.QueueConfiguration")
+ .put(ConfigurationConstants.PROP_NAME, "chaos-roundrobin")
+ .put(ConfigurationConstants.PROP_TYPE, QueueConfiguration.Type.TOPIC_ROUND_ROBIN.name())
+ .put(ConfigurationConstants.PROP_TOPICS, ROUND_TOPICS)
+ .put(ConfigurationConstants.PROP_RETRIES, 2)
+ .put(ConfigurationConstants.PROP_RETRY_DELAY, 2000L)
+ .put(ConfigurationConstants.PROP_MAX_PARALLEL, 5)
+ .asOption()
+ );
}
/**
@@ -307,7 +298,6 @@
@Test(timeout=DURATION * 16000L)
public void testDoChaos() throws Exception {
- final JobManager jobManager = this.getJobManager();
// setup added, created and finished map
// added and finished are filled by notifications
diff --git a/src/test/java/org/apache/sling/event/it/ClassloadingTest.java b/src/test/java/org/apache/sling/event/it/ClassloadingTest.java
index b182401..d03ed6c 100644
--- a/src/test/java/org/apache/sling/event/it/ClassloadingTest.java
+++ b/src/test/java/org/apache/sling/event/it/ClassloadingTest.java
@@ -18,17 +18,10 @@
*/
package org.apache.sling.event.it;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-
-import java.io.IOException;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
-import java.util.Dictionary;
import java.util.HashMap;
-import java.util.Hashtable;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CountDownLatch;
@@ -42,15 +35,24 @@
import org.apache.sling.event.jobs.QueueConfiguration;
import org.apache.sling.event.jobs.consumer.JobConsumer;
import org.apache.sling.testing.tools.retry.RetryLoop;
-import org.junit.After;
-import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Configuration;
+import org.ops4j.pax.exam.Option;
import org.ops4j.pax.exam.junit.PaxExam;
+import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
+import org.ops4j.pax.exam.spi.reactors.PerMethod;
import org.osgi.service.event.Event;
import org.osgi.service.event.EventHandler;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.ops4j.pax.exam.CoreOptions.options;
+import static org.ops4j.pax.exam.cm.ConfigurationAdminOptions.factoryConfiguration;
+
@RunWith(PaxExam.class)
+@ExamReactorStrategy(PerMethod.class)
public class ClassloadingTest extends AbstractJobHandlingTest {
private static final int CONDITION_INTERVAL_MILLIS = 50;
@@ -59,26 +61,17 @@
private static final String QUEUE_NAME = "cltest";
private static final String TOPIC = "sling/cltest";
- @Override
- @Before
- public void setup() throws IOException {
- super.setup();
-
- // create ignore test queue
- final org.osgi.service.cm.Configuration orderedConfig = this.configAdmin.createFactoryConfiguration("org.apache.sling.event.jobs.QueueConfiguration", null);
- final Dictionary<String, Object> orderedProps = new Hashtable<String, Object>();
- orderedProps.put(ConfigurationConstants.PROP_NAME, QUEUE_NAME);
- orderedProps.put(ConfigurationConstants.PROP_TYPE, QueueConfiguration.Type.UNORDERED.name());
- orderedProps.put(ConfigurationConstants.PROP_TOPICS, TOPIC);
- orderedConfig.update(orderedProps);
-
- this.sleep(1000L);
- }
-
- @Override
- @After
- public void cleanup() {
- super.cleanup();
+ @Configuration
+ public Option[] configuration() {
+ return options(
+ baseConfiguration(),
+ // create ignore test queue
+ factoryConfiguration("org.apache.sling.event.jobs.QueueConfiguration")
+ .put(ConfigurationConstants.PROP_NAME, QUEUE_NAME)
+ .put(ConfigurationConstants.PROP_TYPE, QueueConfiguration.Type.UNORDERED.name())
+ .put(ConfigurationConstants.PROP_TOPICS, TOPIC)
+ .asOption()
+ );
}
@Test(timeout = DEFAULT_TEST_TIMEOUT)
@@ -103,7 +96,6 @@
latch.countDown();
}
});
- final JobManager jobManager = this.getJobManager();
final List<String> list = new ArrayList<String>();
list.add("1");
@@ -160,7 +152,6 @@
finishedEvents.add(event);
}
});
- final JobManager jobManager = this.getJobManager();
// dao is an invisible class for the dynamic class loader as it is not public
// therefore scheduling this job should fail!
diff --git a/src/test/java/org/apache/sling/event/it/HistoryTest.java b/src/test/java/org/apache/sling/event/it/HistoryTest.java
index d797f35..37f0038 100644
--- a/src/test/java/org/apache/sling/event/it/HistoryTest.java
+++ b/src/test/java/org/apache/sling/event/it/HistoryTest.java
@@ -18,15 +18,8 @@
*/
package org.apache.sling.event.it;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-import java.io.IOException;
import java.util.Collection;
-import java.util.Dictionary;
import java.util.HashMap;
-import java.util.Hashtable;
import java.util.Map;
import org.apache.sling.event.impl.jobs.config.ConfigurationConstants;
@@ -36,49 +29,48 @@
import org.apache.sling.event.jobs.consumer.JobExecutionContext;
import org.apache.sling.event.jobs.consumer.JobExecutionResult;
import org.apache.sling.event.jobs.consumer.JobExecutor;
-import org.junit.After;
-import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Configuration;
+import org.ops4j.pax.exam.Option;
import org.ops4j.pax.exam.junit.PaxExam;
+import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
+import org.ops4j.pax.exam.spi.reactors.PerMethod;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.ops4j.pax.exam.CoreOptions.options;
+import static org.ops4j.pax.exam.cm.ConfigurationAdminOptions.factoryConfiguration;
@RunWith(PaxExam.class)
+@ExamReactorStrategy(PerMethod.class)
public class HistoryTest extends AbstractJobHandlingTest {
private static final String TOPIC = "sling/test/history";
private static final String PROP_COUNTER = "counter";
- @Override
- @Before
- public void setup() throws IOException {
- super.setup();
-
- // create test queue - we use an ordered queue to have a stable processing order
- // keep the jobs in the history
- final org.osgi.service.cm.Configuration config = this.configAdmin.createFactoryConfiguration("org.apache.sling.event.jobs.QueueConfiguration", null);
- Dictionary<String, Object> props = new Hashtable<String, Object>();
- props.put(ConfigurationConstants.PROP_NAME, "test");
- props.put(ConfigurationConstants.PROP_TYPE, QueueConfiguration.Type.ORDERED.name());
- props.put(ConfigurationConstants.PROP_TOPICS, new String[] {TOPIC});
- props.put(ConfigurationConstants.PROP_RETRIES, 2);
- props.put(ConfigurationConstants.PROP_RETRY_DELAY, 2L);
- props.put(ConfigurationConstants.PROP_KEEP_JOBS, true);
- config.update(props);
-
- this.sleep(1000L);
- }
-
- @Override
- @After
- public void cleanup() {
- super.cleanup();
+ @Configuration
+ public Option[] configuration() {
+ return options(
+ baseConfiguration(),
+ // create test queue - we use an ordered queue to have a stable processing order
+ // keep the jobs in the history
+ factoryConfiguration("org.apache.sling.event.jobs.QueueConfiguration")
+ .put(ConfigurationConstants.PROP_NAME, "test")
+ .put(ConfigurationConstants.PROP_TYPE, QueueConfiguration.Type.ORDERED.name())
+ .put(ConfigurationConstants.PROP_TOPICS, new String[]{TOPIC})
+ .put(ConfigurationConstants.PROP_RETRIES, 2)
+ .put(ConfigurationConstants.PROP_RETRY_DELAY, 2L)
+ .put(ConfigurationConstants.PROP_KEEP_JOBS, true)
+ .asOption()
+ );
}
private Job addJob(final long counter) {
final Map<String, Object> props = new HashMap<String, Object>();
props.put(PROP_COUNTER, counter);
- return this.getJobManager().addJob(TOPIC, props );
+ return jobManager.addJob(TOPIC, props );
}
/**
@@ -105,23 +97,23 @@
this.addJob(i);
}
this.sleep(200L);
- while ( this.getJobManager().findJobs(JobManager.QueryType.HISTORY, TOPIC, -1, (Map<String, Object>[])null).size() < 10 ) {
+ while (jobManager.findJobs(JobManager.QueryType.HISTORY, TOPIC, -1, (Map<String, Object>[])null).size() < 10 ) {
this.sleep(20L);
}
- Collection<Job> col = this.getJobManager().findJobs(JobManager.QueryType.HISTORY, TOPIC, -1, (Map<String, Object>[])null);
+ Collection<Job> col = jobManager.findJobs(JobManager.QueryType.HISTORY, TOPIC, -1, (Map<String, Object>[])null);
assertEquals(10, col.size());
- assertEquals(0, this.getJobManager().findJobs(JobManager.QueryType.ACTIVE, TOPIC, -1, (Map<String, Object>[])null).size());
- assertEquals(0, this.getJobManager().findJobs(JobManager.QueryType.QUEUED, TOPIC, -1, (Map<String, Object>[])null).size());
- assertEquals(0, this.getJobManager().findJobs(JobManager.QueryType.ALL, TOPIC, -1, (Map<String, Object>[])null).size());
- assertEquals(3, this.getJobManager().findJobs(JobManager.QueryType.CANCELLED, TOPIC, -1, (Map<String, Object>[])null).size());
- assertEquals(0, this.getJobManager().findJobs(JobManager.QueryType.DROPPED, TOPIC, -1, (Map<String, Object>[])null).size());
- assertEquals(3, this.getJobManager().findJobs(JobManager.QueryType.ERROR, TOPIC, -1, (Map<String, Object>[])null).size());
- assertEquals(0, this.getJobManager().findJobs(JobManager.QueryType.GIVEN_UP, TOPIC, -1, (Map<String, Object>[])null).size());
- assertEquals(0, this.getJobManager().findJobs(JobManager.QueryType.STOPPED, TOPIC, -1, (Map<String, Object>[])null).size());
- assertEquals(7, this.getJobManager().findJobs(JobManager.QueryType.SUCCEEDED, TOPIC, -1, (Map<String, Object>[])null).size());
+ assertEquals(0, jobManager.findJobs(JobManager.QueryType.ACTIVE, TOPIC, -1, (Map<String, Object>[])null).size());
+ assertEquals(0, jobManager.findJobs(JobManager.QueryType.QUEUED, TOPIC, -1, (Map<String, Object>[])null).size());
+ assertEquals(0, jobManager.findJobs(JobManager.QueryType.ALL, TOPIC, -1, (Map<String, Object>[])null).size());
+ assertEquals(3, jobManager.findJobs(JobManager.QueryType.CANCELLED, TOPIC, -1, (Map<String, Object>[])null).size());
+ assertEquals(0, jobManager.findJobs(JobManager.QueryType.DROPPED, TOPIC, -1, (Map<String, Object>[])null).size());
+ assertEquals(3, jobManager.findJobs(JobManager.QueryType.ERROR, TOPIC, -1, (Map<String, Object>[])null).size());
+ assertEquals(0, jobManager.findJobs(JobManager.QueryType.GIVEN_UP, TOPIC, -1, (Map<String, Object>[])null).size());
+ assertEquals(0, jobManager.findJobs(JobManager.QueryType.STOPPED, TOPIC, -1, (Map<String, Object>[])null).size());
+ assertEquals(7, jobManager.findJobs(JobManager.QueryType.SUCCEEDED, TOPIC, -1, (Map<String, Object>[])null).size());
// find all topics
- assertEquals(7, this.getJobManager().findJobs(JobManager.QueryType.SUCCEEDED, null, -1, (Map<String, Object>[])null).size());
+ assertEquals(7, jobManager.findJobs(JobManager.QueryType.SUCCEEDED, null, -1, (Map<String, Object>[])null).size());
// verify order, message and state
long last = 9;
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 d69d036..dea7c32 100644
--- a/src/test/java/org/apache/sling/event/it/JobHandlingTest.java
+++ b/src/test/java/org/apache/sling/event/it/JobHandlingTest.java
@@ -18,18 +18,9 @@
*/
package org.apache.sling.event.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 java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
-import java.util.Dictionary;
-import java.util.Hashtable;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
@@ -44,45 +35,46 @@
import org.apache.sling.event.jobs.consumer.JobExecutionContext;
import org.apache.sling.event.jobs.consumer.JobExecutionResult;
import org.apache.sling.event.jobs.consumer.JobExecutor;
-import org.junit.After;
-import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Configuration;
+import org.ops4j.pax.exam.Option;
import org.ops4j.pax.exam.junit.PaxExam;
+import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
+import org.ops4j.pax.exam.spi.reactors.PerMethod;
import org.osgi.service.event.Event;
import org.osgi.service.event.EventHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+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 static org.ops4j.pax.exam.CoreOptions.options;
+import static org.ops4j.pax.exam.cm.ConfigurationAdminOptions.factoryConfiguration;
+
@RunWith(PaxExam.class)
+@ExamReactorStrategy(PerMethod.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 {
- super.setup();
-
- // create test queue
- final org.osgi.service.cm.Configuration config = this.configAdmin.createFactoryConfiguration("org.apache.sling.event.jobs.QueueConfiguration", null);
- Dictionary<String, Object> props = new Hashtable<String, Object>();
- props.put(ConfigurationConstants.PROP_NAME, "test");
- props.put(ConfigurationConstants.PROP_TYPE, QueueConfiguration.Type.UNORDERED.name());
- props.put(ConfigurationConstants.PROP_TOPICS, new String[] {TOPIC, TOPIC + "2"});
- props.put(ConfigurationConstants.PROP_RETRIES, 2);
- props.put(ConfigurationConstants.PROP_RETRY_DELAY, 2000L);
- config.update(props);
-
- this.sleep(1000L);
- }
-
- @Override
- @After
- public void cleanup() {
- super.cleanup();
+ @Configuration
+ public Option[] configuration() {
+ return options(
+ baseConfiguration(),
+ // create test queue
+ factoryConfiguration("org.apache.sling.event.jobs.QueueConfiguration")
+ .put(ConfigurationConstants.PROP_NAME, "test")
+ .put(ConfigurationConstants.PROP_TYPE, QueueConfiguration.Type.UNORDERED.name())
+ .put(ConfigurationConstants.PROP_TOPICS, new String[]{TOPIC, TOPIC + "2"})
+ .put(ConfigurationConstants.PROP_RETRIES, 2)
+ .put(ConfigurationConstants.PROP_RETRY_DELAY, 2000L)
+ .asOption()
+ );
}
/**
@@ -103,7 +95,7 @@
}
});
- this.getJobManager().addJob(TOPIC, null);
+ jobManager.addJob(TOPIC, null);
assertTrue("No event received in the given time.", cb.block(5));
cb.reset();
assertFalse("Unexpected event received in the given time.", cb.block(5));
@@ -127,7 +119,7 @@
}
});
- this.getJobManager().addJob(TOPIC, null);
+ jobManager.addJob(TOPIC, null);
assertTrue("No event received in the given time.", cb.block(5));
cb.reset();
assertFalse("Unexpected event received in the given time.", cb.block(5));
@@ -156,13 +148,13 @@
// we start "some" jobs
final int COUNT = 300;
for(int i = 0; i < COUNT; i++ ) {
- this.getJobManager().addJob(TOPIC, null);
+ jobManager.addJob(TOPIC, null);
}
while ( count.get() < COUNT ) {
this.sleep(50);
}
assertEquals("Finished count", COUNT, count.get());
- assertEquals("Finished count", COUNT, this.getJobManager().getStatistics().getNumberOfFinishedJobs());
+ assertEquals("Finished count", COUNT, jobManager.getStatistics().getNumberOfFinishedJobs());
}
/**
@@ -190,7 +182,6 @@
jobPropertiesAsArray[0] = jobProperties;
// create job
- final JobManager jobManager = this.getJobManager();
jobManager.addJob(TOPIC, jobProperties);
cb.block();
@@ -235,7 +226,6 @@
return JobResult.OK;
}
});
- final JobManager jobManager = this.getJobManager();
final Job j = jobManager.addJob(TOPIC, null);
cb.block();
@@ -274,7 +264,6 @@
}
});
- final JobManager jobManager = this.getJobManager();
final Job job = jobManager.addJob(TOPIC, null);
assertTrue("No event received in the given time.", cb.block(5));
@@ -378,8 +367,6 @@
}
});
- final JobManager jobManager = this.getJobManager();
-
jobManager.addJob(TOPIC, Collections.singletonMap("id", (Object)"1"));
jobManager.addJob(TOPIC, Collections.singletonMap("id", (Object)"2"));
jobManager.addJob(TOPIC, Collections.singletonMap("id", (Object)"3"));
@@ -420,8 +407,6 @@
}
});
- 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;
diff --git a/src/test/java/org/apache/sling/event/it/JobsTestSupport.java b/src/test/java/org/apache/sling/event/it/JobsTestSupport.java
new file mode 100644
index 0000000..5414d64
--- /dev/null
+++ b/src/test/java/org/apache/sling/event/it/JobsTestSupport.java
@@ -0,0 +1,116 @@
+/*
+ * 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.event.it;
+
+import java.util.Objects;
+
+import javax.inject.Inject;
+
+import org.apache.sling.event.impl.jobs.config.JobManagerConfiguration;
+import org.apache.sling.event.jobs.JobManager;
+import org.apache.sling.jcr.api.SlingRepository;
+import org.apache.sling.testing.paxexam.TestSupport;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.options.ModifiableCompositeOption;
+import org.ops4j.pax.exam.options.OptionalCompositeOption;
+import org.ops4j.pax.exam.options.extra.VMOption;
+import org.osgi.framework.BundleContext;
+import org.osgi.service.cm.ConfigurationAdmin;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import static org.apache.sling.testing.paxexam.SlingOptions.slingEvent;
+import static org.apache.sling.testing.paxexam.SlingOptions.slingQuickstartOakTar;
+import static org.apache.sling.testing.paxexam.SlingOptions.versionResolver;
+import static org.ops4j.pax.exam.CoreOptions.composite;
+import static org.ops4j.pax.exam.CoreOptions.junitBundles;
+import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
+import static org.ops4j.pax.exam.CoreOptions.vmOption;
+import static org.ops4j.pax.exam.CoreOptions.when;
+import static org.ops4j.pax.exam.cm.ConfigurationAdminOptions.newConfiguration;
+
+public abstract class JobsTestSupport extends TestSupport {
+
+ @Inject
+ protected SlingRepository slingRepository;
+
+ @Inject
+ protected ConfigurationAdmin configAdmin;
+
+ @Inject
+ protected BundleContext bc;
+
+ @Inject
+ protected JobManager jobManager;
+
+ protected final Logger log = LoggerFactory.getLogger(this.getClass());
+
+ protected long backgroundLoadDelay() {
+ return 3L;
+ }
+
+ public ModifiableCompositeOption baseConfiguration() {
+ return composite(
+ super.baseConfiguration(),
+ slingQuickstart(),
+ // Sling Event
+ testBundle("bundle.filename"),
+ slingEvent(),
+ // testing configurations
+ newConfiguration("org.apache.sling.event.impl.jobs.jcr.PersistenceHandler")
+ .put(JobManagerConfiguration.PROPERTY_BACKGROUND_LOAD_DELAY, backgroundLoadDelay())
+ .put("startup.delay", 1L)
+ .asOption(),
+ newConfiguration("org.apache.sling.commons.scheduler.impl.QuartzScheduler")
+ .put("allowedPoolNames", new String[]{"oak"})
+ .asOption(),
+ // this test code uses loginAdministrative!
+ newConfiguration("org.apache.sling.jcr.base.internal.LoginAdminWhitelist")
+ .put("whitelist.bundles.regexp", "PAXEXAM-PROBE-.*")
+ .asOption(),
+ // otherwise we get ignored events
+ newConfiguration("org.apache.felix.eventadmin.impl.EventAdmin")
+ .put("org.apache.felix.eventadmin.IgnoreTimeout", "*")
+ .asOption(),
+ // testing
+ mavenBundle().groupId("org.apache.sling").artifactId("org.apache.sling.testing.tools").versionAsInProject(),
+ mavenBundle().groupId("org.apache.sling").artifactId("org.apache.sling.commons.json").versionAsInProject(),
+ junitBundles(),
+ jacoco() // remove with Testing PaxExam 4.0
+ ).remove(
+ mavenBundle().groupId("org.apache.sling").artifactId("org.apache.sling.event").version(versionResolver)
+ );
+ }
+
+ protected Option slingQuickstart() {
+ final String workingDirectory = workingDirectory();
+ final int httpPort = findFreePort();
+ return composite(
+ slingQuickstartOakTar(workingDirectory, httpPort)
+ );
+ }
+
+ // remove with Testing PaxExam 4.0
+ protected OptionalCompositeOption jacoco() {
+ final String jacocoCommand = System.getProperty("jacoco.command");
+ final VMOption option = Objects.nonNull(jacocoCommand) && !jacocoCommand.trim().isEmpty() ? vmOption(jacocoCommand) : null;
+ return when(Objects.nonNull(option)).useOptions(option);
+ }
+
+}
diff --git a/src/test/java/org/apache/sling/event/it/OrderedMaxParallelTest.java b/src/test/java/org/apache/sling/event/it/OrderedMaxParallelTest.java
index 03085cd..958f891 100644
--- a/src/test/java/org/apache/sling/event/it/OrderedMaxParallelTest.java
+++ b/src/test/java/org/apache/sling/event/it/OrderedMaxParallelTest.java
@@ -18,41 +18,40 @@
*/
package org.apache.sling.event.it;
-import static org.junit.Assert.assertEquals;
-
-import java.io.IOException;
-import java.util.Dictionary;
-import java.util.Hashtable;
-
import org.apache.sling.event.impl.jobs.config.ConfigurationConstants;
import org.apache.sling.event.jobs.QueueConfiguration;
-import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Configuration;
+import org.ops4j.pax.exam.Option;
import org.ops4j.pax.exam.junit.PaxExam;
+import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
+import org.ops4j.pax.exam.spi.reactors.PerMethod;
+
+import static org.junit.Assert.assertEquals;
+import static org.ops4j.pax.exam.CoreOptions.options;
+import static org.ops4j.pax.exam.cm.ConfigurationAdminOptions.factoryConfiguration;
@RunWith(PaxExam.class)
+@ExamReactorStrategy(PerMethod.class)
public class OrderedMaxParallelTest extends AbstractMaxParallelTest {
private static final int DURATION = 40;
- @Override
- @Before
- public void setup() throws IOException {
- super.setup();
-
- // create ordered test queue
- final org.osgi.service.cm.Configuration orderedConfig = this.configAdmin.createFactoryConfiguration("org.apache.sling.event.jobs.QueueConfiguration", null);
- final Dictionary<String, Object> orderedProps = new Hashtable<>();
- orderedProps.put(ConfigurationConstants.PROP_NAME, "ordered-max-parallel");
- orderedProps.put(ConfigurationConstants.PROP_TYPE, QueueConfiguration.Type.ORDERED.name());
- orderedProps.put(ConfigurationConstants.PROP_TOPICS, TOPIC_NAME);
- orderedProps.put(ConfigurationConstants.PROP_RETRIES, 2);
- orderedProps.put(ConfigurationConstants.PROP_RETRY_DELAY, 2000L);
- orderedProps.put(ConfigurationConstants.PROP_MAX_PARALLEL, 1);
- orderedConfig.update(orderedProps);
-
- this.sleep(1000L);
+ @Configuration
+ public Option[] configuration() {
+ return options(
+ baseConfiguration(),
+ // create ordered test queue
+ factoryConfiguration("org.apache.sling.event.jobs.QueueConfiguration")
+ .put(ConfigurationConstants.PROP_NAME, "ordered-max-parallel")
+ .put(ConfigurationConstants.PROP_TYPE, QueueConfiguration.Type.ORDERED.name())
+ .put(ConfigurationConstants.PROP_TOPICS, TOPIC_NAME)
+ .put(ConfigurationConstants.PROP_RETRIES, 2)
+ .put(ConfigurationConstants.PROP_RETRY_DELAY, 2000L)
+ .put(ConfigurationConstants.PROP_MAX_PARALLEL, 1)
+ .asOption()
+ );
}
@Test(timeout=DURATION * 16000L)
diff --git a/src/test/java/org/apache/sling/event/it/OrderedQueueTest.java b/src/test/java/org/apache/sling/event/it/OrderedQueueTest.java
index be23f69..5f7a18a 100644
--- a/src/test/java/org/apache/sling/event/it/OrderedQueueTest.java
+++ b/src/test/java/org/apache/sling/event/it/OrderedQueueTest.java
@@ -18,60 +18,51 @@
*/
package org.apache.sling.event.it;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-import java.io.IOException;
-import java.util.Dictionary;
import java.util.HashMap;
-import java.util.Hashtable;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
import org.apache.sling.event.impl.Barrier;
import org.apache.sling.event.impl.jobs.config.ConfigurationConstants;
import org.apache.sling.event.jobs.Job;
-import org.apache.sling.event.jobs.JobManager;
import org.apache.sling.event.jobs.NotificationConstants;
import org.apache.sling.event.jobs.Queue;
import org.apache.sling.event.jobs.QueueConfiguration;
import org.apache.sling.event.jobs.consumer.JobConsumer;
-import org.junit.After;
-import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Configuration;
+import org.ops4j.pax.exam.Option;
import org.ops4j.pax.exam.junit.PaxExam;
+import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
+import org.ops4j.pax.exam.spi.reactors.PerMethod;
import org.osgi.service.event.Event;
import org.osgi.service.event.EventHandler;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.ops4j.pax.exam.CoreOptions.options;
+import static org.ops4j.pax.exam.cm.ConfigurationAdminOptions.factoryConfiguration;
+
@RunWith(PaxExam.class)
+@ExamReactorStrategy(PerMethod.class)
public class OrderedQueueTest extends AbstractJobHandlingTest {
- @Override
- @Before
- public void setup() throws IOException {
- super.setup();
-
- // create ordered test queue
- final org.osgi.service.cm.Configuration orderedConfig = this.configAdmin.createFactoryConfiguration("org.apache.sling.event.jobs.QueueConfiguration", null);
- final Dictionary<String, Object> orderedProps = new Hashtable<String, Object>();
- orderedProps.put(ConfigurationConstants.PROP_NAME, "orderedtest");
- orderedProps.put(ConfigurationConstants.PROP_TYPE, QueueConfiguration.Type.ORDERED.name());
- orderedProps.put(ConfigurationConstants.PROP_TOPICS, "sling/orderedtest/*");
- orderedProps.put(ConfigurationConstants.PROP_RETRIES, 2);
- orderedProps.put(ConfigurationConstants.PROP_RETRY_DELAY, 2000L);
- orderedConfig.update(orderedProps);
-
- this.sleep(1000L);
- }
-
- @Override
- @After
- public void cleanup() {
- super.cleanup();
+ @Configuration
+ public Option[] configuration() {
+ return options(
+ baseConfiguration(),
+ // create ordered test queue
+ factoryConfiguration("org.apache.sling.event.jobs.QueueConfiguration")
+ .put(ConfigurationConstants.PROP_NAME, "orderedtest")
+ .put(ConfigurationConstants.PROP_TYPE, QueueConfiguration.Type.ORDERED.name())
+ .put(ConfigurationConstants.PROP_TOPICS, "sling/orderedtest/*")
+ .put(ConfigurationConstants.PROP_RETRIES, 2)
+ .put(ConfigurationConstants.PROP_RETRY_DELAY, 2000L)
+ .asOption()
+ );
}
/**
@@ -79,7 +70,6 @@
*/
@Test(timeout = DEFAULT_TEST_TIMEOUT)
public void testOrderedQueue() throws Exception {
- final JobManager jobManager = this.getJobManager();
// register consumer and event handler
final Barrier cb = new Barrier(2);
diff --git a/src/test/java/org/apache/sling/event/it/RoundRobinMaxParallelTest.java b/src/test/java/org/apache/sling/event/it/RoundRobinMaxParallelTest.java
index 7e5531b..b1b6494 100644
--- a/src/test/java/org/apache/sling/event/it/RoundRobinMaxParallelTest.java
+++ b/src/test/java/org/apache/sling/event/it/RoundRobinMaxParallelTest.java
@@ -18,43 +18,41 @@
*/
package org.apache.sling.event.it;
-import static org.junit.Assert.assertTrue;
-
-import java.io.IOException;
-import java.util.Dictionary;
-import java.util.Hashtable;
-
import org.apache.sling.event.impl.jobs.config.ConfigurationConstants;
import org.apache.sling.event.jobs.QueueConfiguration;
-import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Configuration;
+import org.ops4j.pax.exam.Option;
import org.ops4j.pax.exam.junit.PaxExam;
+import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
+import org.ops4j.pax.exam.spi.reactors.PerMethod;
+
+import static org.junit.Assert.assertTrue;
+import static org.ops4j.pax.exam.CoreOptions.options;
+import static org.ops4j.pax.exam.cm.ConfigurationAdminOptions.factoryConfiguration;
@RunWith(PaxExam.class)
+@ExamReactorStrategy(PerMethod.class)
public class RoundRobinMaxParallelTest extends AbstractMaxParallelTest {
private static final int MAX_PARALLEL = 3;
private static final int DURATION = 50;
- @Override
- @Before
- public void setup() throws IOException {
- super.setup();
-
- // create ordered test queue
- final org.osgi.service.cm.Configuration orderedConfig = this.configAdmin.createFactoryConfiguration("org.apache.sling.event.jobs.QueueConfiguration", null);
- final Dictionary<String, Object> orderedProps = new Hashtable<>();
- orderedProps.put(ConfigurationConstants.PROP_NAME, "round-robin-max-parallel");
- orderedProps.put(ConfigurationConstants.PROP_TYPE, QueueConfiguration.Type.TOPIC_ROUND_ROBIN.name());
- orderedProps.put(ConfigurationConstants.PROP_TOPICS, TOPIC_NAME);
- orderedProps.put(ConfigurationConstants.PROP_RETRIES, 2);
- orderedProps.put(ConfigurationConstants.PROP_RETRY_DELAY, 2000L);
- orderedProps.put(ConfigurationConstants.PROP_MAX_PARALLEL, MAX_PARALLEL);
- orderedConfig.update(orderedProps);
-
- this.sleep(1000L);
+ @Configuration
+ public Option[] configuration() {
+ return options(
+ baseConfiguration(),
+ factoryConfiguration("org.apache.sling.event.jobs.QueueConfiguration")
+ .put(ConfigurationConstants.PROP_NAME, "round-robin-max-parallel")
+ .put(ConfigurationConstants.PROP_TYPE, QueueConfiguration.Type.TOPIC_ROUND_ROBIN.name())
+ .put(ConfigurationConstants.PROP_TOPICS, TOPIC_NAME)
+ .put(ConfigurationConstants.PROP_RETRIES, 2)
+ .put(ConfigurationConstants.PROP_RETRY_DELAY, 2000L)
+ .put(ConfigurationConstants.PROP_MAX_PARALLEL, MAX_PARALLEL)
+ .asOption()
+ );
}
@Test(timeout=DURATION * 16000L)
diff --git a/src/test/java/org/apache/sling/event/it/RoundRobinQueueTest.java b/src/test/java/org/apache/sling/event/it/RoundRobinQueueTest.java
index 00dfe2d..36ab986 100644
--- a/src/test/java/org/apache/sling/event/it/RoundRobinQueueTest.java
+++ b/src/test/java/org/apache/sling/event/it/RoundRobinQueueTest.java
@@ -18,15 +18,8 @@
*/
package org.apache.sling.event.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.Dictionary;
import java.util.HashMap;
import java.util.HashSet;
-import java.util.Hashtable;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger;
@@ -34,20 +27,28 @@
import org.apache.sling.event.impl.Barrier;
import org.apache.sling.event.impl.jobs.config.ConfigurationConstants;
import org.apache.sling.event.jobs.Job;
-import org.apache.sling.event.jobs.JobManager;
import org.apache.sling.event.jobs.NotificationConstants;
import org.apache.sling.event.jobs.Queue;
import org.apache.sling.event.jobs.QueueConfiguration;
import org.apache.sling.event.jobs.consumer.JobConsumer;
-import org.junit.After;
-import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Configuration;
+import org.ops4j.pax.exam.Option;
import org.ops4j.pax.exam.junit.PaxExam;
+import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
+import org.ops4j.pax.exam.spi.reactors.PerMethod;
import org.osgi.service.event.Event;
import org.osgi.service.event.EventHandler;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.ops4j.pax.exam.CoreOptions.options;
+import static org.ops4j.pax.exam.cm.ConfigurationAdminOptions.factoryConfiguration;
+
@RunWith(PaxExam.class)
+@ExamReactorStrategy(PerMethod.class)
public class RoundRobinQueueTest extends AbstractJobHandlingTest {
private static final String QUEUE_NAME = "roundrobintest";
@@ -55,34 +56,24 @@
private static int MAX_PAR = 5;
private static int NUM_JOBS = 300;
- @Override
- @Before
- public void setup() throws IOException {
- super.setup();
-
- // create round robin test queue
- final org.osgi.service.cm.Configuration rrConfig = this.configAdmin.createFactoryConfiguration("org.apache.sling.event.jobs.QueueConfiguration", null);
- final Dictionary<String, Object> rrProps = new Hashtable<String, Object>();
- rrProps.put(ConfigurationConstants.PROP_NAME, QUEUE_NAME);
- rrProps.put(ConfigurationConstants.PROP_TYPE, QueueConfiguration.Type.TOPIC_ROUND_ROBIN.name());
- rrProps.put(ConfigurationConstants.PROP_TOPICS, TOPIC + "/*");
- rrProps.put(ConfigurationConstants.PROP_RETRIES, 2);
- rrProps.put(ConfigurationConstants.PROP_RETRY_DELAY, 2000L);
- rrProps.put(ConfigurationConstants.PROP_MAX_PARALLEL, MAX_PAR);
- rrConfig.update(rrProps);
-
- this.sleep(1000L);
- }
-
- @Override
- @After
- public void cleanup() {
- super.cleanup();
+ @Configuration
+ public Option[] configuration() {
+ return options(
+ baseConfiguration(),
+ // create round robin test queue
+ factoryConfiguration("org.apache.sling.event.jobs.QueueConfiguration")
+ .put(ConfigurationConstants.PROP_NAME, QUEUE_NAME)
+ .put(ConfigurationConstants.PROP_TYPE, QueueConfiguration.Type.TOPIC_ROUND_ROBIN.name())
+ .put(ConfigurationConstants.PROP_TOPICS, TOPIC + "/*")
+ .put(ConfigurationConstants.PROP_RETRIES, 2)
+ .put(ConfigurationConstants.PROP_RETRY_DELAY, 2000L)
+ .put(ConfigurationConstants.PROP_MAX_PARALLEL, MAX_PAR)
+ .asOption()
+ );
}
@Test(timeout = DEFAULT_TEST_TIMEOUT)
public void testRoundRobinQueue() throws Exception {
- final JobManager jobManager = this.getJobManager();
final Barrier cb = new Barrier(2);
diff --git a/src/test/java/org/apache/sling/event/it/SchedulingTest.java b/src/test/java/org/apache/sling/event/it/SchedulingTest.java
index 980e694..d0156f1 100644
--- a/src/test/java/org/apache/sling/event/it/SchedulingTest.java
+++ b/src/test/java/org/apache/sling/event/it/SchedulingTest.java
@@ -18,10 +18,6 @@
*/
package org.apache.sling.event.it;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-import java.io.IOException;
import java.util.Date;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicInteger;
@@ -29,33 +25,33 @@
import org.apache.sling.event.jobs.Job;
import org.apache.sling.event.jobs.ScheduledJobInfo;
import org.apache.sling.event.jobs.consumer.JobConsumer;
-import org.junit.After;
-import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Configuration;
+import org.ops4j.pax.exam.Option;
import org.ops4j.pax.exam.junit.PaxExam;
+import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
+import org.ops4j.pax.exam.spi.reactors.PerMethod;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.ops4j.pax.exam.CoreOptions.options;
+
@RunWith(PaxExam.class)
+@ExamReactorStrategy(PerMethod.class)
public class SchedulingTest extends AbstractJobHandlingTest {
private static final String TOPIC = "job/scheduled/topic";
private final Logger logger = LoggerFactory.getLogger(getClass());
- @Override
- @Before
- public void setup() throws IOException {
- super.setup();
-
- this.sleep(1000L);
- }
-
- @Override
- @After
- public void cleanup() {
- super.cleanup();
+ @Configuration
+ public Option[] configuration() {
+ return options(
+ baseConfiguration()
+ );
}
@Test(timeout = DEFAULT_TEST_TIMEOUT)
@@ -75,20 +71,20 @@
});
// we schedule three jobs
- final ScheduledJobInfo info1 = this.getJobManager().createJob(TOPIC).schedule().hourly(5).add();
+ final ScheduledJobInfo info1 = jobManager.createJob(TOPIC).schedule().hourly(5).add();
assertNotNull(info1);
- final ScheduledJobInfo info2 = this.getJobManager().createJob(TOPIC).schedule().daily(10, 5).add();
+ final ScheduledJobInfo info2 = jobManager.createJob(TOPIC).schedule().daily(10, 5).add();
assertNotNull(info2);
- final ScheduledJobInfo info3 = this.getJobManager().createJob(TOPIC).schedule().weekly(3, 19, 12).add();
+ final ScheduledJobInfo info3 = jobManager.createJob(TOPIC).schedule().weekly(3, 19, 12).add();
assertNotNull(info3);
- assertEquals(3, this.getJobManager().getScheduledJobs().size()); // scheduled jobs
+ assertEquals(3, jobManager.getScheduledJobs().size()); // scheduled jobs
info3.unschedule();
- assertEquals(2, this.getJobManager().getScheduledJobs().size()); // scheduled jobs
+ assertEquals(2, jobManager.getScheduledJobs().size()); // scheduled jobs
info1.unschedule();
- assertEquals(1, this.getJobManager().getScheduledJobs().size()); // scheduled jobs
+ assertEquals(1, jobManager.getScheduledJobs().size()); // scheduled jobs
info2.unschedule();
- assertEquals(0, this.getJobManager().getScheduledJobs().size()); // scheduled jobs
+ assertEquals(0, jobManager.getScheduledJobs().size()); // scheduled jobs
}
@Test
@@ -110,20 +106,20 @@
});
for(int i=0; i<NUM_ITERATIONS; i++) {
logger.info("schedulingLoadTest: loop-" + i);
- this.getJobManager().createJob(ownTopic).schedule().at(new Date(System.currentTimeMillis() + 2500)).add();
+ jobManager.createJob(ownTopic).schedule().at(new Date(System.currentTimeMillis() + 2500)).add();
Thread.sleep(1);
}
- logger.info("schedulingLoadTest: done, letting jobs be triggered, currently at {} jobs, {} schedules", counter.get(), this.getJobManager().getScheduledJobs().size());
+ logger.info("schedulingLoadTest: done, letting jobs be triggered, currently at {} jobs, {} schedules", counter.get(), jobManager.getScheduledJobs().size());
final long timeout = System.currentTimeMillis() + 60000;
while(System.currentTimeMillis() < timeout) {
- if ((counter.get() == NUM_ITERATIONS) && (this.getJobManager().getScheduledJobs().size() == 0)) {
+ if ((counter.get() == NUM_ITERATIONS) && (jobManager.getScheduledJobs().size() == 0)) {
break;
}
- logger.info("schedulingLoadTest: currently at {} jobs, {} schedules", counter.get(), getJobManager().getScheduledJobs().size());
+ logger.info("schedulingLoadTest: currently at {} jobs, {} schedules", counter.get(), jobManager.getScheduledJobs().size());
Thread.sleep(100);
}
assertEquals(NUM_ITERATIONS, counter.get());
- assertEquals(0, this.getJobManager().getScheduledJobs().size());
+ assertEquals(0, jobManager.getScheduledJobs().size());
logger.info("schedulingLoadTest: end");
}
}
diff --git a/src/test/java/org/apache/sling/event/it/TimedJobsTest.java b/src/test/java/org/apache/sling/event/it/TimedJobsTest.java
index 0b2d556..2d937d5 100644
--- a/src/test/java/org/apache/sling/event/it/TimedJobsTest.java
+++ b/src/test/java/org/apache/sling/event/it/TimedJobsTest.java
@@ -18,39 +18,35 @@
*/
package org.apache.sling.event.it;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-import java.io.IOException;
import java.util.Date;
import java.util.concurrent.atomic.AtomicInteger;
import org.apache.sling.event.jobs.Job;
import org.apache.sling.event.jobs.ScheduledJobInfo;
import org.apache.sling.event.jobs.consumer.JobConsumer;
-import org.junit.After;
-import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Configuration;
+import org.ops4j.pax.exam.Option;
import org.ops4j.pax.exam.junit.PaxExam;
+import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
+import org.ops4j.pax.exam.spi.reactors.PerMethod;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.ops4j.pax.exam.CoreOptions.options;
@RunWith(PaxExam.class)
+@ExamReactorStrategy(PerMethod.class)
public class TimedJobsTest extends AbstractJobHandlingTest {
private static final String TOPIC = "timed/test/topic";
- @Override
- @Before
- public void setup() throws IOException {
- super.setup();
-
- this.sleep(1000L);
- }
-
- @Override
- @After
- public void cleanup() {
- super.cleanup();
+ @Configuration
+ public Option[] configuration() {
+ return options(
+ baseConfiguration()
+ );
}
@Test(timeout = DEFAULT_TEST_TIMEOUT)
@@ -73,13 +69,13 @@
d.setTime(System.currentTimeMillis() + 3000); // run in 3 seconds
// create scheduled job
- final ScheduledJobInfo info = this.getJobManager().createJob(TOPIC).schedule().at(d).add();
+ final ScheduledJobInfo info = jobManager.createJob(TOPIC).schedule().at(d).add();
assertNotNull(info);
while ( counter.get() == 0 ) {
this.sleep(1000);
}
- assertEquals(0, this.getJobManager().getScheduledJobs().size()); // job is not scheduled anymore
+ assertEquals(0, jobManager.getScheduledJobs().size()); // job is not scheduled anymore
info.unschedule();
}
diff --git a/src/test/java/org/apache/sling/event/it/TopicMatchingTest.java b/src/test/java/org/apache/sling/event/it/TopicMatchingTest.java
index 40f7439..0a6ac5b 100644
--- a/src/test/java/org/apache/sling/event/it/TopicMatchingTest.java
+++ b/src/test/java/org/apache/sling/event/it/TopicMatchingTest.java
@@ -18,40 +18,36 @@
*/
package org.apache.sling.event.it;
-import java.io.IOException;
-
import org.apache.sling.event.impl.Barrier;
import org.apache.sling.event.jobs.Job;
import org.apache.sling.event.jobs.NotificationConstants;
import org.apache.sling.event.jobs.consumer.JobExecutionContext;
import org.apache.sling.event.jobs.consumer.JobExecutionResult;
import org.apache.sling.event.jobs.consumer.JobExecutor;
-import org.junit.After;
-import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Configuration;
+import org.ops4j.pax.exam.Option;
import org.ops4j.pax.exam.junit.PaxExam;
+import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
+import org.ops4j.pax.exam.spi.reactors.PerMethod;
import org.osgi.framework.ServiceRegistration;
import org.osgi.service.event.Event;
import org.osgi.service.event.EventHandler;
+import static org.ops4j.pax.exam.CoreOptions.options;
+
@RunWith(PaxExam.class)
+@ExamReactorStrategy(PerMethod.class)
public class TopicMatchingTest extends AbstractJobHandlingTest {
public static final String TOPIC = "sling/test/a";
- @Override
- @Before
- public void setup() throws IOException {
- super.setup();
-
- this.sleep(1000L);
- }
-
- @Override
- @After
- public void cleanup() {
- super.cleanup();
+ @Configuration
+ public Option[] configuration() {
+ return options(
+ baseConfiguration()
+ );
}
/**
@@ -78,7 +74,7 @@
}
});
- this.getJobManager().addJob(TOPIC, null);
+ jobManager.addJob(TOPIC, null);
barrier.block();
}
@@ -106,7 +102,7 @@
}
});
- this.getJobManager().addJob(TOPIC, null);
+ jobManager.addJob(TOPIC, null);
barrier.block();
}
@@ -148,21 +144,21 @@
});
// first test, all three registered, reg3 should get the precedence
- this.getJobManager().addJob(TOPIC, null);
+ jobManager.addJob(TOPIC, null);
barrier3.block();
// second test, unregister reg3, now it should be reg2
long cc = this.getConsumerChangeCount();
this.unregister(reg3);
this.waitConsumerChangeCount(cc + 1);
- this.getJobManager().addJob(TOPIC, null);
+ jobManager.addJob(TOPIC, null);
barrier2.block();
// third test, unregister reg2, reg1 is now the only one
cc = this.getConsumerChangeCount();
this.unregister(reg2);
this.waitConsumerChangeCount(cc + 1);
- this.getJobManager().addJob(TOPIC, null);
+ jobManager.addJob(TOPIC, null);
barrier1.block();
}
}
diff --git a/src/test/java/org/apache/sling/event/it/UnorderedQueueTest.java b/src/test/java/org/apache/sling/event/it/UnorderedQueueTest.java
index bd0eea3..7a8104a 100644
--- a/src/test/java/org/apache/sling/event/it/UnorderedQueueTest.java
+++ b/src/test/java/org/apache/sling/event/it/UnorderedQueueTest.java
@@ -18,15 +18,8 @@
*/
package org.apache.sling.event.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.Dictionary;
import java.util.HashMap;
import java.util.HashSet;
-import java.util.Hashtable;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger;
@@ -34,20 +27,28 @@
import org.apache.sling.event.impl.Barrier;
import org.apache.sling.event.impl.jobs.config.ConfigurationConstants;
import org.apache.sling.event.jobs.Job;
-import org.apache.sling.event.jobs.JobManager;
import org.apache.sling.event.jobs.NotificationConstants;
import org.apache.sling.event.jobs.Queue;
import org.apache.sling.event.jobs.QueueConfiguration;
import org.apache.sling.event.jobs.consumer.JobConsumer;
-import org.junit.After;
-import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Configuration;
+import org.ops4j.pax.exam.Option;
import org.ops4j.pax.exam.junit.PaxExam;
+import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
+import org.ops4j.pax.exam.spi.reactors.PerMethod;
import org.osgi.service.event.Event;
import org.osgi.service.event.EventHandler;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.ops4j.pax.exam.CoreOptions.options;
+import static org.ops4j.pax.exam.cm.ConfigurationAdminOptions.factoryConfiguration;
+
@RunWith(PaxExam.class)
+@ExamReactorStrategy(PerMethod.class)
public class UnorderedQueueTest extends AbstractJobHandlingTest {
private static final String QUEUE_NAME = "unorderedtestqueue";
@@ -55,34 +56,24 @@
private static int MAX_PAR = 5;
private static int NUM_JOBS = 300;
- @Override
- @Before
- public void setup() throws IOException {
- super.setup();
-
- // create round robin test queue
- final org.osgi.service.cm.Configuration rrConfig = this.configAdmin.createFactoryConfiguration("org.apache.sling.event.jobs.QueueConfiguration", null);
- final Dictionary<String, Object> rrProps = new Hashtable<String, Object>();
- rrProps.put(ConfigurationConstants.PROP_NAME, QUEUE_NAME);
- rrProps.put(ConfigurationConstants.PROP_TYPE, QueueConfiguration.Type.UNORDERED.name());
- rrProps.put(ConfigurationConstants.PROP_TOPICS, TOPIC + "/*");
- rrProps.put(ConfigurationConstants.PROP_RETRIES, 2);
- rrProps.put(ConfigurationConstants.PROP_RETRY_DELAY, 2000L);
- rrProps.put(ConfigurationConstants.PROP_MAX_PARALLEL, MAX_PAR);
- rrConfig.update(rrProps);
-
- this.sleep(1000L);
- }
-
- @Override
- @After
- public void cleanup() {
- super.cleanup();
+ @Configuration
+ public Option[] configuration() {
+ return options(
+ baseConfiguration(),
+ // create round robin test queue
+ factoryConfiguration("org.apache.sling.event.jobs.QueueConfiguration")
+ .put(ConfigurationConstants.PROP_NAME, QUEUE_NAME)
+ .put(ConfigurationConstants.PROP_TYPE, QueueConfiguration.Type.UNORDERED.name())
+ .put(ConfigurationConstants.PROP_TOPICS, TOPIC + "/*")
+ .put(ConfigurationConstants.PROP_RETRIES, 2)
+ .put(ConfigurationConstants.PROP_RETRY_DELAY, 2000L)
+ .put(ConfigurationConstants.PROP_MAX_PARALLEL, MAX_PAR)
+ .asOption()
+ );
}
@Test(timeout = DEFAULT_TEST_TIMEOUT)
public void testUnorderedQueue() throws Exception {
- final JobManager jobManager = this.getJobManager();
final Barrier cb = new Barrier(2);