Author: clement
Date: Sat Dec  7 07:09:31 2013
New Revision: 1548798

URL: http://svn.apache.org/r1548798
Log:
Fix FELIX-4340

Added:
    
felix/trunk/ipojo/manipulator/manipulator-it/online-manipulator-it/src/main/java/org/apache/felix/ipojo/test/online/components/MyProviderWithAnnotations.java
      - copied, changed from r1532285, 
felix/trunk/ipojo/manipulator/manipulator-it/online-manipulator-it/src/main/java/org/apache/felix/ipojo/test/online/components/MyProvider.java
Modified:
    
felix/trunk/ipojo/manipulator/manipulator-it/online-manipulator-it/src/test/java/org/apache/felix/ipojo/test/online/OnlineManipulatorTest.java
    
felix/trunk/ipojo/manipulator/online-manipulator/src/main/java/org/apache/felix/ipojo/online/manipulator/IPOJOURLHandler.java

Copied: 
felix/trunk/ipojo/manipulator/manipulator-it/online-manipulator-it/src/main/java/org/apache/felix/ipojo/test/online/components/MyProviderWithAnnotations.java
 (from r1532285, 
felix/trunk/ipojo/manipulator/manipulator-it/online-manipulator-it/src/main/java/org/apache/felix/ipojo/test/online/components/MyProvider.java)
URL: 
http://svn.apache.org/viewvc/felix/trunk/ipojo/manipulator/manipulator-it/online-manipulator-it/src/main/java/org/apache/felix/ipojo/test/online/components/MyProviderWithAnnotations.java?p2=felix/trunk/ipojo/manipulator/manipulator-it/online-manipulator-it/src/main/java/org/apache/felix/ipojo/test/online/components/MyProviderWithAnnotations.java&p1=felix/trunk/ipojo/manipulator/manipulator-it/online-manipulator-it/src/main/java/org/apache/felix/ipojo/test/online/components/MyProvider.java&r1=1532285&r2=1548798&rev=1548798&view=diff
==============================================================================
--- 
felix/trunk/ipojo/manipulator/manipulator-it/online-manipulator-it/src/main/java/org/apache/felix/ipojo/test/online/components/MyProvider.java
 (original)
+++ 
felix/trunk/ipojo/manipulator/manipulator-it/online-manipulator-it/src/main/java/org/apache/felix/ipojo/test/online/components/MyProviderWithAnnotations.java
 Sat Dec  7 07:09:31 2013
@@ -20,9 +20,15 @@
 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;
 
-public class MyProvider implements Hello {
+@Component
+@Provides
+@Instantiate
+public class MyProviderWithAnnotations implements Hello {
     
     public String sayHello() {
         return "Hello";

Modified: 
felix/trunk/ipojo/manipulator/manipulator-it/online-manipulator-it/src/test/java/org/apache/felix/ipojo/test/online/OnlineManipulatorTest.java
URL: 
http://svn.apache.org/viewvc/felix/trunk/ipojo/manipulator/manipulator-it/online-manipulator-it/src/test/java/org/apache/felix/ipojo/test/online/OnlineManipulatorTest.java?rev=1548798&r1=1548797&r2=1548798&view=diff
==============================================================================
--- 
felix/trunk/ipojo/manipulator/manipulator-it/online-manipulator-it/src/test/java/org/apache/felix/ipojo/test/online/OnlineManipulatorTest.java
 (original)
+++ 
felix/trunk/ipojo/manipulator/manipulator-it/online-manipulator-it/src/test/java/org/apache/felix/ipojo/test/online/OnlineManipulatorTest.java
 Sat Dec  7 07:09:31 2013
@@ -27,6 +27,7 @@ import org.apache.felix.ipojo.architectu
 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.Option;
 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.IOException;
 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 @@ public class OnlineManipulatorTest {
                 
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 @@ public class OnlineManipulatorTest {
     }
 
     @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 @@ public class OnlineManipulatorTest {
     }
 
     /**
+     * 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.
      *

Modified: 
felix/trunk/ipojo/manipulator/online-manipulator/src/main/java/org/apache/felix/ipojo/online/manipulator/IPOJOURLHandler.java
URL: 
http://svn.apache.org/viewvc/felix/trunk/ipojo/manipulator/online-manipulator/src/main/java/org/apache/felix/ipojo/online/manipulator/IPOJOURLHandler.java?rev=1548798&r1=1548797&r2=1548798&view=diff
==============================================================================
--- 
felix/trunk/ipojo/manipulator/online-manipulator/src/main/java/org/apache/felix/ipojo/online/manipulator/IPOJOURLHandler.java
 (original)
+++ 
felix/trunk/ipojo/manipulator/online-manipulator/src/main/java/org/apache/felix/ipojo/online/manipulator/IPOJOURLHandler.java
 Sat Dec  7 07:09:31 2013
@@ -141,22 +141,21 @@ public class IPOJOURLHandler
         // 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());


Reply via email to