Author: pderop
Date: Mon Jan 11 21:51:47 2010
New Revision: 898084
URL: http://svn.apache.org/viewvc?rev=898084&view=rev
Log:
Added test case regarding annotation support (this requires the new
test.annotation bundle)
Added:
felix/trunk/dependencymanager/test/src/test/java/org/apache/felix/dm/test/AnnotationTest.java
Modified:
felix/trunk/dependencymanager/test/pom.xml
Modified: felix/trunk/dependencymanager/test/pom.xml
URL:
http://svn.apache.org/viewvc/felix/trunk/dependencymanager/test/pom.xml?rev=898084&r1=898083&r2=898084&view=diff
==============================================================================
--- felix/trunk/dependencymanager/test/pom.xml (original)
+++ felix/trunk/dependencymanager/test/pom.xml Mon Jan 11 21:51:47 2010
@@ -44,6 +44,18 @@
<scope>provided</scope>
</dependency>
<dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>org.apache.felix.dependencymanager.runtime</artifactId>
+ <version>3.0.0-SNAPSHOT</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+
<artifactId>org.apache.felix.dependencymanager.test.annotation</artifactId>
+ <version>3.0.0-SNAPSHOT</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
<groupId>org.ops4j.pax.exam</groupId>
<artifactId>pax-exam</artifactId>
<version>1.2.0</version>
Added:
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=898084&view=auto
==============================================================================
---
felix/trunk/dependencymanager/test/src/test/java/org/apache/felix/dm/test/AnnotationTest.java
(added)
+++
felix/trunk/dependencymanager/test/src/test/java/org/apache/felix/dm/test/AnnotationTest.java
Mon Jan 11 21:51:47 2010
@@ -0,0 +1,90 @@
+/*
+* 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;
+
+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 org.apache.felix.dm.DependencyManager;
+import org.apache.felix.dm.test.annotation.Sequencer;
+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.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleException;
+
+...@runwith(JUnit4TestRunner.class)
+public class AnnotationTest implements Sequencer
+{
+ Ensure m_ensure;
+
+ @Configuration
+ public static Option[] configuration()
+ {
+ return options(provision(
+
mavenBundle().groupId("org.osgi").artifactId("org.osgi.compendium").version("4.1.0"),
+
mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.dependencymanager").versionAsInProject(),
+
mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.dependencymanager.runtime").versionAsInProject(),
+
mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.dependencymanager.test.annotation").versionAsInProject()));
+ }
+
+ @Test
+ public void testSimpleAnnotations(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
+
m.add(m.createService().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
+ boolean found = false;
+ for (Bundle b : context.getBundles())
+ {
+ if
(b.getSymbolicName().equals("org.apache.felix.dependencymanager.test.annotation"))
+ {
+ try
+ {
+ found = true;
+ b.stop();
+ }
+ catch (BundleException e)
+ {
+ e.printStackTrace();
+ }
+ }
+ }
+ if (! found)
+ {
+ throw new
IllegalStateException("org.apache.felix.dependencymanager.test.annotation
bundle not found");
+ }
+ // And check if the test.annotation bundle has been deactivated orderly
+ m_ensure.waitForStep(11, 10000);
+ }
+
+ // The test.annotation bundle will call back us here
+ public void next(int step)
+ {
+ m_ensure.step(step);
+ }
+}