Author: jwross
Date: Tue Feb 23 20:48:57 2016
New Revision: 1731952

URL: http://svn.apache.org/viewvc?rev=1731952&view=rev
Log:
[ARIES-1417] Aries Subsystems implementation bundle must provide official 
capabilities

Note that I wasn't able to figure out how to get the new Provide-Capability to 
work with aries/parent/pom.xml so I copied the maven-bundle-plugin definition 
from
there to subsystem-core.

Plus test.

Added:
    
aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/defect/Aries1417Test.java
Modified:
    aries/trunk/subsystem/subsystem-core/pom.xml

Modified: aries/trunk/subsystem/subsystem-core/pom.xml
URL: 
http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-core/pom.xml?rev=1731952&r1=1731951&r2=1731952&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-core/pom.xml (original)
+++ aries/trunk/subsystem/subsystem-core/pom.xml Tue Feb 23 20:48:57 2016
@@ -56,6 +56,15 @@
             org.apache.aries.subsystem.core.*
         </aries.osgi.private.pkg>
         <lastReleaseVersion>1.0.0</lastReleaseVersion>
+        <aries.osgi.provide.capability>
+               osgi.implementation;
+                       osgi.implementation="osgi.subsystem";
+                       version:Version="1.1";
+                       uses:="org.osgi.service.subsystem",
+               osgi.service;
+                       
objectClass:List&lt;String&gt;="org.osgi.service.subsystem.Subsystem,org.apache.aries.subsystem.AriesSubsystem";
+                       
uses:="org.osgi.service.subsystem,org.apache.aries.subsystem"
+        </aries.osgi.provide.capability>
     </properties>
 
     <dependencies>
@@ -138,6 +147,36 @@
                     </execution>
                 </executions>
             </plugin>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <version>2.5.0</version>
+                <extensions>true</extensions>
+                <inherited>true</inherited>
+                <configuration>
+                    
<excludeDependencies>${aries.osgi.exclude.dependencies}</excludeDependencies>
+                    <instructions>
+                        <Bundle-Name>${project.name}</Bundle-Name>
+                        
<Bundle-SymbolicName>${aries.osgi.symbolic.name}</Bundle-SymbolicName>
+                        
<Bundle-Activator>${aries.osgi.activator}</Bundle-Activator>
+                        <Export-Package>${aries.osgi.export}</Export-Package>
+                        <Import-Package>${aries.osgi.import}</Import-Package>
+                        
<DynamicImport-Package>${aries.osgi.dynamic}</DynamicImport-Package>
+                        
<Private-Package>${aries.osgi.private.pkg}</Private-Package>
+                        <Implementation-Title>Apache 
Aries</Implementation-Title>
+                        
<Implementation-Version>${project.version}</Implementation-Version>
+                        <Bundle-Vendor>The Apache Software 
Foundation</Bundle-Vendor>
+                        
<Include-Resource>${aries.osgi.include.resource}</Include-Resource>
+                        
<_removeheaders>${aries.osgi.remove.headers}}</_removeheaders>
+                        <_failok>${aries.osgi.failok}</_failok>
+                        
<_consumer-policy>${aries.osgi.import.default.version}</_consumer-policy>
+                        
<_provider-policy>$&lt;range;[==,=+)&gt;</_provider-policy>
+                        
<Export-Service>${aries.osgi.export.service}</Export-Service>
+                        
<Import-Service>${aries.osgi.import.service}</Import-Service>
+                        
<Provide-Capability>${aries.osgi.provide.capability}</Provide-Capability>
+                    </instructions>
+                </configuration>
+            </plugin>
         </plugins>
     </build>
 

Added: 
aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/defect/Aries1417Test.java
URL: 
http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/defect/Aries1417Test.java?rev=1731952&view=auto
==============================================================================
--- 
aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/defect/Aries1417Test.java
 (added)
+++ 
aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/defect/Aries1417Test.java
 Tue Feb 23 20:48:57 2016
@@ -0,0 +1,73 @@
+/*
+ * 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.aries.subsystem.itests.defect;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.util.List;
+import java.util.Map;
+
+import org.apache.aries.subsystem.itests.SubsystemTest;
+import org.junit.Test;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.Version;
+import org.osgi.framework.wiring.BundleRevision;
+import org.osgi.namespace.implementation.ImplementationNamespace;
+import org.osgi.namespace.service.ServiceNamespace;
+import org.osgi.resource.Capability;
+
+public class Aries1417Test extends SubsystemTest {
+       @Test
+       public void testOsgiImplementation() throws Exception {
+               Bundle bundle = getSubsystemCoreBundle();
+               BundleRevision revision = bundle.adapt(BundleRevision.class);
+               List<Capability> capabilities = 
revision.getCapabilities(ImplementationNamespace.IMPLEMENTATION_NAMESPACE);
+               assertEquals("Wrong capabilities", 1, capabilities.size());
+               Capability capability = capabilities.get(0);
+               Map<String, Object> attributes = capability.getAttributes();
+               assertEquals("Wrong namespace value", "osgi.subsystem", 
attributes.get(ImplementationNamespace.IMPLEMENTATION_NAMESPACE));
+               Object version = 
attributes.get(ImplementationNamespace.CAPABILITY_VERSION_ATTRIBUTE);
+               assertTrue("Wrong version type", version instanceof Version);
+               assertEquals("Wrong version", Version.parseVersion("1.1"), 
version);
+               assertEquals("Wrong uses", "org.osgi.service.subsystem", 
capability.getDirectives().get(ImplementationNamespace.CAPABILITY_USES_DIRECTIVE));
+       }
+       
+       @Test
+       public void testOsgiService() throws Exception {
+               Bundle bundle = getSubsystemCoreBundle();
+               BundleRevision revision = bundle.adapt(BundleRevision.class);
+               List<Capability> capabilities = 
revision.getCapabilities(ServiceNamespace.SERVICE_NAMESPACE);
+               assertEquals("Wrong capabilities", 1, capabilities.size());
+               Capability capability = capabilities.get(0);
+               Map<String, Object> attributes = capability.getAttributes();
+               Object objectClass = 
attributes.get(ServiceNamespace.CAPABILITY_OBJECTCLASS_ATTRIBUTE);
+               assertTrue("Wrong objectClass type", objectClass instanceof 
List);
+               @SuppressWarnings({ "rawtypes" })
+               List objectClassList = (List)objectClass;
+               assertEquals("Wrong objectClass size", 2, 
objectClassList.size());
+               Object objectClass1 = objectClassList.get(0);
+               assertTrue("Wrong objectClass type", objectClass1 instanceof 
String);
+               assertEquals("Wrong objectClass", 
"org.osgi.service.subsystem.Subsystem", objectClass1);
+               Object objectClass2 = objectClassList.get(1);
+               assertTrue("Wrong objectClass type", objectClass2 instanceof 
String);
+               assertEquals("Wrong objectClass", 
"org.apache.aries.subsystem.AriesSubsystem", objectClass2);
+               assertEquals("Wrong uses", 
"org.osgi.service.subsystem,org.apache.aries.subsystem", 
capability.getDirectives().get(ServiceNamespace.CAPABILITY_USES_DIRECTIVE));
+       }
+}


Reply via email to