[jboss-osgi-commits] JBoss-OSGI SVN: r90336 - in projects/jboss-osgi/trunk/blueprint: impl/src/main/java/org/jboss/osgi/blueprint/reflect and 10 other directories.

jboss-osgi-commits at lists.jboss.org jboss-osgi-commits at lists.jboss.org
Wed Jun 17 11:22:09 EDT 2009


Author: thomas.diesler at jboss.com
Date: 2009-06-17 11:22:08 -0400 (Wed, 17 Jun 2009)
New Revision: 90336

Added:
   projects/jboss-osgi/trunk/blueprint/testsuite/src/test/java/org/jboss/test/osgi/blueprint/container/
   projects/jboss-osgi/trunk/blueprint/testsuite/src/test/java/org/jboss/test/osgi/blueprint/container/BlueprintContainerTestCase.java
   projects/jboss-osgi/trunk/blueprint/testsuite/src/test/java/org/jboss/test/osgi/blueprint/container/bundle/
   projects/jboss-osgi/trunk/blueprint/testsuite/src/test/resources/container/
   projects/jboss-osgi/trunk/blueprint/testsuite/src/test/resources/container/container-basic.bnd
Removed:
   projects/jboss-osgi/trunk/blueprint/testsuite/src/test/java/org/jboss/test/osgi/blueprint/context/BlueprintContextTestCase.java
   projects/jboss-osgi/trunk/blueprint/testsuite/src/test/java/org/jboss/test/osgi/blueprint/context/bundle/
   projects/jboss-osgi/trunk/blueprint/testsuite/src/test/resources/container/context-basic.bnd
   projects/jboss-osgi/trunk/blueprint/testsuite/src/test/resources/context/
Modified:
   projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/container/BlueprintContainerImpl.java
   projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/reflect/ServiceMetadataImpl.java
   projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/reflect/ServiceReferenceMetadataImpl.java
   projects/jboss-osgi/trunk/blueprint/impl/src/main/resources/schema/blueprint-jbxb.xsd
   projects/jboss-osgi/trunk/blueprint/testsuite/scripts/antrun-test-jars.xml
   projects/jboss-osgi/trunk/blueprint/testsuite/src/test/java/org/jboss/test/osgi/blueprint/container/bundle/BeanA.java
   projects/jboss-osgi/trunk/blueprint/testsuite/src/test/java/org/jboss/test/osgi/blueprint/container/bundle/BeanB.java
   projects/jboss-osgi/trunk/blueprint/testsuite/src/test/java/org/jboss/test/osgi/blueprint/container/bundle/ServiceA.java
   projects/jboss-osgi/trunk/blueprint/testsuite/src/test/java/org/jboss/test/osgi/blueprint/container/bundle/ServiceB.java
   projects/jboss-osgi/trunk/blueprint/testsuite/src/test/resources/container/OSGI-INF/blueprint/basic-service.xml
   projects/jboss-osgi/trunk/blueprint/testsuite/src/test/resources/parser/blueprint-all-elements.xml
Log:
Refactor after BP API update

Modified: projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/container/BlueprintContainerImpl.java
===================================================================
--- projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/container/BlueprintContainerImpl.java	2009-06-17 15:10:06 UTC (rev 90335)
+++ projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/container/BlueprintContainerImpl.java	2009-06-17 15:22:08 UTC (rev 90336)
@@ -26,6 +26,7 @@
 import java.net.URL;
 import java.util.Collection;
 import java.util.Enumeration;
+import java.util.Properties;
 import java.util.Set;
 
 import org.jboss.osgi.blueprint.parser.BlueprintParser;
@@ -34,6 +35,7 @@
 import org.jboss.osgi.spi.NotImplementedException;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
 import org.osgi.service.blueprint.container.BlueprintContainer;
 import org.osgi.service.blueprint.reflect.ComponentMetadata;
 import org.osgi.service.log.LogService;
@@ -64,6 +66,8 @@
 public class BlueprintContainerImpl implements BlueprintContainer 
 {
    public static final String HEADER_BUNDLE_BLUEPRINT = "Bundle-Blueprint";
+   public static final String PROPERTY_BLUEPRINT_BUNDLE_SYMBOLIC_NAME = "osgi.blueprint.container.symbolicname";
+   public static final String PROPERTY_BLUEPRINT_BUNDLE_VERSION = "osgi.blueprint.container.version";
    
    private LogService log;
    
@@ -81,9 +85,10 @@
 
    public void initialize()
    {
-      bpMetadata = getBlueprintMetadata(bundle);
+      bpMetadata = getBlueprintMetadata();
+      registerBlueprintContainerService();
    }
-   
+
    public BundleContext getBundleContext()
    {
       return bundle.getBundleContext();
@@ -115,7 +120,7 @@
    }
    
    @SuppressWarnings("unchecked")
-   private BlueprintMetadata getBlueprintMetadata(Bundle bundle)
+   private BlueprintMetadata getBlueprintMetadata()
    {
       BlueprintMetadata bpMetadata = null;
 
@@ -165,4 +170,15 @@
       BlueprintMetadata blueprint = new BlueprintParser().parse(descriptorURL);
       return blueprint;
    }
+   
+   private void registerBlueprintContainerService()
+   {
+      String symbolicName = bundle.getSymbolicName();
+      String version = (String)bundle.getHeaders().get(Constants.BUNDLE_VERSION);
+      
+      Properties props = new Properties();
+      props.setProperty(PROPERTY_BLUEPRINT_BUNDLE_SYMBOLIC_NAME, symbolicName);
+      props.setProperty(PROPERTY_BLUEPRINT_BUNDLE_VERSION, version);
+      context.registerService(BlueprintContainer.class.getName(), this, props);
+   }
 }
