geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r766279 - in /geronimo/sandbox/blueprint: itests/src/test/java/org/apache/felix/blueprint/itests/Test.java org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/context/ModuleContextImpl.java
Date Sat, 18 Apr 2009 09:39:22 GMT
Author: gnodet
Date: Sat Apr 18 09:39:22 2009
New Revision: 766279

URL: http://svn.apache.org/viewvc?rev=766279&view=rev
Log:
Give access to object instances from the module context, test it in the integration tests

Modified:
    geronimo/sandbox/blueprint/itests/src/test/java/org/apache/felix/blueprint/itests/Test.java
    geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/context/ModuleContextImpl.java

Modified: geronimo/sandbox/blueprint/itests/src/test/java/org/apache/felix/blueprint/itests/Test.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/itests/src/test/java/org/apache/felix/blueprint/itests/Test.java?rev=766279&r1=766278&r2=766279&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/itests/src/test/java/org/apache/felix/blueprint/itests/Test.java
(original)
+++ geronimo/sandbox/blueprint/itests/src/test/java/org/apache/felix/blueprint/itests/Test.java
Sat Apr 18 09:39:22 2009
@@ -21,6 +21,8 @@
 import java.net.URLDecoder;
 
 import org.apache.servicemix.kernel.testing.support.AbstractIntegrationTest;
+import org.apache.geronimo.osgi.example.Foo;
+import org.apache.geronimo.osgi.example.Bar;
 import org.osgi.framework.Bundle;
 import org.osgi.service.blueprint.context.ModuleContext;
 import org.springframework.core.io.Resource;
@@ -37,7 +39,22 @@
         ModuleContext moduleContext = getOsgiService(ModuleContext.class, 5000);
         assertNotNull(moduleContext);
 
-        // TODO: Check that the moduleContext has been correctly instanciated, that it contains
the right beans, etc...
+        Object obj = moduleContext.getComponent("foo");
+        assertNotNull(obj);
+        assertEquals(Foo.class, obj.getClass());
+        obj = moduleContext.getComponent("bar");
+        assertNotNull(obj);
+        assertEquals(Bar.class, obj.getClass());
+
+        // TODO: components properties
+
+        bundle.stop();
+        try {
+            moduleContext = getOsgiService(ModuleContext.class, 1);
+            fail("ModuleContext should have been unregistered");
+        } catch (Exception e) {
+            // Expected, as the module context should have been unregistered
+        }
     }
 
     /**

Modified: geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/context/ModuleContextImpl.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/context/ModuleContextImpl.java?rev=766279&r1=766278&r2=766279&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/context/ModuleContextImpl.java
(original)
+++ geronimo/sandbox/blueprint/org.apache.felix.blueprint/src/main/java/org/apache/felix/blueprint/context/ModuleContextImpl.java
Sat Apr 18 09:39:22 2009
@@ -68,6 +68,7 @@
     private final List<URL> urls;
     private final ComponentDefinitionRegistryImpl componentDefinitionRegistry;
     private final ConversionServiceImpl conversionService;
+    private Map<String, Object> instances;
     private ServiceRegistration registration;
 
     public ModuleContextImpl(BundleContext bundleContext, ModuleContextEventSender sender,
NamespaceHandlerRegistry handlers, List<URL> urls) {
@@ -108,8 +109,10 @@
             ObjectGraph graph = new ObjectGraph(repository);
 
             registerTypeConverters(graph);
-            
-            System.out.println(graph.createAll(new ArrayList<String>(componentDefinitionRegistry.getComponentDefinitionNames())));
+
+            // TODO: handle scopes and such
+            instances = graph.createAll(new ArrayList<String>(componentDefinitionRegistry.getComponentDefinitionNames()));
+            System.out.println(instances);
 
             // Register the ModuleContext in the OSGi registry
             Properties props = new Properties();
@@ -149,8 +152,11 @@
     
     public Object getComponent(String name) throws NoSuchComponentException {
         ComponentMetadata metadata = getComponentMetadata(name);
-        // TODO: get the component instance
-        return null;
+        if (metadata == null) {
+            throw new NoSuchComponentException(name);
+        }
+        // TODO: handle scopes and such
+        return instances.get(name);
     }
 
     public ComponentMetadata getComponentMetadata(String name) {



Mime
View raw message