felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dav...@apache.org
Subject svn commit: r1657569 - in /felix/trunk/scr: pom.xml src/test/java/org/apache/felix/scr/integration/Felix4188Test.java
Date Thu, 05 Feb 2015 13:59:44 GMT
Author: davidb
Date: Thu Feb  5 13:59:44 2015
New Revision: 1657569

URL: http://svn.apache.org/r1657569
Log:
FELIX-4789 Fix for SCR Felix4188Test fails when run with framework 4.4.1 or newer

Also switched the framework used during the SCR integration tests to be 4.6.0

Modified:
    felix/trunk/scr/pom.xml
    felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/Felix4188Test.java

Modified: felix/trunk/scr/pom.xml
URL: http://svn.apache.org/viewvc/felix/trunk/scr/pom.xml?rev=1657569&r1=1657568&r2=1657569&view=diff
==============================================================================
--- felix/trunk/scr/pom.xml (original)
+++ felix/trunk/scr/pom.xml Thu Feb  5 13:59:44 2015
@@ -396,7 +396,7 @@
                 <dependency>
                     <groupId>org.apache.felix</groupId>
                     <artifactId>org.apache.felix.framework</artifactId>
-                    <version>4.0.2</version>
+                    <version>4.6.0</version>
                     <scope>test</scope>
                 </dependency>
             </dependencies>

Modified: felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/Felix4188Test.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/Felix4188Test.java?rev=1657569&r1=1657568&r2=1657569&view=diff
==============================================================================
--- felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/Felix4188Test.java (original)
+++ felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/Felix4188Test.java Thu
Feb  5 13:59:44 2015
@@ -18,6 +18,9 @@
  */
 package org.apache.felix.scr.integration;
 
+import static org.ops4j.pax.tinybundles.core.TinyBundles.bundle;
+import static org.ops4j.pax.tinybundles.core.TinyBundles.withBnd;
+
 import java.io.IOException;
 import java.io.InputStream;
 import java.lang.reflect.Field;
@@ -25,7 +28,9 @@ import java.util.concurrent.CountDownLat
 
 import javax.inject.Inject;
 
+import junit.framework.Assert;
 import junit.framework.TestCase;
+
 import org.apache.felix.scr.integration.components.felix4188.Felix4188Component;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -34,11 +39,10 @@ import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.BundleException;
 import org.osgi.framework.Constants;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceReference;
 import org.osgi.service.component.runtime.dto.ComponentConfigurationDTO;
 
-import static org.ops4j.pax.tinybundles.core.TinyBundles.bundle;
-import static org.ops4j.pax.tinybundles.core.TinyBundles.withBnd;
-
 /**
  * This test validates the FELIX-4188 issue.
  */
@@ -70,11 +74,11 @@ public class Felix4188Test extends Compo
 
         final ComponentConfigurationDTO aComp1 =
                 findComponentConfigurationByName( bundle1, "org.apache.felix.scr.integration.components.Felix4188Component-1",
ComponentConfigurationDTO.SATISFIED);
-        final Object aInst1 = getServiceFromConfiguration(aComp1, Felix4188Component.class);
+        final Object aInst1 = getServiceFromConfigurationInAllClassSpaces(aComp1, Felix4188Component.class.getName());
 
         final ComponentConfigurationDTO aComp2 =
                 findComponentConfigurationByName( bundle2, "org.apache.felix.scr.integration.components.Felix4188Component-2",
ComponentConfigurationDTO.SATISFIED);
-        final Object aInst2 = getServiceFromConfiguration(aComp2, Felix4188Component.class);
+        final Object aInst2 = getServiceFromConfigurationInAllClassSpaces(aComp2, Felix4188Component.class.getName());
 
         final CountDownLatch latch = new CountDownLatch(1);
 
@@ -112,6 +116,23 @@ public class Felix4188Test extends Compo
         return field.get(instance);
     }
 
+    // Note that this test installs two bundles both with the same class in it.
+    // This causes multiple class spaces to be created by the framework.
+    private Object getServiceFromConfigurationInAllClassSpaces( ComponentConfigurationDTO
dto, String clazz ) throws InvalidSyntaxException
+    {
+        long id = dto.id;
+        String filter = "(component.id=" + id + ")";
+        ServiceReference<?>[] srs;
+
+        srs = bundleContext.getAllServiceReferences(clazz, filter);
+        Assert.assertEquals(1, srs.length);
+        ServiceReference<?> sr = srs[0];
+        Object s = bundleContext.getService(sr);
+        Assert.assertNotNull(s);
+        return s;
+    }
+
+
     protected Bundle installBundle( final String descriptorFile, String componentPackage,
String symbolicname ) throws BundleException
     {
         final InputStream bundleStream = bundle()



Mime
View raw message