felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pde...@apache.org
Subject svn commit: r1531687 - in /felix/trunk/dependencymanager: test/src/main/java/org/apache/felix/dm/test/bundle/annotation/adapter/ test/src/test/java/org/apache/felix/dm/test/annotation/ test2/src/main/java/org/apache/felix/dependencymanager/test2/compon...
Date Sun, 13 Oct 2013 13:39:56 GMT
Author: pderop
Date: Sun Oct 13 13:39:56 2013
New Revision: 1531687

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

Added:
    felix/trunk/dependencymanager/test2/src/main/java/org/apache/felix/dependencymanager/test2/components/AdapterAnnotation.java
      - copied, changed from r1531247, felix/trunk/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/adapter/AdapterTest.java
    felix/trunk/dependencymanager/test2/src/test/java/org/apache/felix/dependencymanager/test2/integration/annotations/AdapterAnnotationTest.java
      - copied, changed from r1531247, felix/trunk/dependencymanager/test/src/test/java/org/apache/felix/dm/test/annotation/AdapterAnnotationTest.java
Removed:
    felix/trunk/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/adapter/AdapterTest.java
    felix/trunk/dependencymanager/test/src/test/java/org/apache/felix/dm/test/annotation/AdapterAnnotationTest.java
Modified:
    felix/trunk/dependencymanager/test2/src/main/java/org/apache/felix/dependencymanager/test2/components/SimpleAnnotations.java

Copied: felix/trunk/dependencymanager/test2/src/main/java/org/apache/felix/dependencymanager/test2/components/AdapterAnnotation.java
(from r1531247, felix/trunk/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/adapter/AdapterTest.java)
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/test2/src/main/java/org/apache/felix/dependencymanager/test2/components/AdapterAnnotation.java?p2=felix/trunk/dependencymanager/test2/src/main/java/org/apache/felix/dependencymanager/test2/components/AdapterAnnotation.java&p1=felix/trunk/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/adapter/AdapterTest.java&r1=1531247&r2=1531687&rev=1531687&view=diff
==============================================================================
--- felix/trunk/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/adapter/AdapterTest.java
(original)
+++ felix/trunk/dependencymanager/test2/src/main/java/org/apache/felix/dependencymanager/test2/components/AdapterAnnotation.java
Sun Oct 13 13:39:56 2013
@@ -16,9 +16,8 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.felix.dm.test.bundle.annotation.adapter;
+package org.apache.felix.dependencymanager.test2.components;
 
-import java.util.Hashtable;
 import java.util.Map;
 
 import org.apache.felix.dm.DependencyManager;
@@ -29,196 +28,160 @@ import org.apache.felix.dm.annotation.ap
 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;
 import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceRegistration;
 
