felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pde...@apache.org
Subject svn commit: r899462 - in /felix/trunk/dependencymanager/test: annotation/src/main/java/org/apache/felix/dm/test/annotation/ src/test/java/org/apache/felix/dm/test/
Date Thu, 14 Jan 2010 23:17:57 GMT
Author: pderop
Date: Thu Jan 14 23:17:57 2010
New Revision: 899462

URL: http://svn.apache.org/viewvc?rev=899462&view=rev
Log:
added new testcase regarding annotations and dependencymanager service factories

Added:
    felix/trunk/dependencymanager/test/annotation/src/main/java/org/apache/felix/dm/test/annotation/Factory.java
    felix/trunk/dependencymanager/test/annotation/src/main/java/org/apache/felix/dm/test/annotation/FactoryTest.java
Modified:
    felix/trunk/dependencymanager/test/annotation/src/main/java/org/apache/felix/dm/test/annotation/ServiceProvider.java
    felix/trunk/dependencymanager/test/annotation/src/main/java/org/apache/felix/dm/test/annotation/ServiceProvider2.java
    felix/trunk/dependencymanager/test/src/test/java/org/apache/felix/dm/test/AnnotationTest.java

Added: felix/trunk/dependencymanager/test/annotation/src/main/java/org/apache/felix/dm/test/annotation/Factory.java
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/test/annotation/src/main/java/org/apache/felix/dm/test/annotation/Factory.java?rev=899462&view=auto
==============================================================================
--- felix/trunk/dependencymanager/test/annotation/src/main/java/org/apache/felix/dm/test/annotation/Factory.java
(added)
+++ felix/trunk/dependencymanager/test/annotation/src/main/java/org/apache/felix/dm/test/annotation/Factory.java
Thu Jan 14 23:17:57 2010
@@ -0,0 +1,23 @@
+/*
+ * 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;
+
+/**
+ * Class used to instantiate various components unsing Dependency Manager Factories.
+ */
+public class Factory
+{
+    public FactoryTest createFactoryTest()
+    {
+        return new FactoryTest("factory");
+    }
+}

Added: felix/trunk/dependencymanager/test/annotation/src/main/java/org/apache/felix/dm/test/annotation/FactoryTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/test/annotation/src/main/java/org/apache/felix/dm/test/annotation/FactoryTest.java?rev=899462&view=auto
==============================================================================
--- felix/trunk/dependencymanager/test/annotation/src/main/java/org/apache/felix/dm/test/annotation/FactoryTest.java
(added)
+++ felix/trunk/dependencymanager/test/annotation/src/main/java/org/apache/felix/dm/test/annotation/FactoryTest.java
Thu Jan 14 23:17:57 2010
@@ -0,0 +1,41 @@
+/*
+ * 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 org.apache.felix.dm.annotation.api.Service;
+import org.apache.felix.dm.annotation.api.ServiceDependency;
+import org.apache.felix.dm.annotation.api.Start;
+
+/**
+ * Validate DependencyManager Factories declarared with annotations.
+ */
+@Service(factory=Factory.class, factoryMethod="createFactoryTest")
+public class FactoryTest
+{
+    String m_id;
+    
+    @ServiceDependency(filter="(test=factory)")
+    Sequencer m_sequencer;
+    
+    public FactoryTest(String id)
+    {
+        m_id = id;
+    }
+    
+    @Start
+    void start() {
+        if (! "factory".equals(m_id)) {
+            throw new IllegalStateException();
+        }
+        m_sequencer.next(1);
+    }
+}

