You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by cz...@apache.org on 2013/05/22 17:04:58 UTC
svn commit: r1485238 -
/sling/trunk/bundles/extensions/event/src/test/java/org/apache/sling/event/it/
Author: cziegeler
Date: Wed May 22 15:04:58 2013
New Revision: 1485238
URL: http://svn.apache.org/r1485238
Log:
Remove configurations and dangling jobs after each test
Modified:
sling/trunk/bundles/extensions/event/src/test/java/org/apache/sling/event/it/AbstractJobHandlingTest.java
sling/trunk/bundles/extensions/event/src/test/java/org/apache/sling/event/it/ClassloadingTest.java
sling/trunk/bundles/extensions/event/src/test/java/org/apache/sling/event/it/DropQueueTest.java
sling/trunk/bundles/extensions/event/src/test/java/org/apache/sling/event/it/IgnoreQueueTest.java
sling/trunk/bundles/extensions/event/src/test/java/org/apache/sling/event/it/JobHandlingTest.java
sling/trunk/bundles/extensions/event/src/test/java/org/apache/sling/event/it/OrderedQueueTest.java
sling/trunk/bundles/extensions/event/src/test/java/org/apache/sling/event/it/RoundRobinQueueTest.java
Modified: sling/trunk/bundles/extensions/event/src/test/java/org/apache/sling/event/it/AbstractJobHandlingTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/event/src/test/java/org/apache/sling/event/it/AbstractJobHandlingTest.java?rev=1485238&r1=1485237&r2=1485238&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/event/src/test/java/org/apache/sling/event/it/AbstractJobHandlingTest.java (original)
+++ sling/trunk/bundles/extensions/event/src/test/java/org/apache/sling/event/it/AbstractJobHandlingTest.java Wed May 22 15:04:58 2013
@@ -204,4 +204,14 @@ public abstract class AbstractJobHandlin
handler, props);
return reg;
}
+
+ /**
+ * Helper method to remove a configuration
+ */
+ protected void removeConfiguration(final String pid) throws IOException {
+ if ( pid != null ) {
+ final org.osgi.service.cm.Configuration cfg = this.configAdmin.getConfiguration(pid, null);
+ cfg.delete();
+ }
+ }
}
\ No newline at end of file
Modified: sling/trunk/bundles/extensions/event/src/test/java/org/apache/sling/event/it/ClassloadingTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/event/src/test/java/org/apache/sling/event/it/ClassloadingTest.java?rev=1485238&r1=1485237&r2=1485238&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/event/src/test/java/org/apache/sling/event/it/ClassloadingTest.java (original)
+++ sling/trunk/bundles/extensions/event/src/test/java/org/apache/sling/event/it/ClassloadingTest.java Wed May 22 15:04:58 2013
@@ -39,6 +39,7 @@ import org.apache.sling.event.jobs.JobMa
import org.apache.sling.event.jobs.JobUtil;
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.runner.RunWith;
import org.ops4j.pax.exam.junit.ExamReactorStrategy;
@@ -55,6 +56,8 @@ public class ClassloadingTest extends Ab
private static final String QUEUE_NAME = "cltest";
private static final String TOPIC = "sling/cltest";
+ private String queueConfigPid;
+
@Override
@Before
public void setup() throws IOException {
@@ -68,9 +71,16 @@ public class ClassloadingTest extends Ab
orderedProps.put(ConfigurationConstants.PROP_TOPICS, TOPIC);
orderedConfig.update(orderedProps);
+ queueConfigPid = orderedConfig.getPid();
+
this.sleep(1000L);
}
+ @After
+ public void cleanUp() throws IOException {
+ this.removeConfiguration(this.queueConfigPid);
+
+ }
@org.junit.Test public void testSimpleClassloading() throws Exception {
final AtomicInteger count = new AtomicInteger(0);
Modified: sling/trunk/bundles/extensions/event/src/test/java/org/apache/sling/event/it/DropQueueTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/event/src/test/java/org/apache/sling/event/it/DropQueueTest.java?rev=1485238&r1=1485237&r2=1485238&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/event/src/test/java/org/apache/sling/event/it/DropQueueTest.java (original)
+++ sling/trunk/bundles/extensions/event/src/test/java/org/apache/sling/event/it/DropQueueTest.java Wed May 22 15:04:58 2013
@@ -32,6 +32,7 @@ import org.apache.sling.event.jobs.JobMa
import org.apache.sling.event.jobs.JobUtil;
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.runner.RunWith;
import org.ops4j.pax.exam.junit.ExamReactorStrategy;
@@ -69,6 +70,11 @@ public class DropQueueTest extends Abstr
this.sleep(1000L);
}
+ @After
+ public void cleanUp() throws IOException {
+ this.removeConfiguration(this.queueConfPid);
+
+ }
@org.junit.Test public void testDroppingQueue() throws Exception {
final AtomicInteger count = new AtomicInteger(0);
Modified: sling/trunk/bundles/extensions/event/src/test/java/org/apache/sling/event/it/IgnoreQueueTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/event/src/test/java/org/apache/sling/event/it/IgnoreQueueTest.java?rev=1485238&r1=1485237&r2=1485238&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/event/src/test/java/org/apache/sling/event/it/IgnoreQueueTest.java (original)
+++ sling/trunk/bundles/extensions/event/src/test/java/org/apache/sling/event/it/IgnoreQueueTest.java Wed May 22 15:04:58 2013
@@ -31,6 +31,7 @@ import org.apache.sling.event.jobs.Job;
import org.apache.sling.event.jobs.JobManager;
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.runner.RunWith;
import org.ops4j.pax.exam.junit.ExamReactorStrategy;
@@ -66,6 +67,12 @@ public class IgnoreQueueTest extends Abs
this.sleep(1000L);
}
+ @After
+ public void cleanUp() throws IOException {
+ this.removeConfiguration(this.queueConfPid);
+
+ }
+
@org.junit.Test public void testIgnoreQueue() throws Exception {
final AtomicInteger count = new AtomicInteger(0);
final ServiceRegistration jcReg = this.registerJobConsumer(TOPIC,
Modified: sling/trunk/bundles/extensions/event/src/test/java/org/apache/sling/event/it/JobHandlingTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/event/src/test/java/org/apache/sling/event/it/JobHandlingTest.java?rev=1485238&r1=1485237&r2=1485238&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/event/src/test/java/org/apache/sling/event/it/JobHandlingTest.java (original)
+++ sling/trunk/bundles/extensions/event/src/test/java/org/apache/sling/event/it/JobHandlingTest.java Wed May 22 15:04:58 2013
@@ -41,6 +41,7 @@ import org.apache.sling.event.jobs.JobPr
import org.apache.sling.event.jobs.JobUtil;
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;
@@ -57,6 +58,8 @@ public class JobHandlingTest extends Abs
public static final String TOPIC = "sling/test";
+ private String queueConfPid;
+
@Override
@Before
public void setup() throws IOException {
@@ -72,9 +75,16 @@ public class JobHandlingTest extends Abs
props.put(ConfigurationConstants.PROP_RETRY_DELAY, 2000L);
config.update(props);
+ this.queueConfPid = config.getPid();
this.sleep(1000L);
}
+ @After
+ public void cleanUp() throws IOException {
+ this.removeConfiguration(this.queueConfPid);
+
+ }
+
/**
* Helper method to create a job event.
*/
@@ -518,6 +528,11 @@ public class JobHandlingTest extends Abs
assertEquals("Finished count", COUNT / 2, count.get());
assertEquals("Unprocessed count",COUNT, unprocessedCount.get());
assertEquals("Finished count", COUNT / 2, jobManager.getStatistics().getNumberOfFinishedJobs());
+
+ // now remove jobs
+ for(final Job j : jobManager.findJobs(JobManager.QueryType.ALL, TOPIC + "2", -1, (Map<String, Object>[])null)) {
+ jobManager.removeJobById(j.getId());
+ }
} finally {
eh1.unregister();
eh2.unregister();
Modified: sling/trunk/bundles/extensions/event/src/test/java/org/apache/sling/event/it/OrderedQueueTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/event/src/test/java/org/apache/sling/event/it/OrderedQueueTest.java?rev=1485238&r1=1485237&r2=1485238&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/event/src/test/java/org/apache/sling/event/it/OrderedQueueTest.java (original)
+++ sling/trunk/bundles/extensions/event/src/test/java/org/apache/sling/event/it/OrderedQueueTest.java Wed May 22 15:04:58 2013
@@ -36,6 +36,7 @@ import org.apache.sling.event.jobs.JobUt
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;
@@ -50,6 +51,8 @@ import org.osgi.service.event.EventHandl
@ExamReactorStrategy(AllConfinedStagedReactorFactory.class)
public class OrderedQueueTest extends AbstractJobHandlingTest {
+ private String queueConfPid;
+
@Override
@Before
public void setup() throws IOException {
@@ -65,9 +68,17 @@ public class OrderedQueueTest extends Ab
orderedProps.put(ConfigurationConstants.PROP_RETRY_DELAY, 2000L);
orderedConfig.update(orderedProps);
+ this.queueConfPid = orderedConfig.getPid();
+
this.sleep(1000L);
}
+ @After
+ public void cleanUp() throws IOException {
+ this.removeConfiguration(this.queueConfPid);
+
+ }
+
/**
* Ordered Queue Test
*/
Modified: sling/trunk/bundles/extensions/event/src/test/java/org/apache/sling/event/it/RoundRobinQueueTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/event/src/test/java/org/apache/sling/event/it/RoundRobinQueueTest.java?rev=1485238&r1=1485237&r2=1485238&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/event/src/test/java/org/apache/sling/event/it/RoundRobinQueueTest.java (original)
+++ sling/trunk/bundles/extensions/event/src/test/java/org/apache/sling/event/it/RoundRobinQueueTest.java Wed May 22 15:04:58 2013
@@ -35,6 +35,7 @@ import org.apache.sling.event.jobs.JobUt
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.runner.RunWith;
import org.ops4j.pax.exam.junit.ExamReactorStrategy;
@@ -53,6 +54,8 @@ public class RoundRobinQueueTest extends
private static int MAX_PAR = 5;
private static int NUM_JOBS = 300;
+ private String queueConfPid;
+
@Override
@Before
public void setup() throws IOException {
@@ -69,9 +72,17 @@ public class RoundRobinQueueTest extends
orderedProps.put(ConfigurationConstants.PROP_MAX_PARALLEL, MAX_PAR);
orderedConfig.update(orderedProps);
+ queueConfPid = orderedConfig.getPid();
+
this.sleep(1000L);
}
+ @After
+ public void cleanUp() throws IOException {
+ this.removeConfiguration(this.queueConfPid);
+
+ }
+
@org.junit.Test public void testRoundRobinQueue() throws Exception {
final JobManager jobManager = this.getJobManager();