pax exam 3.0.0 migration
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1530321 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/dependencymanager/test/src/test/java/org/apache/felix/dm/test/annotation/TemporalAnnotationTest.java b/dependencymanager/test/src/test/java/org/apache/felix/dm/test/annotation/TemporalAnnotationTest.java
deleted file mode 100644
index b2e3fb1..0000000
--- a/dependencymanager/test/src/test/java/org/apache/felix/dm/test/annotation/TemporalAnnotationTest.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*/
-package org.apache.felix.dm.test.annotation;
-
-import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
-import static org.ops4j.pax.exam.CoreOptions.options;
-import static org.ops4j.pax.exam.CoreOptions.provision;
-import static org.ops4j.pax.exam.CoreOptions.systemProperty;
-
-import java.util.Dictionary;
-import java.util.Hashtable;
-
-import org.apache.felix.dm.Component;
-import org.apache.felix.dm.DependencyManager;
-import org.apache.felix.dm.test.Base;
-import org.apache.felix.dm.test.BundleGenerator;
-import org.apache.felix.dm.test.Ensure;
-import org.apache.felix.dm.test.bundle.annotation.sequencer.Sequencer;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.ops4j.pax.exam.Option;
-import org.ops4j.pax.exam.junit.Configuration;
-import org.ops4j.pax.exam.junit.JUnit4TestRunner;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.Constants;
-
-/**
- * Use case: Verify Temporal Service Dependendency Annotations usage.
- */
-@RunWith(JUnit4TestRunner.class)
-public class TemporalAnnotationTest extends AnnotationBase
-{
- @Configuration
- public static Option[] configuration()
- {
- return options(
- systemProperty(DMLOG_PROPERTY).value( "true" ),
- provision(
- mavenBundle().groupId("org.osgi").artifactId("org.osgi.compendium").version(Base.OSGI_SPEC_VERSION),
- mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.dependencymanager").versionAsInProject(),
- mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.dependencymanager.runtime").versionAsInProject()),
- provision(
- new BundleGenerator()
- .set(Constants.BUNDLE_SYMBOLICNAME, "TemporalTest")
- .set("Export-Package", "org.apache.felix.dm.test.bundle.annotation.sequencer")
- .set("Private-Package", "org.apache.felix.dm.test.bundle.annotation.temporal")
- .set("Import-Package", "*")
- .set("-plugin", "org.apache.felix.dm.annotation.plugin.bnd.AnnotationPlugin")
- .build()));
- }
-
- @Test
- public void testTemporalServiceDependency(BundleContext context)
- {
- DependencyManager m = new DependencyManager(context);
- // Provide the Sequencer service to the TemporalServiceDependencyTest service.
- m.add(m.createComponent().setImplementation(this).setInterface(Sequencer.class.getName(), null));
-
- Runnable r = Ensure.createRunnableStep(m_ensure, 1);
- Dictionary props = new Hashtable() {{ put("test", "temporal"); }};
- Component s = m.createComponent().setImplementation(r).setInterface(Runnable.class.getName(), props);
- m.add(s);
- m_ensure.waitForStep(1, 15000);
- m.remove(s);
- m_ensure.step(2);
- sleep(500);
- r = Ensure.createRunnableStep(m_ensure, 3);
- s = m.createComponent().setImplementation(r).setInterface(Runnable.class.getName(), props);
- m.add(s);
- m_ensure.waitForStep(3, 15000);
- m.remove(s);
- m_ensure.step(4);
- sleep(1500);
- m_ensure.waitForStep(5, 15000);
- }
-}
diff --git a/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/temporal/TemporalTest.java b/dependencymanager/test2/src/main/java/org/apache/felix/dependencymanager/test2/components/TemporalAnnotations.java
similarity index 70%
rename from dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/temporal/TemporalTest.java
rename to dependencymanager/test2/src/main/java/org/apache/felix/dependencymanager/test2/components/TemporalAnnotations.java
index 2b02b0c..208af62 100644
--- a/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/temporal/TemporalTest.java
+++ b/dependencymanager/test2/src/main/java/org/apache/felix/dependencymanager/test2/components/TemporalAnnotations.java
@@ -16,60 +16,49 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.felix.dm.test.bundle.annotation.temporal;
+package org.apache.felix.dependencymanager.test2.components;
import org.apache.felix.dm.annotation.api.Component;
import org.apache.felix.dm.annotation.api.ServiceDependency;
import org.apache.felix.dm.annotation.api.Start;
import org.apache.felix.dm.annotation.api.Stop;
-import org.apache.felix.dm.test.bundle.annotation.sequencer.Sequencer;
/**
- * Service using an annotated Temporal Service dependendency.
+ * Service using an annotated Temporal Service dependency.
*/
@Component(provides = {})
-public class TemporalTest implements Runnable
-{
+public class TemporalAnnotations implements Runnable {
Thread m_thread;
- @ServiceDependency
- Sequencer m_sequencer;
+ @ServiceDependency(filter = "(name=temporal.annotations)")
+ volatile Ensure m_sequencer;
@ServiceDependency(timeout = 1000L, filter = "(test=temporal)")
- Runnable m_service;
-
+ volatile Runnable m_service;
+
@Start
- protected void start()
- {
+ protected void start() {
m_thread = new Thread(this);
m_thread.start();
}
@Stop
- protected void stop()
- {
+ protected void stop() {
m_thread.interrupt();
- try
- {
+ try {
m_thread.join();
- }
- catch (InterruptedException e)
- {
+ } catch (InterruptedException e) {
}
}
- public void run()
- {
+ public void run() {
m_service.run();
m_sequencer.waitForStep(2, 15000);
- m_service.run(); // we should block here
+ m_service.run(); // we should block here
m_sequencer.waitForStep(4, 15000);
- try
- {
+ try {
m_service.run(); // should raise IllegalStateException
- }
- catch (IllegalStateException e)
- {
+ } catch (IllegalStateException e) {
m_sequencer.step(5);
}
}
diff --git a/dependencymanager/test2/src/test/java/org/apache/felix/dependencymanager/test2/integration/annotations/TemporalAnnotationsTest.java b/dependencymanager/test2/src/test/java/org/apache/felix/dependencymanager/test2/integration/annotations/TemporalAnnotationsTest.java
new file mode 100644
index 0000000..c7dca4f
--- /dev/null
+++ b/dependencymanager/test2/src/test/java/org/apache/felix/dependencymanager/test2/integration/annotations/TemporalAnnotationsTest.java
@@ -0,0 +1,59 @@
+/*
+* 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.felix.dependencymanager.test2.integration.annotations;
+
+import java.util.Dictionary;
+import java.util.Hashtable;
+
+import org.apache.felix.dependencymanager.test2.components.Ensure;
+import org.apache.felix.dependencymanager.test2.integration.common.TestBase;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.junit.PaxExam;
+import org.osgi.framework.ServiceRegistration;
+
+/**
+ * Use case: Verify Temporal Service dependency Annotations usage.
+ */
+@RunWith(PaxExam.class)
+public class TemporalAnnotationsTest extends TestBase
+{
+ @Test
+ public void testTemporalServiceDependency()
+ {
+ Ensure ensure = new Ensure();
+ ServiceRegistration<?> ensureReg = register(ensure, "temporal.annotations");
+ Dictionary props = new Hashtable() {{ put("test", "temporal"); }};
+ Runnable r = Ensure.createRunnableStep(ensure, 1);
+ ServiceRegistration sr = context.registerService(Runnable.class.getName(), r, props);
+ ensure.waitForStep(1, 15000);
+ System.out.println("unregistering R");
+ sr.unregister();
+ ensure.step(2);
+ sleep(500);
+ r = Ensure.createRunnableStep(ensure, 3);
+ sr = context.registerService(Runnable.class.getName(), r, props);
+ ensure.waitForStep(3, 15000);
+ sr.unregister();
+ ensure.step(4);
+ sleep(1500);
+ ensure.waitForStep(5, 15000);
+ ensureReg.unregister();
+ }
+}