Modified: felix/trunk/dependencymanager/test/annotation/src/main/java/org/apache/felix/dm/test/annotation/ServiceProvider.java
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/test/annotation/src/main/java/org/apache/felix/dm/test/annotation/ServiceProvider.java?rev=899462&r1=899461&r2=899462&view=diff
==============================================================================
--- felix/trunk/dependencymanager/test/annotation/src/main/java/org/apache/felix/dm/test/annotation/ServiceProvider.java
(original)
+++ felix/trunk/dependencymanager/test/annotation/src/main/java/org/apache/felix/dm/test/annotation/ServiceProvider.java
Thu Jan 14 23:17:57 2010
@@ -19,7 +19,7 @@
 @Service(properties = { "foo=bar" })
 public class ServiceProvider implements ServiceInterface
 {
-    @ServiceDependency
+    @ServiceDependency(filter="(test=simple)")
     Sequencer m_sequencer;
 
     @ServiceDependency(removed="unbind")

Modified: felix/trunk/dependencymanager/test/annotation/src/main/java/org/apache/felix/dm/test/annotation/ServiceProvider2.java
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/test/annotation/src/main/java/org/apache/felix/dm/test/annotation/ServiceProvider2.java?rev=899462&r1=899461&r2=899462&view=diff
==============================================================================
--- felix/trunk/dependencymanager/test/annotation/src/main/java/org/apache/felix/dm/test/annotation/ServiceProvider2.java
(original)
+++ felix/trunk/dependencymanager/test/annotation/src/main/java/org/apache/felix/dm/test/annotation/ServiceProvider2.java
Thu Jan 14 23:17:57 2010
@@ -26,7 +26,7 @@
     @ServiceDependency(required=false, filter="(foo=bar)")
     Runnable m_runnable;
 
-    @ServiceDependency(service=Sequencer.class)
+    @ServiceDependency(service=Sequencer.class, filter="(test=simple)")
     void bind(Sequencer seq)
     {
         m_sequencer = seq;

Modified: felix/trunk/dependencymanager/test/src/test/java/org/apache/felix/dm/test/AnnotationTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/test/src/test/java/org/apache/felix/dm/test/AnnotationTest.java?rev=899462&r1=899461&r2=899462&view=diff
==============================================================================
--- felix/trunk/dependencymanager/test/src/test/java/org/apache/felix/dm/test/AnnotationTest.java
(original)
+++ felix/trunk/dependencymanager/test/src/test/java/org/apache/felix/dm/test/AnnotationTest.java
Thu Jan 14 23:17:57 2010
@@ -22,6 +22,9 @@
 import static org.ops4j.pax.exam.CoreOptions.options;
 import static org.ops4j.pax.exam.CoreOptions.provision;
 
+import java.util.Dictionary;
+import java.util.Hashtable;
+
 import org.apache.felix.dm.DependencyManager;
 import org.apache.felix.dm.test.annotation.Sequencer;
 import org.junit.Test;
@@ -33,6 +36,7 @@
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.BundleException;
 
+@SuppressWarnings({ "unchecked", "serial" })
 @RunWith(JUnit4TestRunner.class)
 public class AnnotationTest implements Sequencer
 {
@@ -54,7 +58,8 @@
         m_ensure = new Ensure();
         DependencyManager m = new DependencyManager(context);
         // We provide ourself as a "Sequencer" service: this will active the "org.apache.felix.dependencymanager.test.annotation"
bundle
-        m.add(m.createService().setImplementation(this).setInterface(Sequencer.class.getName(),
null));
+        Dictionary props = new Hashtable() {{ put("test", "simple"); }};
+        m.add(m.createService().setImplementation(this).setInterface(Sequencer.class.getName(),
props));
         // Check if the test.annotation components have been initialized orderly
         m_ensure.waitForStep(7, 10000);
         // Stop the test.annotation bundle
@@ -82,6 +87,18 @@
         m_ensure.waitForStep(11, 10000);
     }
 
+    @Test
+    public void testFactoryAnnotation(BundleContext context)
+    {
+        m_ensure = new Ensure();
+        DependencyManager m = new DependencyManager(context);
+        // We provide ourself as a "Sequencer" service: this will active the "org.apache.felix.dependencymanager.test.annotation"
bundle
+        Dictionary props = new Hashtable() {{ put("test", "factory"); }};
+        m.add(m.createService().setImplementation(this).setInterface(Sequencer.class.getName(),
props));
+        // Check if the test.annotation components have been initialized orderly
+        m_ensure.waitForStep(1, 10000);
+    }
+        
     // The test.annotation bundle will call back us here
     public void next(int step)
     {



Mime
View raw message