You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by pd...@apache.org on 2013/10/13 23:44:44 UTC
svn commit: r1531757 - in /felix/trunk/dependencymanager:
test/src/main/java/org/apache/felix/dm/test/bundle/annotation/multiple/
test/src/test/java/org/apache/felix/dm/test/annotation/
test2/src/main/java/org/apache/felix/dependencymanager/test2/compo...
Author: pderop
Date: Sun Oct 13 21:44:44 2013
New Revision: 1531757
URL: http://svn.apache.org/r1531757
Log:
pax-exam 3.0.0 migration ...
Added:
felix/trunk/dependencymanager/test2/src/main/java/org/apache/felix/dependencymanager/test2/components/MultipleAnnotations.java
felix/trunk/dependencymanager/test2/src/test/java/org/apache/felix/dependencymanager/test2/integration/annotations/MultipleAnnotationsTest.java
- copied, changed from r1531247, felix/trunk/dependencymanager/test/src/test/java/org/apache/felix/dm/test/annotation/MultipleAnnotationsTest.java
Removed:
felix/trunk/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/multiple/
felix/trunk/dependencymanager/test/src/test/java/org/apache/felix/dm/test/annotation/MultipleAnnotationsTest.java
Added: felix/trunk/dependencymanager/test2/src/main/java/org/apache/felix/dependencymanager/test2/components/MultipleAnnotations.java
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/test2/src/main/java/org/apache/felix/dependencymanager/test2/components/MultipleAnnotations.java?rev=1531757&view=auto
==============================================================================
--- felix/trunk/dependencymanager/test2/src/main/java/org/apache/felix/dependencymanager/test2/components/MultipleAnnotations.java (added)
+++ felix/trunk/dependencymanager/test2/src/main/java/org/apache/felix/dependencymanager/test2/components/MultipleAnnotations.java Sun Oct 13 21:44:44 2013
@@ -0,0 +1,129 @@
+/*
+* 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.components;
+
+import org.apache.felix.dm.annotation.api.Component;
+import org.apache.felix.dm.annotation.api.Composition;
+import org.apache.felix.dm.annotation.api.Property;
+import org.apache.felix.dm.annotation.api.ServiceDependency;
+import org.apache.felix.dm.annotation.api.Start;
+import org.apache.felix.dm.annotation.api.Stop;
+
+public class MultipleAnnotations {
+ public static class Composite {
+ void bind(Ensure seq) {
+ seq.step(2);
+ }
+ }
+
+ @Component
+ public static class ServiceConsumer {
+ @ServiceDependency(filter="(name=test.MultipleAnnotationsTest)")
+ volatile Ensure m_sequencer;
+
+ @ServiceDependency(filter = "(foo=bar)")
+ volatile ServiceInterface m_service;
+
+ @Start
+ void start() {
+ m_sequencer.step(6);
+ m_service.doService();
+ }
+
+ @Stop
+ void stop() {
+ m_sequencer.step(8);
+ }
+ }
+
+ public interface ServiceInterface {
+ public void doService();
+ }
+
+ @Component(properties = {@Property(name = "foo", value = "bar")})
+ public static class ServiceProvider implements ServiceInterface {
+ @ServiceDependency(filter="(name=test.MultipleAnnotationsTest)")
+ volatile Ensure m_sequencer;
+
+ volatile ServiceProvider2 m_serviceProvider2;
+
+ @ServiceDependency(removed = "unbind")
+ void bind(ServiceProvider2 provider2) {
+ m_serviceProvider2 = provider2;
+ }
+
+ @Start
+ void start() {
+ m_serviceProvider2.step(4);
+ m_sequencer.step(5);
+ }
+
+ @Stop
+ void stop() {
+ m_sequencer.step(9);
+ }
+
+ void unbind(ServiceProvider2 provider2) {
+ m_sequencer.step(10);
+ }
+
+ public void doService() {
+ m_sequencer.step(7);
+ }
+ }
+
+ @Component(provides = {ServiceProvider2.class}, factoryMethod = "create")
+ public static class ServiceProvider2 {
+ final Composite m_composite = new Composite();
+ volatile Ensure m_sequencer;
+
+ static ServiceProvider2 create() {
+ return new ServiceProvider2();
+ }
+
+ @ServiceDependency(required = false, filter = "(foo=bar)") // NullObject
+ volatile Runnable m_runnable;
+
+ @ServiceDependency(service = Ensure.class, filter="(name=test.MultipleAnnotationsTest)")
+ void bind(Ensure seq) {
+ m_sequencer = seq;
+ m_sequencer.step(1);
+ }
+
+ @Start
+ void start() {
+ m_sequencer.step(3);
+ m_runnable.run(); // NullObject
+ }
+
+ public void step(int step) { // called by ServiceProvider.start() method
+ m_sequencer.step(step);
+ }
+
+ @Stop
+ void stop() {
+ m_sequencer.step(11);
+ }
+
+ @Composition
+ Object[] getComposition() {
+ return new Object[]{this, m_composite};
+ }
+ }
+}
Copied: felix/trunk/dependencymanager/test2/src/test/java/org/apache/felix/dependencymanager/test2/integration/annotations/MultipleAnnotationsTest.java (from r1531247, felix/trunk/dependencymanager/test/src/test/java/org/apache/felix/dm/test/annotation/MultipleAnnotationsTest.java)
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/test2/src/test/java/org/apache/felix/dependencymanager/test2/integration/annotations/MultipleAnnotationsTest.java?p2=felix/trunk/dependencymanager/test2/src/test/java/org/apache/felix/dependencymanager/test2/integration/annotations/MultipleAnnotationsTest.java&p1=felix/trunk/dependencymanager/test/src/test/java/org/apache/felix/dm/test/annotation/MultipleAnnotationsTest.java&r1=1531247&r2=1531757&rev=1531757&view=diff
==============================================================================
--- felix/trunk/dependencymanager/test/src/test/java/org/apache/felix/dm/test/annotation/MultipleAnnotationsTest.java (original)
+++ felix/trunk/dependencymanager/test2/src/test/java/org/apache/felix/dependencymanager/test2/integration/annotations/MultipleAnnotationsTest.java Sun Oct 13 21:44:44 2013
@@ -16,63 +16,28 @@
* 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.DependencyManager;
-import org.apache.felix.dm.test.Base;
-import org.apache.felix.dm.test.BundleGenerator;
-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 complex Annotation usage.
*/
-@RunWith(JUnit4TestRunner.class)
-public class MultipleAnnotationsTest 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, "MultipleAnnotationsTest")
- .set("Export-Package", "org.apache.felix.dm.test.bundle.annotation.sequencer")
- .set("Private-Package", "org.apache.felix.dm.test.bundle.annotation.multiple")
- .set("Import-Package", "*")
- .set("-plugin", "org.apache.felix.dm.annotation.plugin.bnd.AnnotationPlugin")
- .build()));
- }
-
+@RunWith(PaxExam.class)
+public class MultipleAnnotationsTest extends TestBase {
@Test
- public void testMultipleAnnotations(BundleContext context)
- {
- DependencyManager m = new DependencyManager(context);
- // Provide the Sequencer service to the MultipleAnnotationsTest class.
- m.add(m.createComponent()
- .setImplementation(this)
- .setInterface(Sequencer.class.getName(), null));
- // Check if the test.annotation components have been initialized orderly
- m_ensure.waitForStep(7, 10000);
- // Stop the test.annotation bundle
- stopBundle("MultipleAnnotationsTest", context);
+ public void testMultipleAnnotations() {
+ Ensure e = new Ensure();
+ ServiceRegistration sr = register(e, "test.MultipleAnnotationsTest");
+ e.waitForStep(7, 10000);
+ stopTestComponentsBundle();
// And check if the test.annotation bundle has been deactivated orderly
- m_ensure.waitForStep(11, 10000);
+ e.waitForStep(11, 10000);
+ sr.unregister();
}
}