\ No newline at end of file

Modified: projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/reflect/ServiceMetadataImpl.java
===================================================================
--- projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/reflect/ServiceMetadataImpl.java	2009-06-17 15:10:06 UTC (rev 90335)
+++ projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/reflect/ServiceMetadataImpl.java	2009-06-17 15:22:08 UTC (rev 90336)
@@ -36,7 +36,6 @@
 import org.osgi.service.blueprint.reflect.RegistrationListener;
 import org.osgi.service.blueprint.reflect.ServiceMetadata;
 import org.osgi.service.blueprint.reflect.Target;
-import org.w3c.dom.Element;
 
 /**
  * Tservice is the type for services exported by this blueprint bundle. Services are sourced by either a <ref> to a <bean> component or an <inline> bean component.
@@ -51,10 +50,9 @@
    protected List<MapEntry> serviceProperties;
    protected Collection<RegistrationListener> registrationListener;
    protected BeanMetadataImpl bean;
-   protected RefImpl refFIXME;
    protected List<Object> any;
    protected String ref;
-   protected int autoExport;
+   protected AutoExportModes autoExportMode;
    protected int ranking;
    private Map<QName, String> otherAttributes = new HashMap<QName, String>();
 
@@ -91,6 +89,11 @@
       return interfaces;
    }
 
+   public void setInterfaces(List<String> interfaces)
+   {
+      this.interfaces = interfaces;
+   }
+
    /**
     * Gets the value of the serviceProperties property.
     */
