felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pde...@apache.org
Subject svn commit: r1530321 - in /felix/trunk/dependencymanager: test/src/main/java/org/apache/felix/dm/test/bundle/annotation/temporal/ test/src/test/java/org/apache/felix/dm/test/annotation/ test2/src/main/java/org/apache/felix/dependencymanager/test2/compo...
Date Tue, 08 Oct 2013 15:57:30 GMT
Author: pderop
Date: Tue Oct  8 15:57:30 2013
New Revision: 1530321

URL: http://svn.apache.org/r1530321
Log:
pax exam 3.0.0 migration

Added:
    felix/trunk/dependencymanager/test2/src/main/java/org/apache/felix/dependencymanager/test2/components/TemporalAnnotations.java
      - copied, changed from r1528830, felix/trunk/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/temporal/TemporalTest.java
    felix/trunk/dependencymanager/test2/src/test/java/org/apache/felix/dependencymanager/test2/integration/annotations/TemporalAnnotationsTest.java
      - copied, changed from r1528830, felix/trunk/dependencymanager/test/src/test/java/org/apache/felix/dm/test/annotation/TemporalAnnotationTest.java
Removed:
    felix/trunk/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/temporal/TemporalTest.java
    felix/trunk/dependencymanager/test/src/test/java/org/apache/felix/dm/test/annotation/TemporalAnnotationTest.java

Copied: felix/trunk/dependencymanager/test2/src/main/java/org/apache/felix/dependencymanager/test2/components/TemporalAnnotations.java
(from r1528830, felix/trunk/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/temporal/TemporalTest.java)
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/test2/src/main/java/org/apache/felix/dependencymanager/test2/components/TemporalAnnotations.java?p2=felix/trunk/dependencymanager/test2/src/main/java/org/apache/felix/dependencymanager/test2/components/TemporalAnnotations.java&p1=felix/trunk/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/temporal/TemporalTest.java&r1=1528830&r2=1530321&rev=1530321&view=diff
==============================================================================
--- felix/trunk/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/temporal/TemporalTest.java
(original)
+++ felix/trunk/dependencymanager/test2/src/main/java/org/apache/felix/dependencymanager/test2/components/TemporalAnnotations.java
Tue Oct  8 15:57:30 2013
@@ -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);
         }
     }

Copied: felix/trunk/dependencymanager/test2/src/test/java/org/apache/felix/dependencymanager/test2/integration/annotations/TemporalAnnotationsTest.java
(from r1528830, felix/trunk/dependencymanager/test/src/test/java/org/apache/felix/dm/test/annotation/TemporalAnnotationTest.java)
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/test2/src/test/java/org/apache/felix/dependencymanager/test2/integration/annotations/TemporalAnnotationsTest.java?p2=felix/trunk/dependencymanager/test2/src/test/java/org/apache/felix/dependencymanager/test2/integration/annotations/TemporalAnnotationsTest.java&p1=felix/trunk/dependencymanager/test/src/test/java/org/apache/felix/dm/test/annotation/TemporalAnnotationTest.java&r1=1528830&r2=1530321&rev=1530321&view=diff
==============================================================================
--- felix/trunk/dependencymanager/test/src/test/java/org/apache/felix/dm/test/annotation/TemporalAnnotationTest.java
(original)
+++ felix/trunk/dependencymanager/test2/src/test/java/org/apache/felix/dependencymanager/test2/integration/annotations/TemporalAnnotationsTest.java
Tue Oct  8 15:57:30 2013
@@ -16,77 +16,44 @@
 * 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;
+package org.apache.felix.dependencymanager.test2.integration.annotations;
 
 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.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.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;
+import org.ops4j.pax.exam.junit.PaxExam;
+import org.osgi.framework.ServiceRegistration;
 
 /**
- * Use case: Verify Temporal Service Dependendency Annotations usage.
+ * Use case: Verify Temporal Service dependency Annotations usage.
  */
-@RunWith(JUnit4TestRunner.class)
-public class TemporalAnnotationTest extends AnnotationBase
+@RunWith(PaxExam.class)
+public class TemporalAnnotationsTest extends TestBase
 {
-    @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)
+    public void testTemporalServiceDependency()
     {
-        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);
+        Ensure ensure = new Ensure();
+        ServiceRegistration<?> ensureReg = register(ensure, "temporal.annotations");
                      
         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);
+        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(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);
+        r = Ensure.createRunnableStep(ensure, 3);
+        sr = context.registerService(Runnable.class.getName(), r, props);
+        ensure.waitForStep(3, 15000);
+        sr.unregister();
+        ensure.step(4);
         sleep(1500);
-        m_ensure.waitForStep(5, 15000);
+        ensure.waitForStep(5, 15000);
+        ensureReg.unregister();
     }
 }



Mime
View raw message