You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by jb...@apache.org on 2007/03/11 17:34:56 UTC

svn commit: r516948 - in /incubator/tuscany/java/sca/kernel/core/src: main/java/org/apache/tuscany/core/component/ main/java/org/apache/tuscany/core/implementation/ test/java/org/apache/tuscany/core/implementation/

Author: jboynes
Date: Sun Mar 11 09:34:54 2007
New Revision: 516948

URL: http://svn.apache.org/viewvc?view=rev&rev=516948
Log:
add method for passing callback wire to InstanceFactoryProvider
add tests for wire attachment

Modified:
    incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/InstanceFactoryProvider.java
    incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/PojoComponent.java
    incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/PojoComponentTestCase.java

Modified: incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/InstanceFactoryProvider.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/InstanceFactoryProvider.java?view=diff&rev=516948&r1=516947&r2=516948
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/InstanceFactoryProvider.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/InstanceFactoryProvider.java Sun Mar 11 09:34:54 2007
@@ -27,18 +27,25 @@
  */
 public interface InstanceFactoryProvider<T> {
     /**
-     * Attach the outbound wire for a single-valued reference.
+     * Attach the wire for a single-valued reference.
      *
-     * @param wire the outbound wire to attach
+     * @param wire the reference wire to attach
      */
     void attachWire(Wire wire);
 
     /**
-     * Attach the outbound wires for a multi-valued reference.
+     * Attach the wires for a multi-valued reference.
      *
-     * @param wires the outbound wires to attach
+     * @param wires the reference wires to attach
      */
     void attachWires(List<Wire> wires);
+
+    /**
+     * Attach the wire for a callback.
+     *
+     * @param wire the callback wire to attach
+     */
+    void attachCallbackWire(Wire wire);
 
     /**
      * Create an instance factory that can be used to create component instances.

Modified: incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/PojoComponent.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/PojoComponent.java?view=diff&rev=516948&r1=516947&r2=516948
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/PojoComponent.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/PojoComponent.java Sun Mar 11 09:34:54 2007
@@ -97,6 +97,7 @@
     }
 
     public void attachCallbackWire(Wire wire) {
+        provider.attachCallbackWire(wire);
     }
 
     public void start() {

Modified: incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/PojoComponentTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/PojoComponentTestCase.java?view=diff&rev=516948&r1=516947&r2=516948
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/PojoComponentTestCase.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/PojoComponentTestCase.java Sun Mar 11 09:34:54 2007
@@ -19,14 +19,21 @@
 package org.apache.tuscany.core.implementation;
 
 import java.net.URI;
+import java.util.Collections;
+import java.util.List;
 
 import junit.framework.TestCase;
-import org.easymock.EasyMock;
+import static org.easymock.EasyMock.createNiceMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.reset;
+import static org.easymock.EasyMock.verify;
 
 import org.apache.tuscany.core.component.InstanceFactory;
 import org.apache.tuscany.core.component.InstanceFactoryProvider;
 import org.apache.tuscany.spi.component.InstanceWrapper;
 import org.apache.tuscany.spi.component.ScopeContainer;
+import org.apache.tuscany.spi.wire.Wire;
 
 /**
  * @version $Rev$ $Date$
@@ -38,6 +45,8 @@
     private InstanceFactory<T> instanceFactory;
     private InstanceWrapper<T> wrapper;
     private ScopeContainer scopeContainer;
+    private Wire wire;
+    private List<Wire> wires;
 
     public void testConversationAttributes() {
         TestComponent<T> component = new TestComponent<T>(componentId, null, null, 0, 12, 34);
@@ -57,36 +66,59 @@
 
     public void testLifecycleAndWrapperCreation() {
         // test start method creates the factory
-        EasyMock.expect(provider.createFactory()).andReturn(instanceFactory);
+        expect(provider.createFactory()).andReturn(instanceFactory);
         scopeContainer.register(component);
-        EasyMock.replay(provider, instanceFactory, wrapper, scopeContainer);
+        replay(provider, instanceFactory, wrapper, scopeContainer);
         component.start();
-        EasyMock.verify(provider, instanceFactory, wrapper, scopeContainer);
+        verify(provider, instanceFactory, wrapper, scopeContainer);
 
         // test creating an wrapper calls the factory
         // we piggyback this here has the component needs to be started for the factory to be active
-        EasyMock.reset(provider, instanceFactory, wrapper, scopeContainer);
-        EasyMock.expect(instanceFactory.newInstance()).andReturn(wrapper);
-        EasyMock.replay(provider, instanceFactory, wrapper, scopeContainer);
+        reset(provider, instanceFactory, wrapper, scopeContainer);
+        expect(instanceFactory.newInstance()).andReturn(wrapper);
+        replay(provider, instanceFactory, wrapper, scopeContainer);
         component.createInstanceWrapper();
-        EasyMock.verify(provider, instanceFactory, wrapper, scopeContainer);
+        verify(provider, instanceFactory, wrapper, scopeContainer);
 
         // test stop method
-        EasyMock.reset(provider, instanceFactory, wrapper, scopeContainer);
+        reset(provider, instanceFactory, wrapper, scopeContainer);
         scopeContainer.unregister(component);
-        EasyMock.replay(provider, instanceFactory, wrapper, scopeContainer);
+        replay(provider, instanceFactory, wrapper, scopeContainer);
         component.stop();
-        EasyMock.verify(provider, instanceFactory, wrapper, scopeContainer);
+        verify(provider, instanceFactory, wrapper, scopeContainer);
+    }
+
+    public void testAttachSingleReferenceWire() {
+        provider.attachWire(wire);
+        replay(provider);
+        component.attachWire(wire);
+        verify(provider);
+    }
+
+    public void testAttachMultipleReferenceWire() {
+        provider.attachWires(wires);
+        replay(provider);
+        component.attachWires(wires);
+        verify(provider);
+    }
+
+    public void testAttachCallbackWire() {
+        provider.attachCallbackWire(wire);
+        replay(provider);
+        component.attachCallbackWire(wire);
+        verify(provider);
     }
 
     @SuppressWarnings("unchecked")
     protected void setUp() throws Exception {
         super.setUp();
         componentId = URI.create("sca://./component");
-        provider = EasyMock.createNiceMock(InstanceFactoryProvider.class);
-        instanceFactory = EasyMock.createNiceMock(InstanceFactory.class);
-        wrapper = EasyMock.createNiceMock(InstanceWrapper.class);
-        scopeContainer = EasyMock.createNiceMock(ScopeContainer.class);
+        provider = createNiceMock(InstanceFactoryProvider.class);
+        instanceFactory = createNiceMock(InstanceFactory.class);
+        wrapper = createNiceMock(InstanceWrapper.class);
+        scopeContainer = createNiceMock(ScopeContainer.class);
+        wire = createNiceMock(Wire.class);
+        wires = Collections.singletonList(wire);
         component = new TestComponent<T>(componentId, provider, scopeContainer, 0, -1, -1);
     }
 



---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org