You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aries.apache.org by jw...@apache.org on 2015/09/19 04:24:21 UTC
svn commit: r1703937 - in /aries/trunk/subsystem/subsystem-obr/src:
main/java/org/apache/aries/subsystem/util/felix/
test/java/org/apache/aries/subsystem/obr/internal/
Author: jwross
Date: Sat Sep 19 02:24:20 2015
New Revision: 1703937
URL: http://svn.apache.org/viewvc?rev=1703937&view=rev
Log:
ARIES-1410 The FelixResourceAdapter does not return all capabilities when given a null namespace.
FelixResourceAdapter.patch from user Bas (baselzinga@gmail.com) applied.
Plus test.
Also, since ARIES-1244 exposed the org.apache.aries.subsystem.util.felix package, I suppose we need to track the package version.
So I added a packageinfo file and set the version to 1.0.1.
Added:
aries/trunk/subsystem/subsystem-obr/src/main/java/org/apache/aries/subsystem/util/felix/packageinfo (with props)
aries/trunk/subsystem/subsystem-obr/src/test/java/org/apache/aries/subsystem/obr/internal/FelixResourceAdapterTest.java
Modified:
aries/trunk/subsystem/subsystem-obr/src/main/java/org/apache/aries/subsystem/util/felix/FelixResourceAdapter.java
Modified: aries/trunk/subsystem/subsystem-obr/src/main/java/org/apache/aries/subsystem/util/felix/FelixResourceAdapter.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-obr/src/main/java/org/apache/aries/subsystem/util/felix/FelixResourceAdapter.java?rev=1703937&r1=1703936&r2=1703937&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-obr/src/main/java/org/apache/aries/subsystem/util/felix/FelixResourceAdapter.java (original)
+++ aries/trunk/subsystem/subsystem-obr/src/main/java/org/apache/aries/subsystem/util/felix/FelixResourceAdapter.java Sat Sep 19 02:24:20 2015
@@ -59,24 +59,31 @@ public class FelixResourceAdapter implem
}
public List<Capability> getCapabilities(String namespace) {
+ ArrayList<Capability> result = new ArrayList<Capability>();
namespace = NamespaceTranslator.translate(namespace);
if (namespace == null || namespace.equals(IdentityNamespace.IDENTITY_NAMESPACE)) {
- Capability c = new OsgiIdentityCapability(this, resource.getSymbolicName(), resource.getVersion());
- return Collections.singletonList(c);
+ result.add(new OsgiIdentityCapability(this, resource.getSymbolicName(), resource.getVersion()));
+ if (namespace != null) {
+ result.trimToSize();
+ return Collections.unmodifiableList(result);
+ }
}
// TODO Add to constants.
- if (namespace.equals("osgi.content")) {
- Capability c = new OsgiContentCapability(this, resource.getURI());
- return Collections.singletonList(c);
+ if (namespace == null || namespace.equals("osgi.content")) {
+ result.add(new OsgiContentCapability(this, resource.getURI()));
+ if (namespace != null) {
+ result.trimToSize();
+ return Collections.unmodifiableList(result);
+ }
}
org.apache.felix.bundlerepository.Capability[] capabilities = resource.getCapabilities();
- ArrayList<Capability> result = new ArrayList<Capability>(capabilities.length);
for (org.apache.felix.bundlerepository.Capability capability : capabilities) {
- if (namespace != null && !capability.getName().equals(namespace)) continue;
- result.add(new FelixCapabilityAdapter(capability, this));
+ if (namespace == null || capability.getName().equals(namespace)) {
+ result.add(new FelixCapabilityAdapter(capability, this));
+ }
}
result.trimToSize();
- return result;
+ return Collections.unmodifiableList(result);
}
@Override
Added: aries/trunk/subsystem/subsystem-obr/src/main/java/org/apache/aries/subsystem/util/felix/packageinfo
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-obr/src/main/java/org/apache/aries/subsystem/util/felix/packageinfo?rev=1703937&view=auto
==============================================================================
--- aries/trunk/subsystem/subsystem-obr/src/main/java/org/apache/aries/subsystem/util/felix/packageinfo (added)
+++ aries/trunk/subsystem/subsystem-obr/src/main/java/org/apache/aries/subsystem/util/felix/packageinfo Sat Sep 19 02:24:20 2015
@@ -0,0 +1,19 @@
+#
+# 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.
+#
+version 1.0.1
Propchange: aries/trunk/subsystem/subsystem-obr/src/main/java/org/apache/aries/subsystem/util/felix/packageinfo
------------------------------------------------------------------------------
svn:executable = *
Added: aries/trunk/subsystem/subsystem-obr/src/test/java/org/apache/aries/subsystem/obr/internal/FelixResourceAdapterTest.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-obr/src/test/java/org/apache/aries/subsystem/obr/internal/FelixResourceAdapterTest.java?rev=1703937&view=auto
==============================================================================
--- aries/trunk/subsystem/subsystem-obr/src/test/java/org/apache/aries/subsystem/obr/internal/FelixResourceAdapterTest.java (added)
+++ aries/trunk/subsystem/subsystem-obr/src/test/java/org/apache/aries/subsystem/obr/internal/FelixResourceAdapterTest.java Sat Sep 19 02:24:20 2015
@@ -0,0 +1,46 @@
+/*
+ * Licensed 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.aries.subsystem.obr.internal;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.aries.subsystem.util.felix.FelixResourceAdapter;
+import org.apache.felix.bundlerepository.Capability;
+import org.apache.felix.bundlerepository.Resource;
+import org.easymock.EasyMock;
+import org.junit.Test;
+
+public class FelixResourceAdapterTest {
+ @Test
+ public void testGetCapabilitiesWithNullNamespace() {
+ Resource resource = EasyMock.createNiceMock(Resource.class);
+ Capability capability = EasyMock.createNiceMock(Capability.class);
+ EasyMock.expect(capability.getName()).andReturn(Capability.PACKAGE);
+ Map<String, Object> properties = new HashMap<String, Object>();
+ properties.put(Capability.PACKAGE, "org.foo.bar");
+ EasyMock.expect(capability.getPropertiesAsMap()).andReturn(properties);
+ Capability[] capabilities = new Capability[] {
+ capability
+ };
+ EasyMock.expect(resource.getCapabilities()).andReturn(capabilities);
+ EasyMock.replay(resource);
+ FelixResourceAdapter adapter = new FelixResourceAdapter(resource);
+ List<org.osgi.resource.Capability> caps = adapter.getCapabilities(null);
+ assertEquals("Null namespace should return all capabilities", 3, caps.size());
+ }
+}