Really execute the Instantiate annotation test suite
Improve @Instantiate annotation processing
Fix a race condition when service properties are modified during the service object constructor.
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@894154 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/ipojo/tests/core/annotations/pom.xml b/ipojo/tests/core/annotations/pom.xml
index 1a1b0e1..d54fe9b 100644
--- a/ipojo/tests/core/annotations/pom.xml
+++ b/ipojo/tests/core/annotations/pom.xml
@@ -60,6 +60,14 @@
<artifactId>org.apache.felix.ipojo.handler.eventadmin</artifactId>
<version>${pom.version}</version>
</dependency>
+
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.eventadmin</artifactId>
+ <version>1.0.0</version>
+ <scope>test</scope>
+ </dependency>
+
</dependencies>
<build>
@@ -106,6 +114,25 @@
</execution>
</executions>
</plugin>
+
+
+ <!-- <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-junit4osgi-plugin</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>test</goal>
+ </goals>
+ <configuration>
+ <configuration>
+ <org.osgi.http.port>8083</org.osgi.http.port>
+ </configuration>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>-->
</plugins>
</build>
</project>
diff --git a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/AnnotationsTestSuite.java b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/AnnotationsTestSuite.java
index dc7d880..c768413 100644
--- a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/AnnotationsTestSuite.java
+++ b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/AnnotationsTestSuite.java
@@ -48,6 +48,8 @@
ots.addTestSuite(Extender.class);
ots.addTestSuite(EventAdmin.class);
+ // Instantiate
+ ots.addTestSuite(Instantiate.class);
return ots;
}
diff --git a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/Instantiate.java b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/Instantiate.java
index 67c2d55..67c2e8f 100644
--- a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/Instantiate.java
+++ b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/Instantiate.java
@@ -9,6 +9,7 @@
import org.apache.felix.ipojo.parser.ManifestMetadataParser;
import org.apache.felix.ipojo.parser.ParseException;
import org.osgi.framework.Bundle;
+import org.osgi.framework.InvalidSyntaxException;
import org.osgi.framework.ServiceReference;
public class Instantiate extends OSGiTestCase {
@@ -20,7 +21,7 @@
}
public void testInstantiateSimple() {
- Element[] meta = getInstanceMetadata(context.getBundle(), "org.apache.felix.ipojo.test.scenarios.component.Instantiate");
+ Element[] meta = getInstanceMetadata(context.getBundle(), "org.apache.felix.ipojo.test.scenarios.component.InstantiateSimple");
assertNotNull(meta);
assertEquals(1, meta.length);
assertNull(meta[0].getAttribute("name"));
@@ -32,19 +33,22 @@
Element[] meta = getInstanceMetadata(context.getBundle(), "org.apache.felix.ipojo.test.scenarios.component.InstantiateWithName");
assertNotNull(meta);
assertEquals(1, meta.length);
- assertNull(meta[0].getAttribute("name"));
+ assertNotNull(meta[0].getAttribute("name"));
+ assertEquals("myInstantiatedInstance", meta[0].getAttribute("name"));
assertEquals(0, meta[0].getElements().length);
}
- public void testInstanceCreation() {
- String in = "org.apache.felix.ipojo.test.scenarios.component.Instantiate-0";
- ServiceReference ref = helper.getServiceReferenceByName(Architecture.class.getName(), in);
+ public void testInstanceCreation() throws InvalidSyntaxException {
+ String in = "org.apache.felix.ipojo.test.scenarios.component.InstantiateSimple-0";
+ ServiceReference ref = helper.getServiceReferenceByName(org.apache.felix.ipojo.architecture.Architecture.class.getName(),
+ in);
assertNotNull(ref);
}
public void testInstanceCreationWithName() {
String in = "myInstantiatedInstance";
- ServiceReference ref = helper.getServiceReferenceByName(Architecture.class.getName(), in);
+ ServiceReference ref = helper.getServiceReferenceByName(org.apache.felix.ipojo.architecture.Architecture.class.getName(),
+ in);
assertNotNull(ref);
}
@@ -70,7 +74,7 @@
// Parses the retrieved description and find the component with the
// given name.
- List list = new ArrayList();
+ List<Element> list = new ArrayList<Element>();
try {
Element element = ManifestMetadataParser.parseHeaderMetadata(elem);
Element[] childs = element.getElements("instance");