This is an automated email from the ASF dual-hosted git repository. rombert pushed a commit to annotated tag org.apache.sling.testing.osgi-mock-2.2.4 in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-testing-osgi-mock.git
commit e5e9177191b14d3803cf0a3d21586690c05f7e25 Author: Stefan Seifert <[email protected]> AuthorDate: Sun Mar 19 16:22:40 2017 +0000 SLING-6672 osgi-mock: Switch to OSGi annotations git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/testing/mocks/osgi-mock@1787642 13f79535-47bb-0310-9956-ffa450edef68 --- pom.xml | 11 ----- .../sling/testing/mock/osgi/MockEventAdmin.java | 21 ++++----- .../OsgiServiceUtilActivateDeactivateTest.java | 6 +-- .../testing/mock/osgi/OsgiServiceUtilTest.java | 54 ++++++++++------------ 4 files changed, 37 insertions(+), 55 deletions(-) diff --git a/pom.xml b/pom.xml index 1cb7493..ff2a289 100644 --- a/pom.xml +++ b/pom.xml @@ -43,12 +43,6 @@ <dependencies> <dependency> - <groupId>org.apache.felix</groupId> - <artifactId>org.apache.felix.scr.annotations</artifactId> - <scope>provided</scope> - </dependency> - - <dependency> <groupId>org.osgi</groupId> <artifactId>osgi.core</artifactId> <scope>compile</scope> @@ -167,11 +161,6 @@ <extensions>true</extensions> </plugin> - <plugin> - <groupId>org.apache.felix</groupId> - <artifactId>maven-scr-plugin</artifactId> - </plugin> - <plugin> <groupId>org.apache.rat</groupId> <artifactId>apache-rat-plugin</artifactId> diff --git a/src/main/java/org/apache/sling/testing/mock/osgi/MockEventAdmin.java b/src/main/java/org/apache/sling/testing/mock/osgi/MockEventAdmin.java index 86c4eb5..fa16f44 100644 --- a/src/main/java/org/apache/sling/testing/mock/osgi/MockEventAdmin.java +++ b/src/main/java/org/apache/sling/testing/mock/osgi/MockEventAdmin.java @@ -26,16 +26,15 @@ import java.util.concurrent.RejectedExecutionException; import java.util.regex.Matcher; import java.util.regex.Pattern; -import org.apache.felix.scr.annotations.Activate; -import org.apache.felix.scr.annotations.Component; -import org.apache.felix.scr.annotations.Deactivate; -import org.apache.felix.scr.annotations.Reference; -import org.apache.felix.scr.annotations.ReferenceCardinality; -import org.apache.felix.scr.annotations.ReferencePolicy; -import org.apache.felix.scr.annotations.Service; import org.apache.sling.commons.osgi.Order; import org.apache.sling.commons.osgi.ServiceUtil; import org.osgi.service.component.ComponentContext; +import org.osgi.service.component.annotations.Activate; +import org.osgi.service.component.annotations.Component; +import org.osgi.service.component.annotations.Deactivate; +import org.osgi.service.component.annotations.Reference; +import org.osgi.service.component.annotations.ReferenceCardinality; +import org.osgi.service.component.annotations.ReferencePolicy; import org.osgi.service.event.Event; import org.osgi.service.event.EventAdmin; import org.osgi.service.event.EventConstants; @@ -47,12 +46,12 @@ import org.slf4j.LoggerFactory; * Mock implementation of {@link EventAdmin}. * From {@link EventConstants} currently only {@link EventConstants#EVENT_TOPIC} is supported. */ -@Component(immediate = true) -@Service(value = EventAdmin.class) +@Component(immediate = true, service = EventAdmin.class) public final class MockEventAdmin implements EventAdmin { - @Reference(name="eventHandler", referenceInterface=EventHandler.class, - cardinality=ReferenceCardinality.OPTIONAL_MULTIPLE, policy=ReferencePolicy.DYNAMIC) + @Reference(name="eventHandler", service=EventHandler.class, + cardinality=ReferenceCardinality.MULTIPLE, policy=ReferencePolicy.DYNAMIC, + bind="bindEventHandler", unbind="unbindEventHandler") private final Map<Object, EventHandlerItem> eventHandlers = new TreeMap<Object, EventHandlerItem>(); private ExecutorService asyncHandler; diff --git a/src/test/java/org/apache/sling/testing/mock/osgi/OsgiServiceUtilActivateDeactivateTest.java b/src/test/java/org/apache/sling/testing/mock/osgi/OsgiServiceUtilActivateDeactivateTest.java index 7ea72d3..60358a4 100644 --- a/src/test/java/org/apache/sling/testing/mock/osgi/OsgiServiceUtilActivateDeactivateTest.java +++ b/src/test/java/org/apache/sling/testing/mock/osgi/OsgiServiceUtilActivateDeactivateTest.java @@ -25,12 +25,12 @@ import static org.junit.Assert.assertTrue; import java.util.Map; -import org.apache.felix.scr.annotations.Activate; -import org.apache.felix.scr.annotations.Component; -import org.apache.felix.scr.annotations.Deactivate; import org.junit.Test; import org.osgi.framework.BundleContext; import org.osgi.service.component.ComponentContext; +import org.osgi.service.component.annotations.Activate; +import org.osgi.service.component.annotations.Component; +import org.osgi.service.component.annotations.Deactivate; import com.google.common.collect.ImmutableMap; diff --git a/src/test/java/org/apache/sling/testing/mock/osgi/OsgiServiceUtilTest.java b/src/test/java/org/apache/sling/testing/mock/osgi/OsgiServiceUtilTest.java index ee1bf5b..1f92fa7 100644 --- a/src/test/java/org/apache/sling/testing/mock/osgi/OsgiServiceUtilTest.java +++ b/src/test/java/org/apache/sling/testing/mock/osgi/OsgiServiceUtilTest.java @@ -31,14 +31,6 @@ import java.util.Hashtable; import java.util.List; import java.util.Map; -import org.apache.felix.scr.annotations.Activate; -import org.apache.felix.scr.annotations.Component; -import org.apache.felix.scr.annotations.Deactivate; -import org.apache.felix.scr.annotations.Property; -import org.apache.felix.scr.annotations.Reference; -import org.apache.felix.scr.annotations.ReferenceCardinality; -import org.apache.felix.scr.annotations.References; -import org.apache.felix.scr.annotations.Service; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -50,7 +42,12 @@ import org.osgi.framework.ServiceFactory; import org.osgi.framework.ServiceReference; import org.osgi.framework.ServiceRegistration; import org.osgi.service.component.ComponentContext; +import org.osgi.service.component.annotations.Activate; +import org.osgi.service.component.annotations.Component; +import org.osgi.service.component.annotations.Deactivate; import org.osgi.service.component.annotations.Modified; +import org.osgi.service.component.annotations.Reference; +import org.osgi.service.component.annotations.ReferenceCardinality; import com.google.common.collect.ImmutableMap; @@ -222,32 +219,31 @@ public class OsgiServiceUtilTest { // no methods } - @Component - @Service(ServiceInterface1.class) - @Property(name = Constants.SERVICE_RANKING, intValue = 100) + @Component(service = ServiceInterface1.class, + property = Constants.SERVICE_RANKING + ":Integer=100") public static class Service1 implements ServiceInterface1 { // dummy interface } - @Component - @Service({ ServiceInterface2.class, ServiceInterface3.class }) - @Property(name = Constants.SERVICE_RANKING, intValue = 200) + @Component(service = { ServiceInterface2.class, ServiceInterface3.class }, + property = Constants.SERVICE_RANKING + ":Integer=200") public static class Service2 implements ServiceInterface2, ServiceInterface3 { // dummy interface } - @Component - @References({ @Reference(name = "reference2", referenceInterface = ServiceInterface2.class, cardinality = ReferenceCardinality.MANDATORY_MULTIPLE) }) + @Component(reference = { @Reference(name = "reference2", service = ServiceInterface2.class, cardinality = ReferenceCardinality.AT_LEAST_ONE, + bind="bindReference2", unbind="unbindReference2") }) public static class Service3 { - @Reference + @Reference(bind="bindReference1", unbind="unbindReference1") private ServiceInterface1 reference1; - @Reference(cardinality = ReferenceCardinality.OPTIONAL_UNARY) + @Reference(cardinality = ReferenceCardinality.OPTIONAL, bind="bindReference1Optional", unbind="unbindReference1Optional") private ServiceInterface1Optional reference1Optional; private List<ServiceReference> references2 = new ArrayList<ServiceReference>(); - @Reference(name = "reference3", referenceInterface = ServiceInterface3.class, cardinality = ReferenceCardinality.OPTIONAL_MULTIPLE) + @Reference(name = "reference3", service = ServiceInterface3.class, cardinality = ReferenceCardinality.MULTIPLE, + bind="bindReference3", unbind="unbindReference3") private List<ServiceSuperInterface3> references3 = new ArrayList<ServiceSuperInterface3>(); private List<Map<String, Object>> reference3Configs = new ArrayList<Map<String, Object>>(); @@ -399,18 +395,19 @@ public class OsgiServiceUtilTest { } - @Component - @References({ @Reference(name = "reference2", referenceInterface = ServiceInterface2.class, cardinality = ReferenceCardinality.MANDATORY_MULTIPLE) }) + @Component(reference = { @Reference(name = "reference2", service = ServiceInterface2.class, cardinality = ReferenceCardinality.AT_LEAST_ONE, + bind="bindReference2", unbind="unbindReference2") }) public static class Service3StaticGreedy { - @Reference + @Reference(bind="bindReference1", unbind="unbindReference1") private ServiceInterface1 reference1; - @Reference(cardinality = ReferenceCardinality.OPTIONAL_UNARY) + @Reference(cardinality = ReferenceCardinality.OPTIONAL, bind="bindReference1Optional", unbind="unbindReference1Optional") private ServiceInterface1Optional reference1Optional; private List<ServiceReference> references2 = new ArrayList<ServiceReference>(); - @Reference(name = "reference3", referenceInterface = ServiceInterface3.class, cardinality = ReferenceCardinality.OPTIONAL_MULTIPLE) + @Reference(name = "reference3", service = ServiceInterface3.class, cardinality = ReferenceCardinality.MULTIPLE, + bind="bindReference3", unbind="unbindReference3") private List<ServiceSuperInterface3> references3 = new ArrayList<ServiceSuperInterface3>(); private List<Map<String, Object>> reference3Configs = new ArrayList<Map<String, Object>>(); @@ -501,8 +498,7 @@ public class OsgiServiceUtilTest { } - @Component - @Reference(referenceInterface = ServiceInterface1.class, name = "customName", bind = "customBind", unbind = "customUnbind") + @Component(reference = @Reference(service = ServiceInterface1.class, name = "customName", bind = "customBind", unbind = "customUnbind")) public static class Service4 { private ServiceInterface1 reference1; @@ -521,8 +517,7 @@ public class OsgiServiceUtilTest { } - @Component - @Service({ ServiceInterface5.class }) + @Component(service = { ServiceInterface5.class }) public static class Service5 implements ServiceInterface5 { @Override @@ -537,8 +532,7 @@ public class OsgiServiceUtilTest { } - @Component - @Service(value=ServiceFactory1.class, serviceFactory=true) + @Component(service = ServiceFactory1.class, servicefactory = true) public static class ServiceFactory1 { } -- To stop receiving notification emails like this one, please contact "[email protected]" <[email protected]>.