-public class AdapterTest
-{
-    public interface S1
-    {
+public class AdapterAnnotation {
+    public interface S1 {
         public void run();
     }
 
-    public interface S2
-    {
+    public interface S2 {
         public void run2();
     }
 
-    public interface S3
-    {
+    public interface S3 {
         public void run3();
     }
 
     @Component
-    public static class S3Consumer
-    {
-        @ServiceDependency
-        Sequencer m_sequencer;
-        private Map<String, String> m_serviceProperties;
+    public static class S3Consumer {
+        private volatile Map<String, String> m_serviceProperties;
         private volatile S3 m_s3;
-        
+
         @ServiceDependency
-        void bind(Map<String, String> serviceProperties, S3 s3)
-        {
+        void bind(Map<String, String> serviceProperties, S3 s3) {
             m_serviceProperties = serviceProperties;
             m_s3 = s3;
         }
-        
+
         @Start
         void start() {
             // The adapter service must inherit from adaptee service properties ...
             if ("value1".equals(m_serviceProperties.get("param1")) // adaptee properties
-                && "true".equals(m_serviceProperties.get("adapter"))) // adapter
properties
+                    && "true".equals(m_serviceProperties.get("adapter"))) // adapter
properties
             {
                 m_s3.run3();
-            }        
+            }
         }
     }
 
-    @AdapterService(adapteeService = S1.class, 
-                    properties={@Property(name="adapter", value="true")})
-    public static class S1ToS3AdapterAutoConfig implements S3
-    {
+    @AdapterService(adapteeService = S1.class, properties = {@Property(name = "adapter",
value = "true")})
+    public static class S1ToS3AdapterAutoConfig implements S3 {
         // This is the adapted service
-        protected S1 m_s1;
-        
-        @ServiceDependency(filter="(name=AdapterAutoConfig)")
-        protected Sequencer m_sequencer;
+        protected volatile S1 m_s1;
+
+        @ServiceDependency(filter = "(name=adapter.autoConfig)")
+        protected volatile Ensure m_sequencer;
 
         // Check auto config injections
         @Inject
-        BundleContext m_bc;
+        volatile BundleContext m_bc;
         BundleContext m_bcNotInjected;
-        
+
         @Inject
-        DependencyManager m_dm;
+        volatile DependencyManager m_dm;
         DependencyManager m_dmNotInjected;
-        
+
         @Inject
-        org.apache.felix.dm.Component m_component;
+        volatile org.apache.felix.dm.Component m_component;
         org.apache.felix.dm.Component m_componentNotInjected;
-        
-        public void run3()
-        {
+
+        public void run3() {
             checkInjectedFields();
             m_s1.run();
             m_sequencer.step(3);
         }
-        
-        private void checkInjectedFields()
-        {
-            if (m_bc == null)
-            {
+
+        private void checkInjectedFields() {
+            if (m_bc == null) {
                 m_sequencer.throwable(new Exception("Bundle Context not injected"));
                 return;
             }
-            if (m_bcNotInjected != null)
-            {
+            if (m_bcNotInjected != null) {
                 m_sequencer.throwable(new Exception("Bundle Context must not be injected"));
                 return;
             }
 
-            if (m_dm == null)
-            {
+            if (m_dm == null) {
                 m_sequencer.throwable(new Exception("DependencyManager not injected"));
                 return;
             }
-            if (m_dmNotInjected != null)
-            {
+            if (m_dmNotInjected != null) {
                 m_sequencer.throwable(new Exception("DependencyManager must not be injected"));
                 return;
             }
 
-            if (m_component == null)
-            {
+            if (m_component == null) {
                 m_sequencer.throwable(new Exception("Component not injected"));
                 return;
             }
-            if (m_componentNotInjected != null)
-            {
+            if (m_componentNotInjected != null) {
                 m_sequencer.throwable(new Exception("Component must not be injected"));
                 return;
             }
         }
     }
 
-    @AdapterService(adapteeService = S1.class, 
-                    properties={@Property(name="adapter", value="true")},
-                    field="m_s1")
-    public static class S1ToS3AdapterAutoConfigField implements S3
-    {
+    @AdapterService(adapteeService = S1.class, properties = {@Property(name = "adapter",
value = "true")}, field = "m_s1")
+    public static class S1ToS3AdapterAutoConfigField implements S3 {
         // This is the adapted service
-        protected S1 m_s1;
-        
-        @ServiceDependency(filter="(name=AdapterAutoConfigField)")
-        protected Sequencer m_sequencer;
+        protected volatile S1 m_s1;
+
+        @ServiceDependency(filter = "(name=adapter.autoConfig.field)")
+        protected volatile Ensure m_sequencer;
 
-        public void run3()
-        {
+        public void run3() {
             m_s1.run();
             m_sequencer.step(3);
         }
     }
-    
-    @AdapterService(adapteeService = S1.class, 
-                    properties={@Property(name="adapter", value="true")},
-                    added="bind", 
-                    removed="removed")
-    public static class S1ToS3AdapterCallback implements S3
-    {
+
+    @AdapterService(adapteeService = S1.class, properties = {@Property(name = "adapter",
value = "true")}, added = "bind", removed = "removed")
+    public static class S1ToS3AdapterCallback implements S3 {
         // This is the adapted service
         protected Object m_s1;
-        
-        @ServiceDependency(filter="(name=AdapterCallback)")
-        protected Sequencer m_sequencer;
 
-        void bind(S1 s1)
-        {
+        @ServiceDependency(filter = "(name=adapter.callback)")
+        protected Ensure m_sequencer;
+
+        void bind(S1 s1) {
             m_s1 = s1;
         }
-        
-        public void run3()
-        {
+
+        public void run3() {
             ((S1) m_s1).run();
         }
-                
+
         @Stop
-        void stop() 
-        {
-            m_sequencer.step(3);            
+        void stop() {
+            m_sequencer.step(3);
         }
-        
-        void removed(S1 s1)
-        {
-            m_sequencer.step(4);            
+
+        void removed(S1 s1) {
+            m_sequencer.step(4);
         }
     }
 
-    @Component(properties = { @Property(name = "param1", value = "value1") })
-    public static class S1Impl implements S1
-    {
+    @Component(properties = {@Property(name = "param1", value = "value1")})
+    public static class S1Impl implements S1 {
         @ServiceDependency
-        protected Sequencer m_sequencer;
+        protected Ensure m_sequencer;
 
         @ServiceDependency
         protected S2 m_s2;
-        
-        public void run()
-        {
+
+        public void run() {
             m_sequencer.step(1);
             m_s2.run2();
         }
     }
-    
+
     @Component
-    public static class S2Impl implements S2
-    {
+    public static class S2Impl implements S2 {
         @ServiceDependency
-        protected Sequencer m_sequencer;
-        
-        public void run2()
-        {
+        protected Ensure m_sequencer;
+
+        public void run2() {
             m_sequencer.step(2);
         }
     }

Modified: felix/trunk/dependencymanager/test2/src/main/java/org/apache/felix/dependencymanager/test2/components/SimpleAnnotations.java
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/test2/src/main/java/org/apache/felix/dependencymanager/test2/components/SimpleAnnotations.java?rev=1531687&r1=1531686&r2=1531687&view=diff
==============================================================================
--- felix/trunk/dependencymanager/test2/src/main/java/org/apache/felix/dependencymanager/test2/components/SimpleAnnotations.java
(original)
+++ felix/trunk/dependencymanager/test2/src/main/java/org/apache/felix/dependencymanager/test2/components/SimpleAnnotations.java
Sun Oct 13 13:39:56 2013
@@ -29,7 +29,6 @@ import org.apache.felix.dm.annotation.ap
 import org.apache.felix.dm.annotation.api.Start;
 import org.apache.felix.dm.annotation.api.Stop;
 import org.apache.felix.dm.annotation.api.Unregistered;
-import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceRegistration;
 import org.osgi.service.log.LogService;

Copied: felix/trunk/dependencymanager/test2/src/test/java/org/apache/felix/dependencymanager/test2/integration/annotations/AdapterAnnotationTest.java
(from r1531247, felix/trunk/dependencymanager/test/src/test/java/org/apache/felix/dm/test/annotation/AdapterAnnotationTest.java)
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/test2/src/test/java/org/apache/felix/dependencymanager/test2/integration/annotations/AdapterAnnotationTest.java?p2=felix/trunk/dependencymanager/test2/src/test/java/org/apache/felix/dependencymanager/test2/integration/annotations/AdapterAnnotationTest.java&p1=felix/trunk/dependencymanager/test/src/test/java/org/apache/felix/dm/test/annotation/AdapterAnnotationTest.java&r1=1531247&r2=1531687&rev=1531687&view=diff
==============================================================================
--- felix/trunk/dependencymanager/test/src/test/java/org/apache/felix/dm/test/annotation/AdapterAnnotationTest.java
(original)
+++ felix/trunk/dependencymanager/test2/src/test/java/org/apache/felix/dependencymanager/test2/integration/annotations/AdapterAnnotationTest.java
Sun Oct 13 13:39:56 2013
@@ -16,87 +16,54 @@
 * specific language governing permissions and limitations
 * under the License.
 */
-package org.apache.felix.dm.test.annotation;
+package org.apache.felix.dependencymanager.test2.integration.annotations;
 
-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 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.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 Aspect Annotations usage.
  */
-@RunWith(JUnit4TestRunner.class)
-public class AdapterAnnotationTest 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, "AdapterTest")
-                    .set("Export-Package", "org.apache.felix.dm.test.bundle.annotation.sequencer")
-                    .set("Private-Package", "org.apache.felix.dm.test.bundle.annotation.adapter")
-                    .set("Import-Package", "*")
-                    .set("-plugin", "org.apache.felix.dm.annotation.plugin.bnd.AnnotationPlugin")
-                    .build()));           
-    }
-
+@RunWith(PaxExam.class)
+public class AdapterAnnotationTest extends TestBase {
     /**
      * Check if an adapter gets injected with its adaptee using default auto config mode.
+     * @throws Throwable 
      */
     @Test
-    public void testAnnotatedAdapterAutoConfig(BundleContext context)
-    {
-        DependencyManager m = new DependencyManager(context);
-        // Provide the Sequencer to the org.apache.felix.dm.test.bundle.annotation.adapter.AdapterTest
bundle 
-        m.add(makeSequencer(m, "AdapterAutoConfig"));
-        m_ensure.waitForStep(3, 10000);
+    public void testAnnotatedAdapterAutoConfig() throws Throwable {
+        Ensure e = new Ensure();
+        ServiceRegistration er = register(e, "adapter.autoConfig");
+        e.waitForStep(3, 10000);
+        e.ensure();
+        er.unregister();
     }
-    
+
     /**
      * Check if an adapter gets injected with its adaptee in a named class field.
      */
     @Test
-    public void testAnnotatedAdapterAutoConfigField(BundleContext context) throws Throwable
-    {
-        DependencyManager m = new DependencyManager(context);
-        // Provide the Sequencer to the org.apache.felix.dm.test.bundle.annotation.adapter.AdapterTest
bundle 
-        m.add(makeSequencer(m, "AdapterAutoConfigField"));
-        m_ensure.waitForStep(3, 10000);
-        m_ensure.ensure();
+    public void testAnnotatedAdapterAutoConfigField() throws Throwable {
+        Ensure e = new Ensure();
+        ServiceRegistration er = register(e, "adapter.autoConfig.field");
+        e.waitForStep(3, 10000);
+        e.ensure();
+        er.unregister();
     }
-    
+
     /**
      * Check if an adapter gets injected with its adaptee in a callback method.
      */
     @Test
-    public void testAnnotatedAdapterCallback(BundleContext context)
-    {
-        DependencyManager m = new DependencyManager(context);
-        // Provide the Sequencer to the org.apache.felix.dm.test.bundle.annotation.adapter.AdapterTest
bundle 
-        Component sequencer = makeSequencer(m, "AdapterCallback");
-        m.add(sequencer);
-        m_ensure.waitForStep(2, 10000);
-        m.remove(sequencer);
-        m_ensure.waitForStep(4, 10000);        
+    public void testAnnotatedAdapterCallback() {
+        Ensure e = new Ensure();
+        ServiceRegistration er = register(e, "adapter.callback");
+        e.waitForStep(2, 10000);
+        er.unregister();
+        e.waitForStep(4, 10000);
     }
 }



Mime
View raw message