felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rickh...@apache.org
Subject svn commit: r1739941 - in /felix/trunk/bundlerepository/src: main/java/org/apache/felix/bundlerepository/impl/ test/java/org/apache/felix/bundlerepository/impl/ test/resources/
Date Tue, 19 Apr 2016 15:00:49 GMT
Author: rickhall
Date: Tue Apr 19 15:00:49 2016
New Revision: 1739941

URL: http://svn.apache.org/viewvc?rev=1739941&view=rev
Log:
Apply patch (FELIX-5196) to use case insensitive matching in requirements.

Modified:
    felix/trunk/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/DataModelHelperImpl.java
    felix/trunk/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/RequirementImpl.java
    felix/trunk/bundlerepository/src/test/java/org/apache/felix/bundlerepository/impl/DataModelHelperTest.java
    felix/trunk/bundlerepository/src/test/java/org/apache/felix/bundlerepository/impl/ResolverImplTest.java
    felix/trunk/bundlerepository/src/test/resources/spec_repository.xml

Modified: felix/trunk/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/DataModelHelperImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/DataModelHelperImpl.java?rev=1739941&r1=1739940&r2=1739941&view=diff
==============================================================================
--- felix/trunk/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/DataModelHelperImpl.java
(original)
+++ felix/trunk/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/DataModelHelperImpl.java
Tue Apr 19 15:00:49 2016
@@ -718,7 +718,7 @@ public class DataModelHelperImpl impleme
 
     private static CapabilityImpl createCapability(String name, Clause clause)
     {
-        CapabilityImpl capability = new CapabilityImpl(name);
+        CapabilityImpl capability = new CapabilityImpl(NamespaceTranslator.getFelixNamespace(name));
         capability.addProperty(name, clause.getName());
         capability.addProperty(Resource.VERSION, Property.VERSION, getVersion(clause));
         Attribute[] attributes = clause.getAttributes();

Modified: felix/trunk/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/RequirementImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/RequirementImpl.java?rev=1739941&r1=1739940&r2=1739941&view=diff
==============================================================================
--- felix/trunk/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/RequirementImpl.java
(original)
+++ felix/trunk/bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/RequirementImpl.java
Tue Apr 19 15:00:49 2016
@@ -18,12 +18,12 @@
  */
 package org.apache.felix.bundlerepository.impl;
 
-import java.util.Collections;
-import java.util.Map;
+import java.util.*;
 import java.util.regex.Pattern;
 
 import org.apache.felix.bundlerepository.Capability;
 import org.apache.felix.bundlerepository.Requirement;
+import org.apache.felix.utils.collections.MapToDictionary;
 import org.apache.felix.utils.filter.FilterImpl;
 import org.osgi.framework.InvalidSyntaxException;
 
@@ -106,8 +106,11 @@ public class RequirementImpl implements
 
     public boolean isSatisfied(Capability capability)
     {
-        return m_name.equals(capability.getName()) && m_filter.matchCase(capability.getPropertiesAsMap())
-                && (m_filter.toString().indexOf("(mandatory:<*") >= 0 || capability.getPropertiesAsMap().get("mandatory:")
== null);
+        Dictionary propertyDict = new MapToDictionary(capability.getPropertiesAsMap());
+
+        return m_name.equals(capability.getName()) &&
+                m_filter.match(propertyDict) &&
+                (m_filter.toString().contains("(mandatory:<*") || propertyDict.get("mandatory:")
== null);
     }
 
     public boolean isExtend()

Modified: felix/trunk/bundlerepository/src/test/java/org/apache/felix/bundlerepository/impl/DataModelHelperTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundlerepository/src/test/java/org/apache/felix/bundlerepository/impl/DataModelHelperTest.java?rev=1739941&r1=1739940&r2=1739941&view=diff
==============================================================================
--- felix/trunk/bundlerepository/src/test/java/org/apache/felix/bundlerepository/impl/DataModelHelperTest.java
(original)
+++ felix/trunk/bundlerepository/src/test/java/org/apache/felix/bundlerepository/impl/DataModelHelperTest.java
Tue Apr 19 15:00:49 2016
@@ -87,20 +87,26 @@ public class DataModelHelperTest extends
                 " org.osgi.service.component\";version:Version=\"1.3\",osgi.service;objectCl\n"
+
                 " ass:List<String>=\"org.osgi.service.component.runtime.ServiceComponentRu\n"
+
                 " ntime\";uses:=\"org.osgi.service.component.runtime\"");
+        attr.putValue("Export-Package", "test.package;version=\"1.0.0\"");
 
         Resource resource = dmh.createResource(attr);
 
-        assertEquals(3, resource.getCapabilities().length);
+        assertEquals(4, resource.getCapabilities().length);
 
         Capability bundleCap = null;
         Capability osgiExtenderCap = null;
         Capability osgiServiceCap = null;
