Fix FELIX-4340
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1548798 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/ipojo/manipulator/manipulator-it/online-manipulator-it/src/main/java/org/apache/felix/ipojo/test/online/components/MyProviderWithAnnotations.java b/ipojo/manipulator/manipulator-it/online-manipulator-it/src/main/java/org/apache/felix/ipojo/test/online/components/MyProviderWithAnnotations.java
new file mode 100644
index 0000000..a7c7312
--- /dev/null
+++ b/ipojo/manipulator/manipulator-it/online-manipulator-it/src/main/java/org/apache/felix/ipojo/test/online/components/MyProviderWithAnnotations.java
@@ -0,0 +1,37 @@
+/*
+ * 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.ipojo.test.online.components;
+
+
+import org.apache.felix.ipojo.annotations.Component;
+import org.apache.felix.ipojo.annotations.Instantiate;
+import org.apache.felix.ipojo.annotations.Provides;
+import org.apache.felix.ipojo.test.online.services.Hello;
+
+@Component
+@Provides
+@Instantiate
+public class MyProviderWithAnnotations implements Hello {
+
+ public String sayHello() {
+ return "Hello";
+ }
+
+}
diff --git a/ipojo/manipulator/manipulator-it/online-manipulator-it/src/test/java/org/apache/felix/ipojo/test/online/OnlineManipulatorTest.java b/ipojo/manipulator/manipulator-it/online-manipulator-it/src/test/java/org/apache/felix/ipojo/test/online/OnlineManipulatorTest.java
index 262e1d7..5690f05 100644
--- a/ipojo/manipulator/manipulator-it/online-manipulator-it/src/test/java/org/apache/felix/ipojo/test/online/OnlineManipulatorTest.java
+++ b/ipojo/manipulator/manipulator-it/online-manipulator-it/src/test/java/org/apache/felix/ipojo/test/online/OnlineManipulatorTest.java
@@ -27,6 +27,7 @@
import org.apache.felix.ipojo.architecture.InstanceDescription;
import org.apache.felix.ipojo.test.online.components.Consumer;
import org.apache.felix.ipojo.test.online.components.MyProvider;
+import org.apache.felix.ipojo.test.online.components.MyProviderWithAnnotations;
import org.apache.felix.ipojo.test.online.services.Hello;
import org.junit.After;
import org.junit.Assert;
@@ -39,7 +40,6 @@
import org.ops4j.pax.exam.junit.PaxExam;
import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
import org.ops4j.pax.exam.spi.reactors.PerClass;
-import org.ops4j.pax.exam.spi.reactors.PerMethod;
import org.ops4j.pax.tinybundles.core.TinyBundles;
import org.osgi.framework.*;
import org.osgi.service.url.URLStreamHandlerService;
@@ -53,7 +53,6 @@
import java.io.InputStream;
import static org.ops4j.pax.exam.CoreOptions.*;
-import static org.ops4j.pax.exam.MavenUtils.asInProject;
@RunWith(PaxExam.class)
@@ -98,6 +97,7 @@
systemProperty("providerWithMetadata").value(providerWithMetadata),
systemProperty("providerWithMetadataInMetaInf").value(providerWithMetadataInMetaInf),
systemProperty("providerWithoutMetadata").value(providerWithoutMetadata),
+ systemProperty("providerUsingAnnotations").value(providerUsingAnnotation()),
systemProperty("consumerWithMetadata").value(consumerWithMetadata),
systemProperty("consumerWithoutMetadata").value(consumerWithoutMetadata),
@@ -189,6 +189,21 @@
}
@Test
+ public void installProviderUsingAnnotations() throws BundleException, InvalidSyntaxException, IOException {
+ String url = context.getProperty("providerUsingAnnotations");
+ Assert.assertNotNull(url);
+ Bundle bundle = context.installBundle("ipojo:" + url);
+ bundle.start();
+
+ assertBundle("Provider-with-annotations");
+ helper.waitForService(Hello.class.getName(), null, 5000);
+ assertValidity();
+ Assert.assertNotNull(context.getServiceReference(Hello.class.getName()));
+
+ bundle.uninstall();
+ }
+
+ @Test
public void installConsumerWithMetadata() throws BundleException, InvalidSyntaxException, IOException {
String url = context.getProperty("providerWithoutMetadata");
Assert.assertNotNull(url);
@@ -302,6 +317,27 @@
}
/**
+ * Gets a provider bundle which does not contain the metadata file and using annotations.
+ *
+ * @return the url of the bundle without metadata
+ * @throws java.io.IOException
+ */
+ public static String providerUsingAnnotation() throws IOException {
+ InputStream is = TinyBundles.bundle()
+ //.addResource("metadata.xml", this.getClass().getClassLoader().getResource("provider.xml"))
+ .add(MyProviderWithAnnotations.class)
+ .set(Constants.BUNDLE_SYMBOLICNAME, "Provider-with-annotations")
+ .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.test.online.services")
+ .build();
+
+ File out = getTemporaryFile("providerUsingAnnotations");
+ StreamUtils.copyStream(is, new FileOutputStream(out), true);
+ String url = out.toURI().toURL().toExternalForm();
+
+ return url;
+ }
+
+ /**
* Gets a consumer bundle using annotation containing the instance
* declaration in the metadata.
*
diff --git a/ipojo/manipulator/online-manipulator/src/main/java/org/apache/felix/ipojo/online/manipulator/IPOJOURLHandler.java b/ipojo/manipulator/online-manipulator/src/main/java/org/apache/felix/ipojo/online/manipulator/IPOJOURLHandler.java
index 786c20b..bd16ebf 100644
--- a/ipojo/manipulator/online-manipulator/src/main/java/org/apache/felix/ipojo/online/manipulator/IPOJOURLHandler.java
+++ b/ipojo/manipulator/online-manipulator/src/main/java/org/apache/felix/ipojo/online/manipulator/IPOJOURLHandler.java
@@ -141,22 +141,21 @@
// Pojoization
Pojoization pojoizator = new Pojoization();
File out = new File(m_temp, bundle.getName() + "-ipojo.jar");
- System.out.println("Pojoization " + bundle.exists() + " - " + metadata.exists());
try {
pojoizator.pojoization(bundle, out, metadata);
} catch (Exception e) {
if (!pojoizator.getErrors().isEmpty()) {
- throw new IOException("Errors occured during the manipulation : " + pojoizator.getErrors());
+ throw new IOException("Errors occurred during the manipulation : " + pojoizator.getErrors());
}
e.printStackTrace();
throw new RuntimeException(e.getMessage());
}
if (!pojoizator.getErrors().isEmpty()) {
- throw new IOException("Errors occured during the manipulation : " + pojoizator.getErrors());
+ throw new IOException("Errors occurred during the manipulation : " + pojoizator.getErrors());
}
if (!pojoizator.getWarnings().isEmpty()) {
- System.err.println("Warnings occured during the manipulation : " + pojoizator.getWarnings());
+ System.err.println("Warnings occurred during the manipulation : " + pojoizator.getWarnings());
}
System.out.println("Manipulation done : " + out.exists());