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 2014/04/13 19:27:45 UTC
svn commit: r1587058 - in
/felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it: ./
.settings/ src/ src/dm/ src/dm/runtime/ src/dm/runtime/it/
src/dm/runtime/it/components/ src/dm/runtime/it/tests/
Author: pderop
Date: Sun Apr 13 17:27:44 2014
New Revision: 1587058
URL: http://svn.apache.org/r1587058
Log:
Added DM runtime integration tests (for now, there is only one test)
Added:
felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/
felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/.classpath (with props)
felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/.gitignore
felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/.project (with props)
felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/.settings/
felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/.settings/org.eclipse.jdt.core.prefs
felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/bnd.bnd
felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/build.xml (with props)
felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/dm.runtime.it.components.bnd
felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/dm.runtime.it.tests.bnd
felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/
felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/
felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/
felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/
felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/components/
felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/components/SimpleAnnotations.java
felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/components/packageinfo
felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/tests/
felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/tests/SimpleAnnotationsTest.java
Added: felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/.classpath
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/.classpath?rev=1587058&view=auto
==============================================================================
Binary file - no diff available.
Propchange: felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/.classpath
------------------------------------------------------------------------------
svn:mime-type = application/xml
Added: felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/.gitignore
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/.gitignore?rev=1587058&view=auto
==============================================================================
--- felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/.gitignore (added)
+++ felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/.gitignore Sun Apr 13 17:27:44 2014
@@ -0,0 +1,2 @@
+/generated/
+/bin/
Added: felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/.project
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/.project?rev=1587058&view=auto
==============================================================================
Binary file - no diff available.
Propchange: felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/.project
------------------------------------------------------------------------------
svn:mime-type = application/xml
Added: felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/.settings/org.eclipse.jdt.core.prefs
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/.settings/org.eclipse.jdt.core.prefs?rev=1587058&view=auto
==============================================================================
--- felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/.settings/org.eclipse.jdt.core.prefs (added)
+++ felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/.settings/org.eclipse.jdt.core.prefs Sun Apr 13 17:27:44 2014
@@ -0,0 +1,11 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.7
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.7
Added: felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/bnd.bnd
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/bnd.bnd?rev=1587058&view=auto
==============================================================================
--- felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/bnd.bnd (added)
+++ felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/bnd.bnd Sun Apr 13 17:27:44 2014
@@ -0,0 +1,27 @@
+-buildpath: \
+ osgi.core;version='[4.2,5)',\
+ osgi.cmpn,\
+ org.mockito.mockito-all,\
+ dm;version=latest,\
+ dm.annotations;version=latest,\
+ dm.it.api;version=latest,\
+ junit.osgi;version=3.8
+-runbundles: \
+ org.mockito.mockito-all,\
+ dm;version=latest,\
+ dm.runtime;version=latest,\
+ dm.it.api;version=latest,\
+ org.apache.felix.configadmin;version=1.8.1,\
+ org.apache.felix.metatype;version=1.0.4,\
+ osgi.cmpn;version=4.3.0,\
+ org.apache.felix.gogo.runtime;version=0.10.0,\
+ dm.runtime.it.components;version=latest,\
+ dm.runtime.it.tests;version=latest
+-runee:JavaSE-1.6
+-runfw:org.apache.felix.framework
+-runsystempackages: \
+ sun.reflect
+-runvm:-ea
+-sub: \
+ *.bnd
+-plugin: dm.annotation.plugin.bnd.AnnotationPlugin;log=debug;path:=${workspace}/dm.annotations/generated/dm.annotations.jar
\ No newline at end of file
Added: felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/build.xml
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/build.xml?rev=1587058&view=auto
==============================================================================
Binary file - no diff available.
Propchange: felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/build.xml
------------------------------------------------------------------------------
svn:mime-type = application/xml
Added: felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/dm.runtime.it.components.bnd
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/dm.runtime.it.components.bnd?rev=1587058&view=auto
==============================================================================
--- felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/dm.runtime.it.components.bnd (added)
+++ felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/dm.runtime.it.components.bnd Sun Apr 13 17:27:44 2014
@@ -0,0 +1,5 @@
+Bundle-Version:0.0.0.${tstamp}
+Test-Cases: \
+ ${classes;CONCRETE;EXTENDS;junit.framework.TestCase}
+Export-Package: \
+ dm.runtime.it.components
\ No newline at end of file
Added: felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/dm.runtime.it.tests.bnd
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/dm.runtime.it.tests.bnd?rev=1587058&view=auto
==============================================================================
--- felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/dm.runtime.it.tests.bnd (added)
+++ felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/dm.runtime.it.tests.bnd Sun Apr 13 17:27:44 2014
@@ -0,0 +1,2 @@
+Private-Package: \
+ dm.runtime.it.tests
\ No newline at end of file
Added: felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/components/SimpleAnnotations.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/components/SimpleAnnotations.java?rev=1587058&view=auto
==============================================================================
--- felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/components/SimpleAnnotations.java (added)
+++ felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/components/SimpleAnnotations.java Sun Apr 13 17:27:44 2014
@@ -0,0 +1,181 @@
+/*
+ * 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 dm.runtime.it.components;
+
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceRegistration;
+import org.osgi.service.log.LogService;
+
+import dm.DependencyManager;
+import dm.annotation.api.Component;
+import dm.annotation.api.Destroy;
+import dm.annotation.api.Init;
+import dm.annotation.api.Inject;
+import dm.annotation.api.Property;
+import dm.annotation.api.Registered;
+import dm.annotation.api.ServiceDependency;
+import dm.annotation.api.Start;
+import dm.annotation.api.Stop;
+import dm.annotation.api.Unregistered;
+import dm.it.Ensure;
+
+public class SimpleAnnotations {
+ /**
+ * Provides a <code>Runnable</code> service, which is required by the
+ * {@link Consumer} class.
+ */
+ @Component(properties = {@Property(name = "foo", value = "bar"), @Property(name="type", value="SimpleAnnotations")})
+ public static class Producer implements Runnable {
+ public final static String ENSURE = "SimpleAnnotations.Producer";
+
+ @ServiceDependency(filter = "(name=" + ENSURE + ")")
+ volatile Ensure _ensure;
+
+ @ServiceDependency
+ volatile LogService _logService;
+
+ @Inject
+ volatile BundleContext _ctx;
+
+ @Init
+ protected void init() {
+ _logService.log(LogService.LOG_INFO, "producer.init");
+ // Our component is initializing (at this point: all required
+ // dependencies are injected).
+ _ensure.step(1);
+ }
+
+ @Start
+ protected void start() {
+ // We are about to be registered in the OSGi registry.
+ _ensure.step(2);
+ }
+
+ @Registered
+ protected void registered(ServiceRegistration sr) {
+ _logService.log(LogService.LOG_INFO, "Registered");
+ if (sr == null) {
+ _ensure.throwable(new Exception("ServiceRegistration is null"));
+ }
+ if (!"bar".equals(sr.getReference().getProperty("foo"))) {
+ _ensure.throwable(new Exception("Invalid Service Properties"));
+ }
+ _ensure.step(3);
+ }
+
+ public void run() {
+ _ensure.step(5);
+ }
+
+ @Stop
+ protected void stop() {
+ // We are about to be unregistered from the OSGi registry, and we
+ // must stop.
+ _ensure.step(8);
+ }
+
+ @Unregistered
+ protected void stopped() {
+ // We are unregistered from the OSGi registry.
+ _ensure.step(9);
+ }
+
+ @Destroy
+ public void destroy() {
+ // Our component is shutting down.
+ _ensure.step(10);
+ }
+ }
+
+ /**
+ * Consumes a service which is provided by the {@link Producer} class.
+ */
+ @Component
+ public static class Consumer {
+ public final static String ENSURE = "SimpleAnnotations.Consumer";
+
+ @ServiceDependency
+ volatile LogService _logService;
+
+ @ServiceDependency(filter="(type=SimpleAnnotations)")
+ volatile Runnable _runnable;
+
+ @ServiceDependency(filter = "(name=" + ENSURE + ")")
+ volatile Ensure _ensure;
+
+ @Inject
+ volatile BundleContext _bc;
+ BundleContext _bcNotInjected;
+
+ @Inject
+ volatile DependencyManager _dm;
+ DependencyManager _dmNotInjected;
+
+ @Inject
+ volatile dm.Component _component;
+ dm.Component _componentNotInjected;
+
+ @Start
+ protected void start() {
+ _logService.log(LogService.LOG_INFO, "Consumer.START: ");
+ checkInjectedFields();
+ _ensure.step(4);
+ _runnable.run();
+ }
+
+ private void checkInjectedFields() {
+ if (_bc == null) {
+ _ensure.throwable(new Exception("Bundle Context not injected"));
+ return;
+ }
+ if (_bcNotInjected != null) {
+ _ensure.throwable(new Exception("Bundle Context must not be injected"));
+ return;
+ }
+
+ if (_dm == null) {
+ _ensure.throwable(new Exception("DependencyManager not injected"));
+ return;
+ }
+ if (_dmNotInjected != null) {
+ _ensure.throwable(new Exception("DependencyManager must not be injected"));
+ return;
+ }
+
+ if (_component == null) {
+ _ensure.throwable(new Exception("Component not injected"));
+ return;
+ }
+ if (_componentNotInjected != null) {
+ _ensure.throwable(new Exception("Component must not be injected"));
+ return;
+ }
+ }
+
+ @Stop
+ protected void stop() {
+ _ensure.step(6);
+ }
+
+ @Destroy
+ void destroy() {
+ _ensure.step(7);
+ }
+ }
+}
Added: felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/components/packageinfo
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/components/packageinfo?rev=1587058&view=auto
==============================================================================
--- felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/components/packageinfo (added)
+++ felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/components/packageinfo Sun Apr 13 17:27:44 2014
@@ -0,0 +1 @@
+version 1.0
\ No newline at end of file
Added: felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/tests/SimpleAnnotationsTest.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/tests/SimpleAnnotationsTest.java?rev=1587058&view=auto
==============================================================================
--- felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/tests/SimpleAnnotationsTest.java (added)
+++ felix/sandbox/pderop/dependencymanager-prototype/dm.runtime.it/src/dm/runtime/it/tests/SimpleAnnotationsTest.java Sun Apr 13 17:27:44 2014
@@ -0,0 +1,27 @@
+package dm.runtime.it.tests;
+
+import org.osgi.framework.ServiceRegistration;
+
+import dm.it.Ensure;
+import dm.it.TestBase;
+import dm.runtime.it.components.SimpleAnnotations.Consumer;
+import dm.runtime.it.components.SimpleAnnotations.Producer;
+
+/**
+ * Use case: Ensure that a Provider can be injected into a Consumer, using simple DM annotations.
+ */
+public class SimpleAnnotationsTest extends TestBase {
+ public void testSimpleAnnotations() throws Throwable {
+ Ensure e = new Ensure();
+ ServiceRegistration er = register(e, Producer.ENSURE);
+ e.waitForStep(3, 10000); // Producer registered
+ ServiceRegistration er2 = register(e, Consumer.ENSURE);
+
+ er2.unregister(); // stop consumer
+ er.unregister(); // stop provider
+
+ // And check if components have been deactivated orderly.
+ e.waitForStep(10, 10000);
+ e.ensure();
+ }
+}