@@ -146,46 +149,7 @@
    }
 
    /**
-    * Gets the value of the refFIXME property.
-    * 
-    * @return possible object is {@link RefImpl }
-    * 
-    */
-   public RefImpl getRefFIXME()
-   {
-      return refFIXME;
-   }
-
-   /**
-    * Sets the value of the refFIXME property.
-    * 
-    * @param value allowed object is {@link RefImpl }
-    * 
-    */
-   public void setRefFIXME(RefImpl value)
-   {
-      this.refFIXME = value;
-   }
-
-   /**
     * Gets the value of the any property.
-    * 
-    * <p>
-    * This accessor method returns a reference to the live list, not a snapshot. Therefore any modification you make to the returned list will be present inside the
-    * JAXB object. This is why there is not a <CODE>set</CODE> method for the any property.
-    * 
-    * <p>
-    * For example, to add a new item, do as follows:
-    * 
-    * <pre>
-    * getAny().add(newItem);
-    * </pre>
-    * 
-    * 
-    * <p>
-    * Objects of the following type(s) are allowed in the list {@link Object } {@link Element }
-    * 
-    * 
     */
    public List<Object> getAny()
    {
@@ -223,12 +187,12 @@
     * 
     * @return possible object is {@link AutoExportModes }
     */
-   public int getAutoExport()
+   public AutoExportModes getAutoExportMode()
    {
-      if (autoExport == 0)
-         autoExport = AUTO_EXPORT_DISABLED;
+      if (autoExportMode == null)
+         autoExportMode = AutoExportModes.DISABLED;
       
-      return autoExport;
+      return autoExportMode;
    }
 
    /**
@@ -236,11 +200,26 @@
     * 
     * @param value allowed object is {@link AutoExportModes }
     */
-   public void setAutoExport(int value)
+   public void setAutoExportMode(AutoExportModes value)
    {
-      this.autoExport = value;
+      this.autoExportMode = value;
    }
 
+   public int getAutoExport()
+   {
+      int modeValue = AUTO_EXPORT_DISABLED;
+      
+      AutoExportModes mode = getAutoExportMode();
+      if (mode == AutoExportModes.ALL_CLASSES)
+         modeValue =  AUTO_EXPORT_ALL_CLASSES;
+      else if (mode == AutoExportModes.CLASS_HIERARCHY)
+         modeValue =  AUTO_EXPORT_CLASS_HIERARCHY;
+      else if (mode == AutoExportModes.INTERFACES)
+         modeValue =  AUTO_EXPORT_INTERFACES;
+      
+      return modeValue;
+   }
+
    /**
     * Gets the value of the ranking property.
     */
@@ -259,14 +238,6 @@
 
    /**
     * Gets a map that contains attributes that aren't bound to any typed property on this class.
-    * 
-    * <p>
-    * the map is keyed by the name of the attribute and the value is the string value of the attribute.
-    * 
-    * the map returned by this method is live, and you can add new attribute by updating the map directly. Because of this design, there's no setter.
-    * 
-    * 
-    * @return always non-null
     */
    public Map<QName, String> getOtherAttributes()
    {
@@ -275,16 +246,6 @@
 
    // **********************************************************************
 
-   public int getAutoExportMode()
-   {
-      throw new NotImplementedException();
-   }
-
-   public List<String> getExplicitDependencies()
-   {
-      throw new NotImplementedException();
-   }
-
    public Target getServiceComponent()
    {
       throw new NotImplementedException();

Modified: projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/reflect/ServiceReferenceMetadataImpl.java
===================================================================
--- projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/reflect/ServiceReferenceMetadataImpl.java	2009-06-17 15:10:06 UTC (rev 90335)
+++ projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/reflect/ServiceReferenceMetadataImpl.java	2009-06-17 15:22:08 UTC (rev 90336)
@@ -30,7 +30,6 @@
 
 import javax.xml.namespace.QName;
 
-import org.jboss.osgi.spi.NotImplementedException;
 import org.osgi.service.blueprint.reflect.ReferenceListener;
 import org.osgi.service.blueprint.reflect.ServiceReferenceMetadata;
 
@@ -111,6 +110,20 @@
       return interfaces;
    }
 
+   public void setInterfaces(List<String> interfaces)
+   {
+      this.interfaces = interfaces;
+   }
+
+   public String getInterface()
+   {
+      List<String> interfaces = getInterfaces();
+      if (interfaces.size() == 0)
+         throw new IllegalStateException("Empty list of interfaces");
+
+      return interfaces.get(0);
+   }
+   
    /**
     * Gets the value of the listener property.
     */
@@ -210,22 +223,9 @@
 
    /**
     * Gets a map that contains attributes that aren't bound to any typed property on this class.
-    * 
-    * <p>
-    * the map is keyed by the name of the attribute and the value is the string value of the attribute.
-    * 
-    * the map returned by this method is live, and you can add new attribute by updating the map directly. Because of this design, there's no setter.
-    * 
-    * 
-    * @return always non-null
     */
    public Map<QName, String> getOtherAttributes()
    {
       return otherAttributes;
    }
-
-   public String getInterface()
-   {
-      throw new NotImplementedException();
-   }
 }

Modified: projects/jboss-osgi/trunk/blueprint/impl/src/main/resources/schema/blueprint-jbxb.xsd
===================================================================
--- projects/jboss-osgi/trunk/blueprint/impl/src/main/resources/schema/blueprint-jbxb.xsd	2009-06-17 15:10:06 UTC (rev 90335)
+++ projects/jboss-osgi/trunk/blueprint/impl/src/main/resources/schema/blueprint-jbxb.xsd	2009-06-17 15:22:08 UTC (rev 90336)
@@ -579,7 +579,7 @@
                 <xsd:attribute name="interface" use="optional" type="Tclass" >
                     <xsd:annotation>
                         <xsd:appinfo>
-                            <jbxb:property name="interfaceNames"/>
+                            <jbxb:property name="interfaces"/>
                         </xsd:appinfo>
                     </xsd:annotation>
                 </xsd:attribute>
@@ -712,7 +712,7 @@
                 <xsd:attribute name="interface" type="Tclass" use="optional" >
                     <xsd:annotation>
                         <xsd:appinfo>
-                            <jbxb:property name="interfaceNames"/>
+                            <jbxb:property name="interfaces"/>
                         </xsd:appinfo>
                     </xsd:annotation>
                 </xsd:attribute>
@@ -732,7 +732,13 @@
                         </xsd:documentation>
                     </xsd:annotation>
                 </xsd:attribute>
-                <xsd:attribute name="auto-export" type="TautoExportModes" default="disabled" />
+                <xsd:attribute name="auto-export" type="TautoExportModes" default="disabled" >
+                    <xsd:annotation>
+                        <xsd:appinfo>
+                            <jbxb:property name="autoExportMode"/>
+                        </xsd:appinfo>
+                    </xsd:annotation>
+                </xsd:attribute>
                 <xsd:attribute name="ranking" type="xsd:int" default="0">
                     <xsd:annotation>
                         <xsd:documentation>
@@ -1107,7 +1113,7 @@
             <xsd:element name="value" type="TinterfaceValue" >
                 <xsd:annotation>
                     <xsd:appinfo>
-                        <jbxb:property name="interfaceNames"/>
+                        <jbxb:property name="interfaces"/>
                     </xsd:appinfo>
                 </xsd:annotation>
             </xsd:element>

Modified: projects/jboss-osgi/trunk/blueprint/testsuite/scripts/antrun-test-jars.xml
===================================================================
--- projects/jboss-osgi/trunk/blueprint/testsuite/scripts/antrun-test-jars.xml	2009-06-17 15:10:06 UTC (rev 90335)
+++ projects/jboss-osgi/trunk/blueprint/testsuite/scripts/antrun-test-jars.xml	2009-06-17 15:22:08 UTC (rev 90336)
@@ -43,7 +43,7 @@
     <!-- Please add alphabetically -->
 
     <!-- context -->
-    <bnd classpath="${tests.classes.dir}" output="${tests.output.dir}/test-libs/context-basic.jar" files="${tests.resources.dir}/context/context-basic.bnd" />
+    <bnd classpath="${tests.classes.dir}" output="${tests.output.dir}/test-libs/container-basic.jar" files="${tests.resources.dir}/container/container-basic.bnd" />
 
     <!-- Please add alphabetically -->
 

Copied: projects/jboss-osgi/trunk/blueprint/testsuite/src/test/java/org/jboss/test/osgi/blueprint/container/BlueprintContainerTestCase.java (from rev 90334, projects/jboss-osgi/trunk/blueprint/testsuite/src/test/java/org/jboss/test/osgi/blueprint/context/BlueprintContextTestCase.java)
===================================================================
--- projects/jboss-osgi/trunk/blueprint/testsuite/src/test/java/org/jboss/test/osgi/blueprint/container/BlueprintContainerTestCase.java	                        (rev 0)
+++ projects/jboss-osgi/trunk/blueprint/testsuite/src/test/java/org/jboss/test/osgi/blueprint/container/BlueprintContainerTestCase.java	2009-06-17 15:22:08 UTC (rev 90336)
@@ -0,0 +1,270 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.osgi.blueprint.container;
+
+//$Id$
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assume.assumeNotNull;
+
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import javax.management.MBeanServer;
+
+import org.jboss.osgi.husky.Bridge;
+import org.jboss.osgi.husky.BridgeFactory;
+import org.jboss.osgi.husky.annotation.ProvideContext;
+import org.jboss.osgi.spi.capability.BlueprintCapability;
+import org.jboss.osgi.spi.capability.HuskyCapability;
+import org.jboss.osgi.spi.capability.MicrocontainerCapability;
+import org.jboss.osgi.spi.testing.OSGiBundle;
+import org.jboss.osgi.spi.testing.OSGiRuntime;
+import org.jboss.osgi.spi.testing.OSGiTestHelper;
+import org.jboss.test.osgi.blueprint.container.bundle.BeanA;
+import org.jboss.test.osgi.blueprint.container.bundle.ServiceA;
+import org.jboss.test.osgi.blueprint.container.bundle.ServiceB;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.blueprint.container.BlueprintContainer;
+import org.osgi.service.blueprint.reflect.BeanMetadata;
+import org.osgi.service.blueprint.reflect.ComponentMetadata;
+import org.osgi.service.blueprint.reflect.ServiceMetadata;
+import org.osgi.service.blueprint.reflect.ServiceReferenceMetadata;
+
+/**
+ * BlueprintContainer API tests
+ * 
+ * @author thomas.diesler at jboss.com
+ * @since 13-May-2009
+ */
+public class BlueprintContainerTestCase
+{
+   @ProvideContext
+   public static BundleContext context;
+
+   private static OSGiRuntime runtime;
+   private static Bridge huskyBridge;
+
+   @BeforeClass
+   public static void beforeClass() throws Exception
+   {
+      if (context == null)
+      {
+         runtime = new OSGiTestHelper().getDefaultRuntime();
+         runtime.addCapability(new HuskyCapability());
+         runtime.addCapability(new MicrocontainerCapability());
+         runtime.addCapability(new BlueprintCapability());
+         
+         huskyBridge = BridgeFactory.getBridge();
+         
+         OSGiBundle bundle = runtime.installBundle("container-basic.jar");
+         bundle.start();
+      }
+   }
+
+   @AfterClass
+   public static void afterClass() throws Exception
+   {
+      if (context == null)
+         runtime.shutdown();
+   }
+
+   @Test
+   public void testBlueprintBundleInstall() throws Exception
+   {
+      if (context == null)
+         huskyBridge.run();
+      
+      assumeNotNull(context);
+      
+      Bundle bundle = context.getBundle();
+      assertEquals("container-basic", bundle.getSymbolicName());
+   }
+
+   @Test
+   public void testBlueprintContextAvailable() throws Exception
+   {
+      if (context == null)
+         huskyBridge.run();
+      
+      assumeNotNull(context);
+      
+      BlueprintContainer bpContext = getBlueprintContainer();
+      assertNotNull("BlueprintContainer available", bpContext);
+   }
+
+
+   @Test
+   public void getBeanComponentsMetadata() throws Exception
+   {
+      if (context == null)
+         huskyBridge.run();
+      
+      assumeNotNull(context);
+      
+      BlueprintContainer bpContext = getBlueprintContainer();
+      Collection<BeanMetadata> bcMetadata = bpContext.getMetadata(BeanMetadata.class);
+      
+      assertNotNull("BeanComponentsMetadata not null", bcMetadata);
+      assertEquals("BeanComponentsMetadata size", 1, bcMetadata.size());
+      
+      BeanMetadata bmd = bcMetadata.iterator().next();
+      assertEquals("beanA", bmd.getId());
+      assertEquals(BeanA.class.getName(), bmd.getClassName());
+   }
+
+   @Test
+   public void getBundleContext() throws Exception
+   {
+      if (context == null)
+         huskyBridge.run();
+      
+      assumeNotNull(context);
+      
+      BlueprintContainer bpContext = getBlueprintContainer();
+      BundleContext bndContext = bpContext.getBundleContext();
+      
+      assertNotNull("BundleContext not null", bndContext);
+      assertEquals("BundleContext equals", context, bndContext);
+   }
+
+
+   @Test
+   @Ignore
+   public void getComponent() throws Exception
+   {
+      if (context == null)
+         huskyBridge.run();
+      
+      assumeNotNull(context);
+      
+      BlueprintContainer bpContext = getBlueprintContainer();
+      bpContext.getComponentInstance("beanA");
+   }
+
+   @Test
+   public void getComponentMetadata() throws Exception
+   {
+      if (context == null)
+         huskyBridge.run();
+      
+      assumeNotNull(context);
+      
+      BlueprintContainer bpContext = getBlueprintContainer();
+      ComponentMetadata compMetadata = bpContext.getComponentMetadata("beanA");
+      
+      assertNotNull("ComponentMetadata not null", compMetadata);
+      assertEquals("beanA", compMetadata.getId());
+   }
+
+   @Test
+   public void getComponentNames() throws Exception
+   {
+      if (context == null)
+         huskyBridge.run();
+      
+      assumeNotNull(context);
+      
+      BlueprintContainer bpContext = getBlueprintContainer();
+      Set<String> compNames = bpContext.getComponentIds();
+
+      assertNotNull("ComponentNames not null", compNames);
+      assertEquals("ComponentNames size", 4, compNames.size());
+      assertTrue("ComponentNames contains beanA", compNames.contains("beanA"));
+      assertTrue("ComponentNames contains serviceA", compNames.contains("serviceA"));
+      assertTrue("ComponentNames contains serviceB", compNames.contains("serviceB"));
+      assertTrue("ComponentNames contains mbeanService", compNames.contains("mbeanService"));
+   }
+
+   @Test
+   public void getExportedServicesMetadata() throws Exception
+   {
+      if (context == null)
+         huskyBridge.run();
+      
+      assumeNotNull(context);
+      
+      BlueprintContainer bpContext = getBlueprintContainer();
+      Collection<ServiceMetadata> servicesMetadata = bpContext.getMetadata(ServiceMetadata.class);
+
+      assertNotNull("ServiceMetadata not null", servicesMetadata);
+      assertEquals("ServiceMetadata size", 2, servicesMetadata.size());
+      
+      Iterator<ServiceMetadata> itServices = servicesMetadata.iterator();
+      ServiceMetadata serviceA = itServices.next();
+      assertEquals("serviceA", serviceA.getId());
+      
+      List<String> interfaceNamesA = serviceA.getInterfaces();
+      assertNotNull("InterfaceNames not null", interfaceNamesA);
+      assertEquals("InterfaceNames size", 1, interfaceNamesA.size());
+      assertEquals("InterfaceName", ServiceA.class.getName(), interfaceNamesA.get(0));
+      
+      ServiceMetadata serviceB = itServices.next();
+      assertEquals("serviceB", serviceB.getId());
+      
+      List<String> interfaceNamesB = serviceB.getInterfaces();
+      assertNotNull("InterfaceNames not null", interfaceNamesB);
+      assertEquals("InterfaceNames size", 1, interfaceNamesB.size());
+      assertEquals("InterfaceName", ServiceB.class.getName(), interfaceNamesB.get(0));
+   }
+
+   @Test
+   public void getReferencedServicesMetadata() throws Exception
+   {
+      if (context == null)
+         huskyBridge.run();
+      
+      assumeNotNull(context);
+      
+      BlueprintContainer bpContext = getBlueprintContainer();
+      Collection<ServiceReferenceMetadata> srefsMetadata = bpContext.getMetadata(ServiceReferenceMetadata.class);
+
+      assertNotNull("ServiceReferenceMetadata not null", srefsMetadata);
+      assertEquals("ServiceReferenceMetadata size", 1, srefsMetadata.size());
+      
+      ServiceReferenceMetadata srefMetadata = srefsMetadata.iterator().next();
+      assertEquals("mbeanService", srefMetadata.getId());
+      
+      String interfaceName = srefMetadata.getInterface();
+      assertNotNull("InterfaceName not null", interfaceName);
+      assertEquals("InterfaceName", MBeanServer.class.getName(), interfaceName);
+   }
+
+   private BlueprintContainer getBlueprintContainer()
+   {
+      ServiceReference sref = context.getServiceReference(BlueprintContainer.class.getName());
+      assertNotNull("BlueprintContainer service not null", sref);
+      
+      BlueprintContainer bpContext = (BlueprintContainer)context.getService(sref);
+      return bpContext;
+   }
+}
\ No newline at end of file

Copied: projects/jboss-osgi/trunk/blueprint/testsuite/src/test/java/org/jboss/test/osgi/blueprint/container/bundle (from rev 90334, projects/jboss-osgi/trunk/blueprint/testsuite/src/test/java/org/jboss/test/osgi/blueprint/context/bundle)

Modified: projects/jboss-osgi/trunk/blueprint/testsuite/src/test/java/org/jboss/test/osgi/blueprint/container/bundle/BeanA.java
===================================================================
--- projects/jboss-osgi/trunk/blueprint/testsuite/src/test/java/org/jboss/test/osgi/blueprint/context/bundle/BeanA.java	2009-06-17 14:36:03 UTC (rev 90334)
+++ projects/jboss-osgi/trunk/blueprint/testsuite/src/test/java/org/jboss/test/osgi/blueprint/container/bundle/BeanA.java	2009-06-17 15:22:08 UTC (rev 90336)
@@ -19,7 +19,7 @@
  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  */
-package org.jboss.test.osgi.blueprint.context.bundle;
+package org.jboss.test.osgi.blueprint.container.bundle;
 
 import javax.management.MBeanServer;
 

Modified: projects/jboss-osgi/trunk/blueprint/testsuite/src/test/java/org/jboss/test/osgi/blueprint/container/bundle/BeanB.java
===================================================================
--- projects/jboss-osgi/trunk/blueprint/testsuite/src/test/java/org/jboss/test/osgi/blueprint/context/bundle/BeanB.java	2009-06-17 14:36:03 UTC (rev 90334)
+++ projects/jboss-osgi/trunk/blueprint/testsuite/src/test/java/org/jboss/test/osgi/blueprint/container/bundle/BeanB.java	2009-06-17 15:22:08 UTC (rev 90336)
@@ -19,7 +19,7 @@
  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  */
-package org.jboss.test.osgi.blueprint.context.bundle;
+package org.jboss.test.osgi.blueprint.container.bundle;
 
 
 //$Id$

Modified: projects/jboss-osgi/trunk/blueprint/testsuite/src/test/java/org/jboss/test/osgi/blueprint/container/bundle/ServiceA.java
===================================================================
--- projects/jboss-osgi/trunk/blueprint/testsuite/src/test/java/org/jboss/test/osgi/blueprint/context/bundle/ServiceA.java	2009-06-17 14:36:03 UTC (rev 90334)
+++ projects/jboss-osgi/trunk/blueprint/testsuite/src/test/java/org/jboss/test/osgi/blueprint/container/bundle/ServiceA.java	2009-06-17 15:22:08 UTC (rev 90336)
@@ -19,7 +19,7 @@
  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  */
-package org.jboss.test.osgi.blueprint.context.bundle;
+package org.jboss.test.osgi.blueprint.container.bundle;
 
 //$Id$
 

Modified: projects/jboss-osgi/trunk/blueprint/testsuite/src/test/java/org/jboss/test/osgi/blueprint/container/bundle/ServiceB.java
===================================================================
--- projects/jboss-osgi/trunk/blueprint/testsuite/src/test/java/org/jboss/test/osgi/blueprint/context/bundle/ServiceB.java	2009-06-17 14:36:03 UTC (rev 90334)
+++ projects/jboss-osgi/trunk/blueprint/testsuite/src/test/java/org/jboss/test/osgi/blueprint/container/bundle/ServiceB.java	2009-06-17 15:22:08 UTC (rev 90336)
@@ -19,7 +19,7 @@
  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  */
-package org.jboss.test.osgi.blueprint.context.bundle;
+package org.jboss.test.osgi.blueprint.container.bundle;
 
 //$Id$
 

Deleted: projects/jboss-osgi/trunk/blueprint/testsuite/src/test/java/org/jboss/test/osgi/blueprint/context/BlueprintContextTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/blueprint/testsuite/src/test/java/org/jboss/test/osgi/blueprint/context/BlueprintContextTestCase.java	2009-06-17 15:10:06 UTC (rev 90335)
+++ projects/jboss-osgi/trunk/blueprint/testsuite/src/test/java/org/jboss/test/osgi/blueprint/context/BlueprintContextTestCase.java	2009-06-17 15:22:08 UTC (rev 90336)
@@ -1,268 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.test.osgi.blueprint.context;
-
-//$Id$
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assume.assumeNotNull;
-
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
-import javax.management.MBeanServer;
-
-import org.jboss.osgi.husky.Bridge;
-import org.jboss.osgi.husky.BridgeFactory;
-import org.jboss.osgi.husky.annotation.ProvideContext;
-import org.jboss.osgi.spi.capability.BlueprintCapability;
-import org.jboss.osgi.spi.capability.HuskyCapability;
-import org.jboss.osgi.spi.capability.MicrocontainerCapability;
-import org.jboss.osgi.spi.testing.OSGiBundle;
-import org.jboss.osgi.spi.testing.OSGiRuntime;
-import org.jboss.osgi.spi.testing.OSGiTestHelper;
-import org.jboss.test.osgi.blueprint.context.bundle.BeanA;
-import org.jboss.test.osgi.blueprint.context.bundle.ServiceA;
-import org.jboss.test.osgi.blueprint.context.bundle.ServiceB;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.blueprint.container.BlueprintContainer;
-import org.osgi.service.blueprint.reflect.BeanMetadata;
-import org.osgi.service.blueprint.reflect.ComponentMetadata;
-import org.osgi.service.blueprint.reflect.ServiceMetadata;
-import org.osgi.service.blueprint.reflect.ServiceReferenceMetadata;
-
-/**
- * BlueprintContainer API tests
- * 
- * @author thomas.diesler at jboss.com
- * @since 13-May-2009
- */
-public class BlueprintContextTestCase
-{
-   @ProvideContext
-   public static BundleContext context;
-
-   private static OSGiRuntime runtime;
-   private static Bridge huskyBridge;
-
-   @BeforeClass
-   public static void beforeClass() throws Exception
-   {
-      if (context == null)
-      {
-         runtime = new OSGiTestHelper().getDefaultRuntime();
-         runtime.addCapability(new HuskyCapability());
-         runtime.addCapability(new MicrocontainerCapability());
-         runtime.addCapability(new BlueprintCapability());
-         
-         huskyBridge = BridgeFactory.getBridge();
-         
-         OSGiBundle bundle = runtime.installBundle("context-basic.jar");
-         bundle.start();
-      }
-   }
-
-   @AfterClass
-   public static void afterClass() throws Exception
-   {
-      if (context == null)
-         runtime.shutdown();
-   }
-
-   @Test
-   public void testBlueprintBundleInstall() throws Exception
-   {
-      if (context == null)
-         huskyBridge.run();
-      
-      assumeNotNull(context);
-      
-      Bundle bundle = context.getBundle();
-      assertEquals("context-basic", bundle.getSymbolicName());
-   }
-
-   @Test
-   public void testBlueprintContextAvailable() throws Exception
-   {
-      if (context == null)
-         huskyBridge.run();
-      
-      assumeNotNull(context);
-      
-      BlueprintContainer bpContext = getBlueprintContext();
-      assertNotNull("BlueprintContainer available", bpContext);
-   }
-
-
-   @Test
-   public void getBeanComponentsMetadata() throws Exception
-   {
-      if (context == null)
-         huskyBridge.run();
-      
-      assumeNotNull(context);
-      
-      BlueprintContainer bpContext = getBlueprintContext();
-      Collection<BeanMetadata> bcMetadata = bpContext.getMetadata(BeanMetadata.class);
-      
-      assertNotNull("BeanComponentsMetadata not null", bcMetadata);
-      assertEquals("BeanComponentsMetadata size", 1, bcMetadata.size());
-      
-      BeanMetadata bmd = bcMetadata.iterator().next();
-      assertEquals("beanA", bmd.getId());
-      assertEquals(BeanA.class.getName(), bmd.getClassName());
-   }
-
-   @Test
-   public void getBundleContext() throws Exception
-   {
-      if (context == null)
-         huskyBridge.run();
-      
-      assumeNotNull(context);
-      
-      BlueprintContainer bpContext = getBlueprintContext();
-      BundleContext bndContext = bpContext.getBundleContext();
-      
-      assertNotNull("BundleContext not null", bndContext);
-      assertEquals("BundleContext equals", context, bndContext);
-   }
-
-
-   @Test
-   @Ignore
-   public void getComponent() throws Exception
-   {
-      if (context == null)
-         huskyBridge.run();
-      
-      assumeNotNull(context);
-      
-      BlueprintContainer bpContext = getBlueprintContext();
-      bpContext.getComponentInstance("beanA");
-   }
-
-   @Test
-   public void getComponentMetadata() throws Exception
-   {
-      if (context == null)
-         huskyBridge.run();
-      
-      assumeNotNull(context);
-      
-      BlueprintContainer bpContext = getBlueprintContext();
-      ComponentMetadata compMetadata = bpContext.getComponentMetadata("beanA");
-      
-      assertNotNull("ComponentMetadata not null", compMetadata);
-      assertEquals("beanA", compMetadata.getId());
-   }
-
-   @Test
-   public void getComponentNames() throws Exception
-   {
-      if (context == null)
-         huskyBridge.run();
-      
-      assumeNotNull(context);
-      
-      BlueprintContainer bpContext = getBlueprintContext();
-      Set<String> compNames = bpContext.getComponentIds();
-
-      assertNotNull("ComponentNames not null", compNames);
-      assertEquals("ComponentNames size", 4, compNames.size());
-      assertTrue("ComponentNames contains beanA", compNames.contains("beanA"));
-      assertTrue("ComponentNames contains serviceA", compNames.contains("serviceA"));
-      assertTrue("ComponentNames contains serviceB", compNames.contains("serviceB"));
-      assertTrue("ComponentNames contains mbeanService", compNames.contains("mbeanService"));
-   }
-
-   @Test
-   public void getExportedServicesMetadata() throws Exception
-   {
-      if (context == null)
-         huskyBridge.run();
-      
-      assumeNotNull(context);
-      
-      BlueprintContainer bpContext = getBlueprintContext();
-      Collection<ServiceMetadata> servicesMetadata = bpContext.getMetadata(ServiceMetadata.class);
-
-      assertNotNull("ServiceMetadata not null", servicesMetadata);
-      assertEquals("ServiceMetadata size", 2, servicesMetadata.size());
-      
-      Iterator<ServiceMetadata> itServices = servicesMetadata.iterator();
-      ServiceMetadata serviceA = itServices.next();
-      assertEquals("serviceA", serviceA.getId());
-      
-      List<String> interfaceNamesA = serviceA.getInterfaces();
-      assertNotNull("InterfaceNames not null", interfaceNamesA);
-      assertEquals("InterfaceNames size", 1, interfaceNamesA.size());
-      assertEquals("InterfaceName", ServiceA.class.getName(), interfaceNamesA.get(0));
-      
-      ServiceMetadata serviceB = itServices.next();
-      assertEquals("serviceB", serviceB.getId());
-      
-      List<String> interfaceNamesB = serviceB.getInterfaces();
-      assertNotNull("InterfaceNames not null", interfaceNamesB);
-      assertEquals("InterfaceNames size", 1, interfaceNamesB.size());
-      assertEquals("InterfaceName", ServiceB.class.getName(), interfaceNamesB.get(0));
-   }
-
-   @Test
-   public void getReferencedServicesMetadata() throws Exception
-   {
-      if (context == null)
-         huskyBridge.run();
-      
-      assumeNotNull(context);
-      
-      BlueprintContainer bpContext = getBlueprintContext();
-      Collection<ServiceReferenceMetadata> srefsMetadata = bpContext.getMetadata(ServiceReferenceMetadata.class);
-
-      assertNotNull("ServiceReferenceMetadata not null", srefsMetadata);
-      assertEquals("ServiceReferenceMetadata size", 1, srefsMetadata.size());
-      
-      ServiceReferenceMetadata srefMetadata = srefsMetadata.iterator().next();
-      assertEquals("mbeanService", srefMetadata.getId());
-      
-      String interfaceName = srefMetadata.getInterface();
-      assertNotNull("InterfaceName not null", interfaceName);
-      assertEquals("InterfaceName", MBeanServer.class.getName(), interfaceName);
-   }
-
-   private BlueprintContainer getBlueprintContext()
-   {
-      ServiceReference sref = context.getServiceReference(BlueprintContainer.class.getName());
-      BlueprintContainer bpContext = (BlueprintContainer)context.getService(sref);
-      return bpContext;
-   }
-}
\ No newline at end of file

Copied: projects/jboss-osgi/trunk/blueprint/testsuite/src/test/resources/container (from rev 90334, projects/jboss-osgi/trunk/blueprint/testsuite/src/test/resources/context)

Modified: projects/jboss-osgi/trunk/blueprint/testsuite/src/test/resources/container/OSGI-INF/blueprint/basic-service.xml
===================================================================
--- projects/jboss-osgi/trunk/blueprint/testsuite/src/test/resources/context/OSGI-INF/blueprint/basic-service.xml	2009-06-17 14:36:03 UTC (rev 90334)
+++ projects/jboss-osgi/trunk/blueprint/testsuite/src/test/resources/container/OSGI-INF/blueprint/basic-service.xml	2009-06-17 15:22:08 UTC (rev 90336)
@@ -1,15 +1,15 @@
 <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
   xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd schema/blueprint.xsd">
   
-  <bean id="beanA" class="org.jboss.test.osgi.blueprint.context.bundle.BeanA">
+  <bean id="beanA" class="org.jboss.test.osgi.blueprint.container.bundle.BeanA">
     <property name="mbeanServer" ref="mbeanService"/>
   </bean>
   
-  <service id="serviceA" ref="beanA" interface="org.jboss.test.osgi.blueprint.context.bundle.ServiceA">
+  <service id="serviceA" ref="beanA" interface="org.jboss.test.osgi.blueprint.container.bundle.ServiceA">
   </service>
   
-  <service id="serviceB" interface="org.jboss.test.osgi.blueprint.context.bundle.ServiceB">
-    <bean class="org.jboss.test.osgi.blueprint.context.bundle.BeanB"/>
+  <service id="serviceB" interface="org.jboss.test.osgi.blueprint.container.bundle.ServiceB">
+    <bean class="org.jboss.test.osgi.blueprint.container.bundle.BeanB"/>
   </service>
   
   <reference id="mbeanService" interface="javax.management.MBeanServer"/>

Copied: projects/jboss-osgi/trunk/blueprint/testsuite/src/test/resources/container/container-basic.bnd (from rev 90334, projects/jboss-osgi/trunk/blueprint/testsuite/src/test/resources/context/context-basic.bnd)
===================================================================
--- projects/jboss-osgi/trunk/blueprint/testsuite/src/test/resources/container/container-basic.bnd	                        (rev 0)
+++ projects/jboss-osgi/trunk/blueprint/testsuite/src/test/resources/container/container-basic.bnd	2009-06-17 15:22:08 UTC (rev 90336)
@@ -0,0 +1,24 @@
+# bnd build -classpath target/test-classes -output target/test-libs/container-basic.jar src/test/resources/container/container-basic.bnd
+
+Bundle-SymbolicName: container-basic
+
+Export-Package: org.jboss.test.osgi.blueprint.container
+
+Private-Package: org.jboss.test.osgi.blueprint.container.bundle
+
+Import-Package: \
+	javax.management, \
+	org.jboss.osgi.husky, \
+	org.jboss.osgi.husky.annotation, \
+	org.jboss.osgi.spi.capability, \
+	org.jboss.osgi.spi.testing, \
+	org.junit, \
+	org.osgi.framework, \
+	org.osgi.service.blueprint.* 
+
+Include-Resource: \
+	OSGI-INF/blueprint=OSGI-INF/blueprint
+
+Test-Package: org.jboss.test.osgi.blueprint.container
+
+-removeheaders: Include-Resource

Deleted: projects/jboss-osgi/trunk/blueprint/testsuite/src/test/resources/container/context-basic.bnd
===================================================================
--- projects/jboss-osgi/trunk/blueprint/testsuite/src/test/resources/context/context-basic.bnd	2009-06-17 14:36:03 UTC (rev 90334)
+++ projects/jboss-osgi/trunk/blueprint/testsuite/src/test/resources/container/context-basic.bnd	2009-06-17 15:22:08 UTC (rev 90336)
@@ -1,24 +0,0 @@
-# bnd build -classpath target/test-classes -output target/test-libs/context-basic.jar src/test/resources/context/context-basic.bnd
-
-Bundle-SymbolicName: context-basic
-
-Export-Package: org.jboss.test.osgi.blueprint.context
-
-Private-Package: org.jboss.test.osgi.blueprint.context.bundle
-
-Import-Package: \
-	javax.management, \
-	org.jboss.osgi.husky, \
-	org.jboss.osgi.husky.annotation, \
-	org.jboss.osgi.spi.capability, \
-	org.jboss.osgi.spi.testing, \
-	org.junit, \
-	org.osgi.framework, \
-	org.osgi.service.blueprint.* 
-
-Include-Resource: \
-	OSGI-INF/blueprint=OSGI-INF/blueprint
-
-Test-Package: org.jboss.test.osgi.blueprint.context
-
--removeheaders: Include-Resource

Modified: projects/jboss-osgi/trunk/blueprint/testsuite/src/test/resources/parser/blueprint-all-elements.xml
===================================================================
--- projects/jboss-osgi/trunk/blueprint/testsuite/src/test/resources/parser/blueprint-all-elements.xml	2009-06-17 15:10:06 UTC (rev 90335)
+++ projects/jboss-osgi/trunk/blueprint/testsuite/src/test/resources/parser/blueprint-all-elements.xml	2009-06-17 15:22:08 UTC (rev 90336)
@@ -18,10 +18,12 @@
 
   <service id="idServiceA" auto-export="disabled" depends-on="someServiceDependency" interface="foo.ServiceInterface" ranking="0">
     <description>service description</description>
+    <!-- 
     <interfaces>
       <value>foo.ServiceInterfA</value>
       <value>foo.ServiceInterfB</value>
     </interfaces>
+    -->
     <service-properties>
       <entry key="keyA" value="valueA" />
       <entry key="keyB" value="valueB" />
@@ -49,10 +51,12 @@
 
   <reference component-name="referenceCompName" interface="foo.referenceInterf" filter="referenceFilter" availablitity="optional">
     <description>reference description</description>
+    <!-- 
     <interfaces>
       <value>foo.ReferenceInterfA</value>
       <value>foo.ReferenceInterfB</value>
     </interfaces>
+    -->
     <listener ref="referenceListenerA" bind-method="bindMethod" unbind-method="unbindMethod" />
     <listener ref="referenceListenerB" />
   </reference>




More information about the jboss-osgi-commits mailing list