+        Capability osgiPackageCap = null;
 
         for (Capability capability : resource.getCapabilities()) {
             if (capability.getName().equals("bundle")) {
                 bundleCap = capability;
             } else if (capability.getName().equals("osgi.extender")) {
                 osgiExtenderCap = capability;
+            } else if (capability.getName().equals("service")) {
+                osgiServiceCap = capability;
+            } else if (capability.getName().equals("package")) {
+                osgiPackageCap = capability;
             } else {
                 osgiServiceCap = capability;
             }
@@ -109,10 +115,15 @@ public class DataModelHelperTest extends
         assertNotNull(bundleCap);
         assertNotNull(osgiExtenderCap);
         assertNotNull(osgiServiceCap);
+        assertNotNull(osgiPackageCap);
 
         assertEquals("osgi.extender", osgiExtenderCap.getName());
         assertEquals("osgi.component", osgiExtenderCap.getPropertiesAsMap().get("osgi.extender"));
         assertEquals("1.3.0", osgiExtenderCap.getPropertiesAsMap().get(Constants.VERSION_ATTRIBUTE).toString());
+
+        assertEquals("service", osgiServiceCap.getName());
+
+        assertEquals("package", osgiPackageCap.getName());
     }
 
     public void testGzipResource() throws Exception {

Modified: felix/trunk/bundlerepository/src/test/java/org/apache/felix/bundlerepository/impl/ResolverImplTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundlerepository/src/test/java/org/apache/felix/bundlerepository/impl/ResolverImplTest.java?rev=1739941&r1=1739940&r2=1739941&view=diff
==============================================================================
--- felix/trunk/bundlerepository/src/test/java/org/apache/felix/bundlerepository/impl/ResolverImplTest.java
(original)
+++ felix/trunk/bundlerepository/src/test/java/org/apache/felix/bundlerepository/impl/ResolverImplTest.java
Tue Apr 19 15:00:49 2016
@@ -99,9 +99,24 @@ public class ResolverImplTest extends Te
         EasyMock.expect(resource.getURI()).andReturn("http://test.com").anyTimes();
         EasyMock.expect(resource.isLocal()).andReturn(true).anyTimes();
 
-        EasyMock.replay(resource);
+        // Create a Local Resource with a service capability
+        CapabilityImpl capability2 = new CapabilityImpl("service");
+        capability2.addProperty("objectClass", "org.some.other.interface");
+        capability2.addProperty("effective", "active");
+
+        org.apache.felix.bundlerepository.Capability[] capabilities2 = { capability2 };
+
+        Resource resource2 = EasyMock.createMock(Resource.class);
+        EasyMock.expect(resource2.getSymbolicName()).andReturn("com.test.bundleB").anyTimes();
+        EasyMock.expect(resource2.getRequirements()).andReturn(null).anyTimes();
+        EasyMock.expect(resource2.getCapabilities()).andReturn(capabilities2).anyTimes();
+        EasyMock.expect(resource2.getURI()).andReturn("http://test2.com").anyTimes();
+        EasyMock.expect(resource2.isLocal()).andReturn(true).anyTimes();
+
+        EasyMock.replay(resource, resource2);
 
         resolver.add(resource);
+        resolver.add(resource2);
 
         // Set the requirements to get the bundle
         RequirementImpl requirement = new RequirementImpl("foo");

Modified: felix/trunk/bundlerepository/src/test/resources/spec_repository.xml
URL: http://svn.apache.org/viewvc/felix/trunk/bundlerepository/src/test/resources/spec_repository.xml?rev=1739941&r1=1739940&r2=1739941&view=diff
==============================================================================
--- felix/trunk/bundlerepository/src/test/resources/spec_repository.xml (original)
+++ felix/trunk/bundlerepository/src/test/resources/spec_repository.xml Tue Apr 19 15:00:49
2016
@@ -40,6 +40,11 @@
       <attribute name='bundle-symbolic-name' value='org.apache.felix.bundlerepository.test_file_3'/>
       <attribute name='bundle-version' type='Version' value='1.2.3.something'/>
     </capability>
+      <capability namespace="osgi.service">
+          <attribute name="objectClass" type="List&lt;String&gt;" value="org.some.interface"/>
+          <attribute name="someProperty" value="someValue"/>
+          <attribute name="service.ranking" type="Long" value="10"/>
+      </capability>
     <requirement namespace='osgi.wiring.package'>
       <directive name='filter' value='(osgi.wiring.package=com.foo)'/>
     </requirement>
@@ -64,6 +69,14 @@
             <directive name="filter" value="(&amp;(osgi.extender=osgi.component)(version&gt;=1.0.0)(!(version&gt;=2.0.0)))"/>
             <directive name="effective" value="active"/>
         </requirement>
+        <requirement namespace="osgi.service">
+            <directive name="filter" value="(objectClass=org.some.interface)"/>
+            <directive name="effective" value="active"/>
+        </requirement>
+        <requirement namespace="osgi.service">
+            <directive name="filter" value="(objectClass=org.some.other.interface)"/>
+            <directive name="effective" value="active"/>
+        </requirement>
     </resource>
     <resource>
         <capability namespace='osgi.identity'>



Mime
View raw message