You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by jm...@apache.org on 2006/12/30 22:42:28 UTC

svn commit: r491325 [3/6] - in /incubator/tuscany/java/sca: kernel/core/src/main/java/org/apache/tuscany/core/binding/ kernel/core/src/main/java/org/apache/tuscany/core/binding/local/ kernel/core/src/main/java/org/apache/tuscany/core/builder/ kernel/co...

Modified: incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/builder/ConnectorImplTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/builder/ConnectorImplTestCase.java?view=diff&rev=491325&r1=491324&r2=491325
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/builder/ConnectorImplTestCase.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/builder/ConnectorImplTestCase.java Sat Dec 30 13:42:22 2006
@@ -18,6 +18,7 @@
  */
 package org.apache.tuscany.core.builder;
 
+import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Type;
 import java.util.ArrayList;
 import java.util.Collections;
@@ -29,8 +30,8 @@
 import org.apache.tuscany.spi.component.AtomicComponent;
 import org.apache.tuscany.spi.component.CompositeComponent;
 import org.apache.tuscany.spi.component.Reference;
-import org.apache.tuscany.spi.component.SCAObject;
 import org.apache.tuscany.spi.component.Service;
+import org.apache.tuscany.spi.component.ServiceBinding;
 import org.apache.tuscany.spi.idl.java.JavaServiceContract;
 import org.apache.tuscany.spi.model.Operation;
 import org.apache.tuscany.spi.model.Scope;
@@ -38,11 +39,20 @@
 import org.apache.tuscany.spi.wire.InboundInvocationChain;
 import org.apache.tuscany.spi.wire.InboundWire;
 import org.apache.tuscany.spi.wire.Interceptor;
+import org.apache.tuscany.spi.wire.InvocationRuntimeException;
+import org.apache.tuscany.spi.wire.Message;
+import org.apache.tuscany.spi.wire.MessageImpl;
 import org.apache.tuscany.spi.wire.OutboundInvocationChain;
 import org.apache.tuscany.spi.wire.OutboundWire;
 import org.apache.tuscany.spi.wire.TargetInvoker;
 
 import junit.framework.TestCase;
+import org.apache.tuscany.core.implementation.composite.ServiceImpl;
+import org.apache.tuscany.core.wire.InboundInvocationChainImpl;
+import org.apache.tuscany.core.wire.InboundWireImpl;
+import org.apache.tuscany.core.wire.InvokerInterceptor;
+import org.apache.tuscany.core.wire.OutboundInvocationChainImpl;
+import org.apache.tuscany.core.wire.OutboundWireImpl;
 import org.apache.tuscany.core.wire.SynchronousBridgingInterceptor;
 import org.easymock.EasyMock;
 
@@ -50,143 +60,96 @@
  * @version $Rev$ $Date$
  */
 public class ConnectorImplTestCase extends TestCase {
+    private static final String FOO_SERVICE = "FooService";
+    private static final QualifiedName FOO_TARGET = new QualifiedName("target/FooService");
+    private static final String RESPONSE = "response";
 
     private ConnectorImpl connector;
     private ServiceContract contract;
     private Operation<Type> operation;
-    private Interceptor headInterceptor;
-    private Interceptor tailInterceptor;
 
     public void testConnectReferenceWires() throws Exception {
-
-        // create the inbound wire and chain
-        InboundInvocationChain inboundChain = EasyMock.createMock(InboundInvocationChain.class);
-        EasyMock.expect(inboundChain.getOperation()).andReturn(operation).atLeastOnce();
-        inboundChain.addInterceptor(EasyMock.isA(SynchronousBridgingInterceptor.class));
-        inboundChain.setTargetInvoker(null);
-        inboundChain.prepare();
-        EasyMock.replay(inboundChain);
-        Map<Operation<?>, InboundInvocationChain> inboundChains = new HashMap<Operation<?>, InboundInvocationChain>();
-        inboundChains.put(operation, inboundChain);
-        InboundWire inboundWire = EasyMock.createMock(InboundWire.class);
-        EasyMock.expect(inboundWire.getServiceContract()).andReturn(contract).anyTimes();
-        EasyMock.expect(inboundWire.getInvocationChains()).andReturn(inboundChains).atLeastOnce();
-        EasyMock.expect(inboundWire.getContainer()).andReturn(EasyMock.createNiceMock(SCAObject.class));
-        EasyMock.replay(inboundWire);
-
-        OutboundInvocationChain outboundChain = EasyMock.createMock(OutboundInvocationChain.class);
-        EasyMock.expect(outboundChain.getHeadInterceptor()).andReturn(headInterceptor);
-        EasyMock.replay(outboundChain);
-        Map<Operation<?>, OutboundInvocationChain> outboundChains =
-            new HashMap<Operation<?>, OutboundInvocationChain>();
-        outboundChains.put(operation, outboundChain);
-        OutboundWire outboundWire = EasyMock.createMock(OutboundWire.class);
-        EasyMock.expect(outboundWire.getServiceContract()).andReturn(contract).anyTimes();
-        EasyMock.expect(outboundWire.getTargetName()).andReturn(new QualifiedName("target/FooService")).anyTimes();
-        EasyMock.expect(outboundWire.getInvocationChains()).andReturn(outboundChains).anyTimes();
-        EasyMock.replay(outboundWire);
+        InboundInvocationChain inboundChain = new InboundInvocationChainImpl(operation);
+        InboundWire inboundWire = new InboundWireImpl();
+        inboundWire.setServiceContract(contract);
+        inboundWire.addInvocationChain(operation, inboundChain);
+
+        OutboundInvocationChain outboundChain = new OutboundInvocationChainImpl(operation);
+        outboundChain.addInterceptor(new LoopbackInterceptor());
+        OutboundWire outboundWire = new OutboundWireImpl();
+        outboundWire.setServiceContract(contract);
+        outboundWire.setTargetName(FOO_TARGET);
+        outboundWire.addInvocationChain(operation, outboundChain);
 
         Reference reference = EasyMock.createMock(Reference.class);
         EasyMock.expect(reference.getParent()).andReturn(null);
         EasyMock.expect(reference.createTargetInvoker(contract, operation)).andReturn(null);
         EasyMock.expect(reference.getInboundWire()).andReturn(inboundWire);
         EasyMock.expect(reference.getOutboundWire()).andReturn(outboundWire);
+        EasyMock.expect(reference.isSystem()).andReturn(false);
         EasyMock.replay(reference);
 
+        inboundWire.setContainer(reference);
+        outboundWire.setContainer(reference);
         connector.connect(reference);
 
         EasyMock.verify(reference);
-        EasyMock.verify(inboundWire);
-        EasyMock.verify(outboundWire);
-        EasyMock.verify(inboundChain);
-        EasyMock.verify(outboundChain);
-    }
-
-    public void testConnectServiceWires() throws Exception {
-        // create the inbound wire and chain for the target
-        InboundInvocationChain targetChain = EasyMock.createMock(InboundInvocationChain.class);
-        EasyMock.expect(targetChain.getOperation()).andReturn(operation).atLeastOnce();
-        EasyMock.expect(targetChain.getHeadInterceptor()).andReturn(headInterceptor);
-        targetChain.prepare();
-        EasyMock.replay(targetChain);
-        Map<Operation<?>, InboundInvocationChain> targetChains = new HashMap<Operation<?>, InboundInvocationChain>();
-        targetChains.put(operation, targetChain);
-        InboundWire targetWire = EasyMock.createMock(InboundWire.class);
-        EasyMock.expect(targetWire.getServiceContract()).andReturn(contract).anyTimes();
-        EasyMock.expect(targetWire.getInvocationChains()).andReturn(targetChains);
-        targetWire.getSourceCallbackInvocationChains("source");
-        EasyMock.expectLastCall().andReturn(Collections.emptyMap());
+        Interceptor interceptor = inboundChain.getHeadInterceptor();
+        assertTrue(interceptor instanceof SynchronousBridgingInterceptor);
+        Message resp = interceptor.invoke(new MessageImpl());
+        assertEquals(RESPONSE, resp.getBody());
 
-        // create the target
-        AtomicComponent target = EasyMock.createMock(AtomicComponent.class);
-        EasyMock.expect(target.getScope()).andReturn(Scope.COMPOSITE);
-        EasyMock.expect(target.isSystem()).andReturn(false).atLeastOnce();
-        target.getInboundWire(EasyMock.eq("FooService"));
-        EasyMock.expectLastCall().andReturn(targetWire).atLeastOnce();
-        target.createTargetInvoker(EasyMock.eq("FooService"), EasyMock.eq(operation), EasyMock.eq(targetWire));
-        EasyMock.expectLastCall().andReturn(null);
-        EasyMock.replay(target);
+    }
 
-        EasyMock.expect(targetWire.getContainer()).andReturn(target).atLeastOnce();
-        EasyMock.replay(targetWire);
+    public void testConnectSynchronousServiceWiresToAtomicTarget() throws Exception {
+        AtomicComponent target = createAtomicTarget();
 
         // create the parent composite
         CompositeComponent parent = EasyMock.createMock(CompositeComponent.class);
         EasyMock.expect(parent.getChild("target")).andReturn(target);
         EasyMock.replay(parent);
 
-        // create the inbound wire and chain for the source service
-        InboundInvocationChain inboundChain = EasyMock.createMock(InboundInvocationChain.class);
-        EasyMock.expect(inboundChain.getOperation()).andReturn(operation).atLeastOnce();
-        inboundChain.addInterceptor(EasyMock.isA(SynchronousBridgingInterceptor.class));
-        inboundChain.setTargetInvoker(null);
-        EasyMock.replay(inboundChain);
-        Map<Operation<?>, InboundInvocationChain> inboundChains = new HashMap<Operation<?>, InboundInvocationChain>();
-        inboundChains.put(operation, inboundChain);
-        InboundWire inboundWire = EasyMock.createMock(InboundWire.class);
-        EasyMock.expect(inboundWire.getServiceContract()).andReturn(contract).anyTimes();
-        EasyMock.expect(inboundWire.getContainer()).andReturn(EasyMock.createNiceMock(SCAObject.class));
-        EasyMock.expect(inboundWire.getInvocationChains()).andReturn(inboundChains).atLeastOnce();
-        EasyMock.replay(inboundWire);
-
-        // create the outbound wire and chain for the source service
-        OutboundInvocationChain outboundChain = EasyMock.createMock(OutboundInvocationChain.class);
-        EasyMock.expect(outboundChain.getHeadInterceptor()).andReturn(headInterceptor);
-        outboundChain.setTargetInterceptor(EasyMock.isA(SynchronousBridgingInterceptor.class));
-        outboundChain.prepare();
-        outboundChain.setTargetInvoker(null);
-        EasyMock.expect(outboundChain.getOperation()).andReturn(operation);
-        EasyMock.replay(outboundChain);
-        Map<Operation<?>, OutboundInvocationChain> outboundChains =
-            new HashMap<Operation<?>, OutboundInvocationChain>();
-        outboundChains.put(operation, outboundChain);
-        OutboundWire outboundWire = EasyMock.createMock(OutboundWire.class);
-        outboundWire.getTargetCallbackInvocationChains();
-        EasyMock.expectLastCall().andReturn(Collections.emptyMap());
-        EasyMock.expect(outboundWire.getServiceContract()).andReturn(contract).anyTimes();
-        EasyMock.expect(outboundWire.getTargetName()).andReturn(new QualifiedName("target/FooService")).anyTimes();
-        EasyMock.expect(outboundWire.getInvocationChains()).andReturn(outboundChains).anyTimes();
-
-        // create the service
-        Service service = EasyMock.createMock(Service.class);
-        EasyMock.expect(service.getName()).andReturn("source");
-        EasyMock.expect(service.isSystem()).andReturn(false).atLeastOnce();
-        EasyMock.expect(service.getParent()).andReturn(parent).atLeastOnce();
-        EasyMock.expect(service.getInboundWire()).andReturn(inboundWire).atLeastOnce();
-        EasyMock.expect(service.getScope()).andReturn(Scope.SYSTEM);
-        EasyMock.expect(service.getOutboundWire()).andReturn(outboundWire);
-        EasyMock.replay(service);
+        InboundInvocationChain inboundChain = new InboundInvocationChainImpl(operation);
+        InboundWire inboundWire = new InboundWireImpl();
+        inboundWire.addInvocationChain(operation, inboundChain);
+        inboundWire.setServiceContract(contract);
+
+        OutboundInvocationChain outboundChain = new OutboundInvocationChainImpl(operation);
+        OutboundWire outboundWire = new OutboundWireImpl();
+        outboundWire.setTargetName(FOO_TARGET);
+        outboundWire.addInvocationChain(operation, outboundChain);
+        outboundWire.setServiceContract(contract);
+
+        // create the binding
+        ServiceBinding binding = EasyMock.createMock(ServiceBinding.class);
+        EasyMock.expect(binding.getName()).andReturn("source");
+        binding.setService(EasyMock.isA(Service.class));
+        EasyMock.expect(binding.isSystem()).andReturn(false).atLeastOnce();
+        EasyMock.expect(binding.getInboundWire()).andReturn(inboundWire).atLeastOnce();
+        EasyMock.expect(binding.getOutboundWire()).andReturn(outboundWire);
+        EasyMock.expect(binding.getScope()).andReturn(Scope.SYSTEM);
+        EasyMock.replay(binding);
 
-        EasyMock.expect(outboundWire.getContainer()).andReturn(service).atLeastOnce();
-        EasyMock.replay(outboundWire);
+        outboundWire.setContainer(binding);
+        inboundWire.setContainer(binding);
+
+        Service service = new ServiceImpl("foo", parent, null);
+        service.addServiceBinding(binding);
 
         connector.connect(service);
+        MessageImpl msg = new MessageImpl();
+        msg.setTargetInvoker(inboundChain.getTargetInvoker());
+        Message resp = inboundChain.getHeadInterceptor().invoke(msg);
+        assertEquals(RESPONSE, resp.getBody());
+        EasyMock.verify(binding);
+    }
 
-        EasyMock.verify(service);
-        EasyMock.verify(inboundWire);
-        EasyMock.verify(outboundWire);
-        EasyMock.verify(inboundChain);
-        EasyMock.verify(outboundChain);
+    public void testConnectNonBlockingServiceWiresToAtomicTarget() throws Exception {
+        // JFM FIXME
+    }
+
+    public void testConnectCallbackServiceWiresToAtomicTarget() throws Exception {
+        // JFM FIXME
     }
 
     /**
@@ -194,99 +157,33 @@
      */
     public void testConnectAtomicComponentToAtomicComponentSyncWire() throws Exception {
 
-        // create the inbound wire and chain
-        InboundInvocationChain inboundChain = EasyMock.createMock(InboundInvocationChain.class);
-        EasyMock.expect(inboundChain.getOperation()).andReturn(operation).atLeastOnce();
-        EasyMock.expect(inboundChain.getHeadInterceptor()).andReturn(headInterceptor);
-        EasyMock.replay(inboundChain);
-        Map<Operation<?>, InboundInvocationChain> inboundChains = new HashMap<Operation<?>, InboundInvocationChain>();
-        inboundChains.put(operation, inboundChain);
-        InboundWire targetWire = EasyMock.createMock(InboundWire.class);
-        EasyMock.expect(targetWire.getServiceContract()).andReturn(contract).anyTimes();
-        EasyMock.expect(targetWire.getInvocationChains()).andReturn(inboundChains);
-        targetWire.getSourceCallbackInvocationChains("source");
-        EasyMock.expectLastCall().andReturn(Collections.emptyMap());
-
-        // create the target
-        AtomicComponent target = EasyMock.createMock(AtomicComponent.class);
-        EasyMock.expect(target.getScope()).andReturn(Scope.COMPOSITE);
-        target.getInboundWire(EasyMock.eq("FooService"));
-        EasyMock.expectLastCall().andReturn(targetWire);
-        target.createTargetInvoker(EasyMock.eq("FooService"), EasyMock.eq(operation), EasyMock.eq(targetWire));
-        EasyMock.expectLastCall().andReturn(null);
-        EasyMock.replay(target);
-
-        EasyMock.expect(targetWire.getContainer()).andReturn(target).atLeastOnce();
-        EasyMock.replay(targetWire);
-
+        AtomicComponent target = createAtomicTarget();
         // create the parent composite
         CompositeComponent parent = EasyMock.createMock(CompositeComponent.class);
         EasyMock.expect(parent.getChild("target")).andReturn(target);
         EasyMock.replay(parent);
-
-        // create the outbound wire and chain from the source component
-        OutboundInvocationChain outboundChain = EasyMock.createMock(OutboundInvocationChain.class);
-        EasyMock.expect(outboundChain.getOperation()).andReturn(operation).atLeastOnce();
-        outboundChain.setTargetInterceptor(EasyMock.isA(SynchronousBridgingInterceptor.class));
-        outboundChain.setTargetInvoker(null);
-        outboundChain.prepare();
-        EasyMock.replay(outboundChain);
-        Map<Operation<?>, OutboundInvocationChain> outboundChains =
-            new HashMap<Operation<?>, OutboundInvocationChain>();
-        outboundChains.put(operation, outboundChain);
-        OutboundWire outboundWire = EasyMock.createMock(OutboundWire.class);
-        EasyMock.expect(outboundWire.isAutowire()).andReturn(false);
-        EasyMock.expect(outboundWire.getServiceContract()).andReturn(contract).anyTimes();
-        EasyMock.expect(outboundWire.getTargetName()).andReturn(new QualifiedName("target/FooService")).anyTimes();
-        EasyMock.expect(outboundWire.getInvocationChains()).andReturn(outboundChains).anyTimes();
-        outboundWire.getTargetCallbackInvocationChains();
-        EasyMock.expectLastCall().andReturn(Collections.emptyMap());
-
-        Map<String, List<OutboundWire>> outboundWires = new HashMap<String, List<OutboundWire>>();
-        List<OutboundWire> list = new ArrayList<OutboundWire>();
-        list.add(outboundWire);
-        outboundWires.put("fooService", list);
-
-        // create the source
-        AtomicComponent source = EasyMock.createMock(AtomicComponent.class);
-        EasyMock.expect(source.isSystem()).andReturn(false).atLeastOnce();
-        EasyMock.expect(source.getScope()).andReturn(Scope.COMPOSITE);
-        EasyMock.expect(source.getParent()).andReturn(parent).atLeastOnce();
-        EasyMock.expect(source.getOutboundWires()).andReturn(outboundWires);
-        EasyMock.expect(source.getName()).andReturn("source");
-        source.getInboundWires();
-        EasyMock.expectLastCall().andReturn(Collections.emptyMap());
-        EasyMock.replay(source);
-
-        EasyMock.expect(outboundWire.getContainer()).andReturn(source).atLeastOnce();
-        EasyMock.replay(outboundWire);
-
+        AtomicComponent source = createAtomicSource(parent);
         connector.connect(source);
-        EasyMock.verify(outboundWire);
-        EasyMock.verify(targetWire);
-        EasyMock.verify(outboundChain);
-        EasyMock.verify(inboundChain);
-        EasyMock.verify(source);
-        EasyMock.verify(target);
+
+        MessageImpl msg = new MessageImpl();
+        Map<String, List<OutboundWire>> wires = source.getOutboundWires();
+        OutboundWire wire = wires.get(FOO_SERVICE).get(0);
+        OutboundInvocationChain chain = wire.getInvocationChains().get(operation);
+        msg.setTargetInvoker(chain.getTargetInvoker());
+        Message resp = chain.getHeadInterceptor().invoke(msg);
+        assertEquals(RESPONSE, resp.getBody());
     }
 
     public void testConnectInboundAtomicComponentWires() throws Exception {
         // create the inbound wire and chain
-        InboundInvocationChain chain = EasyMock.createMock(InboundInvocationChain.class);
-        EasyMock.expect(chain.getOperation()).andReturn(operation).atLeastOnce();
-        chain.setTargetInvoker(null);
-        chain.prepare();
-        EasyMock.replay(chain);
-        Map<Operation<?>, InboundInvocationChain> inboundChains = new HashMap<Operation<?>, InboundInvocationChain>();
-        inboundChains.put(operation, chain);
-        InboundWire wire = EasyMock.createMock(InboundWire.class);
-        EasyMock.expect(wire.getServiceName()).andReturn("FooService");
-        EasyMock.expect(wire.getServiceContract()).andReturn(contract).anyTimes();
-        EasyMock.expect(wire.getInvocationChains()).andReturn(inboundChains);
-        EasyMock.replay(wire);
-
-        Map<String, InboundWire> wires = new HashMap<String, InboundWire>();
-        wires.put("FooService", wire);
+        InboundInvocationChain chain = new InboundInvocationChainImpl(operation);
+        chain.addInterceptor(new InvokerInterceptor());
+        InboundWire wire = new InboundWireImpl();
+        wire.setServiceContract(contract);
+        wire.addInvocationChain(operation, chain);
+        wire.setServiceName(FOO_SERVICE);
+        List<InboundWire> wires = new ArrayList<InboundWire>();
+        wires.add(wire);
 
         AtomicComponent source = EasyMock.createMock(AtomicComponent.class);
         EasyMock.expect(source.getParent()).andReturn(null);
@@ -294,15 +191,15 @@
         EasyMock.expectLastCall().andReturn(Collections.emptyMap());
         source.getInboundWires();
         EasyMock.expectLastCall().andReturn(wires);
-        source.createTargetInvoker(EasyMock.eq("FooService"), EasyMock.eq(operation), (InboundWire) EasyMock.isNull());
-        EasyMock.expectLastCall().andReturn(null);
+        source.createTargetInvoker(EasyMock.eq(FOO_SERVICE), EasyMock.eq(operation), (InboundWire) EasyMock.isNull());
+        EasyMock.expectLastCall().andReturn(new MockInvoker());
         EasyMock.replay(source);
 
         connector.connect(source);
-
-        EasyMock.verify(source);
-        EasyMock.verify(wire);
-        EasyMock.verify(chain);
+        Message msg = new MessageImpl();
+        msg.setTargetInvoker(chain.getTargetInvoker());
+        Message resp = chain.getHeadInterceptor().invoke(msg);
+        assertEquals(RESPONSE, resp.getBody());
     }
 
     public void testConnectTargetNotFound() throws Exception {
@@ -311,44 +208,17 @@
         parent.getChild(EasyMock.isA(String.class));
         EasyMock.expectLastCall().andReturn(null);
         EasyMock.replay(parent);
-        OutboundWire outboundWire = EasyMock.createMock(OutboundWire.class);
-        EasyMock.expect(outboundWire.isAutowire()).andReturn(false);
-        EasyMock.expect(outboundWire.getServiceContract()).andReturn(contract).anyTimes();
-        EasyMock.expect(outboundWire.getTargetName()).andReturn(new QualifiedName("target/FooService")).anyTimes();
-        EasyMock.expect(outboundWire.getInvocationChains()).andReturn(null).anyTimes();
-        EasyMock.expect(outboundWire.getReferenceName()).andReturn("nothtere");
-        EasyMock.expect(outboundWire.getContainer()).andReturn(EasyMock.createNiceMock(SCAObject.class));
-        outboundWire.getTargetCallbackInvocationChains();
-        EasyMock.expectLastCall().andReturn(Collections.emptyMap());
-        EasyMock.replay(outboundWire);
-        Map<String, List<OutboundWire>> outboundWires = new HashMap<String, List<OutboundWire>>();
-        List<OutboundWire> list = new ArrayList<OutboundWire>();
-        list.add(outboundWire);
-        outboundWires.put("fooService", list);
-
-        // create the source
-        AtomicComponent source = EasyMock.createMock(AtomicComponent.class);
-        EasyMock.expect(source.getOutboundWires()).andReturn(outboundWires);
-        EasyMock.expect(source.isSystem()).andReturn(false);
-        EasyMock.expect(source.getName()).andReturn("foo");
-        EasyMock.expect(source.getParent()).andReturn(parent);
-        EasyMock.replay(source);
         try {
+            AtomicComponent source = createAtomicSource(parent);
             connector.connect(source);
             fail();
         } catch (TargetServiceNotFoundException e) {
             // expected
         }
-
-        EasyMock.verify(source);
     }
 
     public void testOutboundToInboundOptimization() throws Exception {
-        InboundWire inboundWire = EasyMock.createMock(InboundWire.class);
-        EasyMock.expect(inboundWire.getContainer()).andReturn(null);
-        inboundWire.getInvocationChains();
-        EasyMock.expectLastCall().andReturn(Collections.emptyMap());
-        EasyMock.replay(inboundWire);
+        InboundWire inboundWire = new InboundWireImpl();
 
         OutboundWire outboundWire = EasyMock.createMock(OutboundWire.class);
         outboundWire.getInvocationChains();
@@ -359,100 +229,175 @@
         EasyMock.replay(outboundWire);
 
         connector.connect(outboundWire, inboundWire, true);
-        EasyMock.verify(inboundWire);
         EasyMock.verify(outboundWire);
     }
 
     public void testOutboundToInboundChainConnect() {
+        TargetInvoker invoker = new MockInvoker();
+        InboundInvocationChain inboundChain = new InboundInvocationChainImpl(operation);
+        inboundChain.addInterceptor(new LoopbackInterceptor());
 
-        TargetInvoker invoker = EasyMock.createMock(TargetInvoker.class);
-        EasyMock.replay(invoker);
+        OutboundInvocationChain outboundChain = new OutboundInvocationChainImpl(operation);
 
-        InboundInvocationChain inboundChain = EasyMock.createMock(InboundInvocationChain.class);
-        EasyMock.expect(inboundChain.getHeadInterceptor()).andReturn(headInterceptor);
-        EasyMock.replay(inboundChain);
-
-        OutboundInvocationChain outboundChain = EasyMock.createMock(OutboundInvocationChain.class);
-        outboundChain.prepare();
-        outboundChain.setTargetInterceptor(EasyMock.isA(SynchronousBridgingInterceptor.class));
-        outboundChain.setTargetInvoker(invoker);
-        EasyMock.replay(outboundChain);
         connector.connect(outboundChain, inboundChain, invoker, false);
-        EasyMock.verify(outboundChain);
+        Interceptor interceptor = outboundChain.getHeadInterceptor();
+        assertTrue(interceptor instanceof SynchronousBridgingInterceptor);
+        Message resp = interceptor.invoke(new MessageImpl());
+        assertEquals(RESPONSE, resp.getBody());
+
     }
 
     public void testInboundToOutboundChainConnect() {
-        InboundInvocationChain inboundChain = EasyMock.createMock(InboundInvocationChain.class);
-        inboundChain.addInterceptor(EasyMock.isA(SynchronousBridgingInterceptor.class));
-        EasyMock.replay(inboundChain);
-
-        OutboundInvocationChain outboundChain = EasyMock.createMock(OutboundInvocationChain.class);
-        EasyMock.expect(outboundChain.getHeadInterceptor()).andReturn(headInterceptor);
-        outboundChain.prepare();
-        outboundChain.setTargetInterceptor(headInterceptor);
-        EasyMock.replay(outboundChain);
+        InboundInvocationChain inboundChain = new InboundInvocationChainImpl(operation);
+
+        OutboundInvocationChain outboundChain = new OutboundInvocationChainImpl(operation);
+        outboundChain.addInterceptor(new LoopbackInterceptor());
+
         connector.connect(inboundChain, outboundChain);
-        EasyMock.verify(inboundChain);
+        Interceptor interceptor = inboundChain.getHeadInterceptor();
+        assertTrue(interceptor instanceof SynchronousBridgingInterceptor);
+        Message resp = interceptor.invoke(new MessageImpl());
+        assertEquals(RESPONSE, resp.getBody());
     }
 
     public void testOutboundWireToInboundReferenceTarget() throws Exception {
         AtomicComponent component = EasyMock.createMock(AtomicComponent.class);
         EasyMock.expect(component.getName()).andReturn("foo");
         EasyMock.replay(component);
-        // create the inbound wire and chain
-        InboundInvocationChain inboundChain = EasyMock.createMock(InboundInvocationChain.class);
-        EasyMock.expect(inboundChain.getOperation()).andReturn(operation).atLeastOnce();
-        EasyMock.expect(inboundChain.getHeadInterceptor()).andReturn(headInterceptor);
-        EasyMock.replay(inboundChain);
-        Map<Operation<?>, InboundInvocationChain> inboundChains = new HashMap<Operation<?>, InboundInvocationChain>();
-        inboundChains.put(operation, inboundChain);
-        InboundWire targetWire = EasyMock.createMock(InboundWire.class);
-        EasyMock.expect(targetWire.getServiceContract()).andReturn(contract).anyTimes();
-        EasyMock.expect(targetWire.getInvocationChains()).andReturn(inboundChains);
-        targetWire.getSourceCallbackInvocationChains("foo");
-        EasyMock.expectLastCall().andReturn(Collections.emptyMap());
+
         Reference target = EasyMock.createMock(Reference.class);
         EasyMock.expect(target.createTargetInvoker(EasyMock.isA(ServiceContract.class), EasyMock.isA(Operation.class)))
-            .andReturn(null);
+            .andReturn(new MockInvoker());
         EasyMock.replay(target);
 
-        EasyMock.expect(targetWire.getContainer()).andReturn(target);
-        EasyMock.replay(targetWire);
+        InboundInvocationChain inboundChain = new InboundInvocationChainImpl(operation);
+        inboundChain.addInterceptor(new LoopbackInterceptor());
+        InboundWire targetWire = new InboundWireImpl();
+        targetWire.setServiceContract(contract);
+        targetWire.addInvocationChain(operation, inboundChain);
+        targetWire.setContainer(target);
 
         // create the outbound wire and chain from the source component
-        OutboundInvocationChain outboundChain = EasyMock.createMock(OutboundInvocationChain.class);
-        EasyMock.expect(outboundChain.getOperation()).andReturn(operation).atLeastOnce();
-        outboundChain.setTargetInterceptor(EasyMock.isA(SynchronousBridgingInterceptor.class));
-        outboundChain.setTargetInvoker(null);
-        outboundChain.prepare();
-        EasyMock.replay(outboundChain);
-        Map<Operation<?>, OutboundInvocationChain> outboundChains =
-            new HashMap<Operation<?>, OutboundInvocationChain>();
-        outboundChains.put(operation, outboundChain);
-        OutboundWire sourceWire = EasyMock.createMock(OutboundWire.class);
-        EasyMock.expect(sourceWire.getContainer()).andReturn(component);
-        EasyMock.expect(sourceWire.getServiceContract()).andReturn(contract).anyTimes();
-        EasyMock.expect(sourceWire.getTargetName()).andReturn(new QualifiedName("target/FooService")).anyTimes();
-        EasyMock.expect(sourceWire.getInvocationChains()).andReturn(outboundChains).anyTimes();
-        sourceWire.getTargetCallbackInvocationChains();
-        EasyMock.expectLastCall().andReturn(Collections.emptyMap());
-        EasyMock.replay(sourceWire);
+        OutboundInvocationChain sourceChain = new OutboundInvocationChainImpl(operation);
+        OutboundWire sourceWire = new OutboundWireImpl();
+        sourceWire.setServiceContract(contract);
+        sourceWire.setTargetName(FOO_TARGET);
+        sourceWire.addInvocationChain(operation, sourceChain);
+        sourceWire.setContainer(component);
 
         connector.connect(sourceWire, targetWire, false);
-        EasyMock.verify(inboundChain);
-        EasyMock.verify(targetWire);
-        EasyMock.verify(target);
+        Interceptor interceptor = sourceChain.getHeadInterceptor();
+        assertTrue(interceptor instanceof SynchronousBridgingInterceptor);
+        Message resp = interceptor.invoke(new MessageImpl());
+        assertEquals(RESPONSE, resp.getBody());
     }
 
     protected void setUp() throws Exception {
         super.setUp();
         connector = new ConnectorImpl();
-        contract = new JavaServiceContract(String.class);
+        contract = new JavaServiceContract(Foo.class);
         operation = new Operation<Type>("bar", null, null, null);
-        headInterceptor = EasyMock.createMock(Interceptor.class);
-        EasyMock.replay(headInterceptor);
-        tailInterceptor = EasyMock.createMock(Interceptor.class);
-        EasyMock.replay(tailInterceptor);
     }
 
+    private interface Foo {
+        String echo();
+    }
+
+    private AtomicComponent createAtomicTarget() throws Exception {
+        InboundInvocationChain chain = new InboundInvocationChainImpl(operation);
+        chain.addInterceptor(new InvokerInterceptor());
+        InboundWire targetWire = new InboundWireImpl();
+        targetWire.setServiceContract(contract);
+        targetWire.addInvocationChain(operation, chain);
+
+        // create the target
+        AtomicComponent target = EasyMock.createMock(AtomicComponent.class);
+        EasyMock.expect(target.getScope()).andReturn(Scope.COMPOSITE);
+        EasyMock.expect(target.isSystem()).andReturn(false).atLeastOnce();
+        target.getInboundWire(EasyMock.eq(FOO_SERVICE));
+        EasyMock.expectLastCall().andReturn(targetWire).atLeastOnce();
+        target.createTargetInvoker(EasyMock.eq(FOO_SERVICE), EasyMock.eq(operation), EasyMock.eq(targetWire));
+        MockInvoker mockInvoker = new MockInvoker();
+        EasyMock.expectLastCall().andReturn(mockInvoker);
+        EasyMock.replay(target);
+        targetWire.setContainer(target);
+        return target;
+    }
+
+    private AtomicComponent createAtomicSource(CompositeComponent parent) throws Exception {
+        // create the outbound wire and chain from the source component
+        OutboundInvocationChain outboundChain = new OutboundInvocationChainImpl(operation);
+
+        OutboundWire outboundWire = new OutboundWireImpl();
+        outboundWire.setTargetName(FOO_TARGET);
+        outboundWire.setServiceContract(contract);
+        outboundWire.addInvocationChain(operation, outboundChain);
+
+        Map<String, List<OutboundWire>> outboundWires = new HashMap<String, List<OutboundWire>>();
+        List<OutboundWire> list = new ArrayList<OutboundWire>();
+        list.add(outboundWire);
+        outboundWires.put(FOO_SERVICE, list);
+
+        // create the source
+        AtomicComponent source = EasyMock.createMock(AtomicComponent.class);
+        EasyMock.expect(source.isSystem()).andReturn(false).atLeastOnce();
+        EasyMock.expect(source.getScope()).andReturn(Scope.COMPOSITE);
+        EasyMock.expect(source.getParent()).andReturn(parent).atLeastOnce();
+        EasyMock.expect(source.getOutboundWires()).andReturn(outboundWires).atLeastOnce();
+        EasyMock.expect(source.getName()).andReturn("source").atLeastOnce();
+        source.getInboundWires();
+        EasyMock.expectLastCall().andReturn(Collections.emptyList());
+        EasyMock.replay(source);
+
+        outboundWire.setContainer(source);
+        return source;
+    }
+
+    private static class MockInvoker implements TargetInvoker {
+        public Object invokeTarget(final Object payload, final short sequence) throws InvocationTargetException {
+            return null;
+        }
+
+        public Message invoke(Message msg) throws InvocationRuntimeException {
+            Message resp = new MessageImpl();
+            resp.setBody(RESPONSE);
+            return resp;
+        }
+
+        public boolean isCacheable() {
+            return false;
+        }
+
+        public void setCacheable(boolean cacheable) {
+
+        }
+
+        public boolean isOptimizable() {
+            return false;
+        }
+
+        public Object clone() throws CloneNotSupportedException {
+            return super.clone();
+        }
+    }
+
+    private static class LoopbackInterceptor implements Interceptor {
+        public Message invoke(Message msg) {
+            Message resp = new MessageImpl();
+            resp.setBody(RESPONSE);
+            return resp;
+        }
+
+        public void setNext(Interceptor next) {
+
+        }
+
+        public Interceptor getNext() {
+            return null;
+        }
+
+        public boolean isOptimizable() {
+            return false;
+        }
+    }
 }

Modified: incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/databinding/impl/DataBindingWirePostProcessorTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/databinding/impl/DataBindingWirePostProcessorTestCase.java?view=diff&rev=491325&r1=491324&r2=491325
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/databinding/impl/DataBindingWirePostProcessorTestCase.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/databinding/impl/DataBindingWirePostProcessorTestCase.java Sat Dec 30 13:42:22 2006
@@ -34,7 +34,7 @@
 import org.apache.tuscany.spi.component.Component;
 import org.apache.tuscany.spi.component.CompositeComponent;
 import org.apache.tuscany.spi.component.Reference;
-import org.apache.tuscany.spi.component.Service;
+import org.apache.tuscany.spi.component.ServiceBinding;
 import org.apache.tuscany.spi.databinding.Mediator;
 import org.apache.tuscany.spi.idl.java.JavaServiceContract;
 import org.apache.tuscany.spi.model.DataType;
@@ -176,11 +176,11 @@
         InboundWire inboundWire = createMock(InboundWire.class);
         OutboundWire outboundWire = createMock(OutboundWire.class);
 
-        Service service = createMock(Service.class);
+        ServiceBinding serviceBinding = createMock(ServiceBinding.class);
         CompositeComponent composite = createMock(CompositeComponent.class);
-        expect(service.getParent()).andReturn(composite);
-        expect(inboundWire.getContainer()).andReturn(service).anyTimes();
-        expect(outboundWire.getContainer()).andReturn(service).anyTimes();
+        expect(serviceBinding.getParent()).andReturn(composite);
+        expect(inboundWire.getContainer()).andReturn(serviceBinding).anyTimes();
+        expect(outboundWire.getContainer()).andReturn(serviceBinding).anyTimes();
 
         Map<Operation<?>, OutboundInvocationChain> outboundChains =
             new HashMap<Operation<?>, OutboundInvocationChain>();
@@ -223,7 +223,7 @@
         contract.setCallbackOperations(operations);
         expect(inboundWire.getServiceContract()).andReturn(contract);
 
-        EasyMock.replay(composite, service, inboundWire, outboundWire, inboundChain, outboundChain);
+        EasyMock.replay(composite, serviceBinding, inboundWire, outboundWire, inboundChain, outboundChain);
 
         processor.process(inboundWire, outboundWire);
     }

Modified: incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/deployer/BootstrapDeployerTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/deployer/BootstrapDeployerTestCase.java?view=diff&rev=491325&r1=491324&r2=491325
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/deployer/BootstrapDeployerTestCase.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/deployer/BootstrapDeployerTestCase.java Sat Dec 30 13:42:22 2006
@@ -20,6 +20,7 @@
 
 import java.net.URL;
 import java.util.Map;
+import java.util.Collection;
 import javax.xml.stream.XMLInputFactory;
 
 import org.apache.tuscany.spi.bootstrap.ComponentNames;
@@ -38,6 +39,7 @@
 import org.apache.tuscany.spi.model.PropertyValue;
 import org.apache.tuscany.spi.model.ReferenceDefinition;
 import org.apache.tuscany.spi.model.ServiceDefinition;
+import org.apache.tuscany.spi.model.BindingDefinition;
 
 import junit.framework.TestCase;
 import org.apache.tuscany.core.bootstrap.Bootstrapper;
@@ -82,7 +84,10 @@
         assertNotNull(serviceDefinition);
         assertEquals("service", serviceDefinition.getName());
         assertEquals(BasicInterface.class, serviceDefinition.getServiceContract().getInterfaceClass());
-        assertTrue(serviceDefinition.getBinding() instanceof SystemBindingDefinition);
+        Collection<BindingDefinition> bindings = serviceDefinition.getBindings();
+        for (BindingDefinition binding : bindings) {
+            assertTrue(binding instanceof SystemBindingDefinition);
+        }
 
         // check parse of <component>
         Map<String, ComponentDefinition<? extends Implementation<?>>> components = composite.getDeclaredComponents();

Modified: incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/TestUtils.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/TestUtils.java?view=diff&rev=491325&r1=491324&r2=491325
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/TestUtils.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/TestUtils.java Sat Dec 30 13:42:22 2006
@@ -18,9 +18,8 @@
  */
 package org.apache.tuscany.core.implementation;
 
-import java.util.HashMap;
+import java.util.ArrayList;
 import java.util.List;
-import java.util.Map;
 
 import org.apache.tuscany.spi.component.AtomicComponent;
 import org.apache.tuscany.spi.idl.InvalidServiceContractException;
@@ -29,7 +28,6 @@
 import org.apache.tuscany.spi.wire.InboundWire;
 
 import org.apache.tuscany.core.idl.java.JavaInterfaceProcessorRegistryImpl;
-import org.apache.tuscany.core.util.JavaIntrospectionHelper;
 import org.apache.tuscany.core.wire.InboundWireImpl;
 
 /**
@@ -41,21 +39,20 @@
     private TestUtils() {
     }
 
-    public static Map<String, InboundWire> populateInboundWires(AtomicComponent component,
-                                                                Map<String, InboundWire> wires)
+    public static List<InboundWire> populateInboundWires(AtomicComponent component, List<InboundWire> wires)
         throws InvalidServiceContractException {
-        for (InboundWire wire : wires.values()) {
+        for (InboundWire wire : wires) {
             wire.setContainer(component);
         }
         return wires;
     }
 
-    public static Map<String, InboundWire> createInboundWires(List<Class<?>> interfazes)
+    public static List<InboundWire> createInboundWires(List<Class<?>> interfazes)
         throws InvalidServiceContractException {
-        Map<String, InboundWire> wires = new HashMap<String, InboundWire>(interfazes.size());
+        List<InboundWire> wires = new ArrayList<InboundWire>(interfazes.size());
         for (Class<?> interfaze : interfazes) {
             InboundWire wire = createInboundWire(interfaze);
-            wires.put(JavaIntrospectionHelper.getBaseName(interfaze), wire);
+            wires.add(wire);
         }
         return wires;
     }

Modified: incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/AutowireResolutionTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/AutowireResolutionTestCase.java?view=diff&rev=491325&r1=491324&r2=491325
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/AutowireResolutionTestCase.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/AutowireResolutionTestCase.java Sat Dec 30 13:42:22 2006
@@ -68,7 +68,7 @@
     }
 
     /**
-     * Verify parent resolution strategy for application services
+     * Verify parent resolution strategy for application serviceBindings
      */
     public void testNamespaceIsolationAutowire() throws Exception {
         Foo foo = new Foo() {

Modified: incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/AutowireTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/AutowireTestCase.java?view=diff&rev=491325&r1=491324&r2=491325
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/AutowireTestCase.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/AutowireTestCase.java Sat Dec 30 13:42:22 2006
@@ -20,11 +20,11 @@
 
 import java.util.ArrayList;
 import java.util.List;
-import java.util.Map;
 
 import org.apache.tuscany.spi.component.AtomicComponent;
 import org.apache.tuscany.spi.component.CompositeComponent;
 import org.apache.tuscany.spi.component.Reference;
+import org.apache.tuscany.spi.component.ServiceBinding;
 import org.apache.tuscany.spi.component.Service;
 import org.apache.tuscany.spi.wire.InboundWire;
 
@@ -51,7 +51,7 @@
         AtomicComponent component = EasyMock.createMock(AtomicComponent.class);
         EasyMock.expect(component.getName()).andReturn("source").atLeastOnce();
         EasyMock.expect(component.isSystem()).andReturn(true).atLeastOnce();
-        Map<String, InboundWire> wires = TestUtils.createInboundWires(interfaces);
+        List<InboundWire> wires = TestUtils.createInboundWires(interfaces);
         EasyMock.expect(component.getInboundWires()).andReturn(wires).atLeastOnce();
         TestUtils.populateInboundWires(component, wires);
         EasyMock.replay(component);
@@ -77,7 +77,7 @@
         AtomicComponent component = EasyMock.createMock(AtomicComponent.class);
         EasyMock.expect(component.getName()).andReturn("source").atLeastOnce();
         EasyMock.expect(component.isSystem()).andReturn(false).atLeastOnce();
-        Map<String, InboundWire> wires = TestUtils.createInboundWires(interfaces);
+        List<InboundWire> wires = TestUtils.createInboundWires(interfaces);
         EasyMock.expect(component.getInboundWires()).andReturn(wires).atLeastOnce();
         TestUtils.populateInboundWires(component, wires);
 
@@ -99,20 +99,27 @@
         CompositeComponent parent = new CompositeComponentImpl("parent", null, null, true);
         parent.start();
 
+        ServiceBinding serviceBinding = EasyMock.createMock(ServiceBinding.class);
+        InboundWire wire = TestUtils.createInboundWire(Source.class);
+        wire.setContainer(serviceBinding);
+        EasyMock.expect(serviceBinding.getInboundWire()).andReturn(wire).atLeastOnce();
+        EasyMock.replay(serviceBinding);
+
+        List<ServiceBinding> bindings = new ArrayList<ServiceBinding>();
+        bindings.add(serviceBinding);
         Service service = EasyMock.createMock(Service.class);
         EasyMock.expect(service.getName()).andReturn("service").atLeastOnce();
         EasyMock.expect(service.isSystem()).andReturn(true).atLeastOnce();
-        InboundWire wire = TestUtils.createInboundWire(Source.class);
-        wire.setContainer(service);
-        EasyMock.expect(service.getInboundWire()).andReturn(wire).atLeastOnce();
+
+        EasyMock.expect(service.getServiceBindings()).andReturn(bindings).atLeastOnce();
         EasyMock.replay(service);
         parent.register(service);
 
         InboundWire source = parent.resolveSystemExternalAutowire(Source.class);
-        assertSame(service, source.getContainer());
+        assertSame(serviceBinding, source.getContainer());
         InboundWire source2 = parent.resolveSystemExternalAutowire(Source2.class);
         assertNull(source2);
-        EasyMock.verify(service);
+        EasyMock.verify(serviceBinding);
     }
 
     /**
@@ -122,20 +129,27 @@
         CompositeComponent parent = new CompositeComponentImpl("parent", null, null, true);
         parent.start();
 
+        ServiceBinding serviceBinding = EasyMock.createMock(ServiceBinding.class);
+        InboundWire wire = TestUtils.createInboundWire(Source.class);
+        wire.setContainer(serviceBinding);
+        EasyMock.expect(serviceBinding.getInboundWire()).andReturn(wire).atLeastOnce();
+        EasyMock.replay(serviceBinding);
+
+        List<ServiceBinding> bindings = new ArrayList<ServiceBinding>();
+        bindings.add(serviceBinding);
         Service service = EasyMock.createMock(Service.class);
         EasyMock.expect(service.getName()).andReturn("service").atLeastOnce();
         EasyMock.expect(service.isSystem()).andReturn(false).atLeastOnce();
-        InboundWire wire = TestUtils.createInboundWire(Source.class);
-        wire.setContainer(service);
-        EasyMock.expect(service.getInboundWire()).andReturn(wire).atLeastOnce();
+
+        EasyMock.expect(service.getServiceBindings()).andReturn(bindings).atLeastOnce();
         EasyMock.replay(service);
         parent.register(service);
 
         InboundWire source = parent.resolveExternalAutowire(Source.class);
-        assertSame(service, source.getContainer());
+        assertSame(serviceBinding, source.getContainer());
         InboundWire source2 = parent.resolveExternalAutowire(Source2.class);
         assertNull(source2);
-        EasyMock.verify(service);
+        EasyMock.verify(serviceBinding);
     }
 
 

Modified: incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeBuilderTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeBuilderTestCase.java?view=diff&rev=491325&r1=491324&r2=491325
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeBuilderTestCase.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeBuilderTestCase.java Sat Dec 30 13:42:22 2006
@@ -19,14 +19,11 @@
 package org.apache.tuscany.core.implementation.composite;
 
 import java.net.URI;
-import java.util.HashMap;
-import java.util.Map;
 
 import org.apache.tuscany.spi.component.AtomicComponent;
 import org.apache.tuscany.spi.component.CompositeComponent;
-import org.apache.tuscany.spi.component.ScopeContainer;
+import org.apache.tuscany.spi.component.ScopeContainerMonitor;
 import org.apache.tuscany.spi.component.Service;
-import org.apache.tuscany.spi.component.TargetException;
 import org.apache.tuscany.spi.deployer.DeploymentContext;
 import org.apache.tuscany.spi.idl.java.JavaInterfaceProcessorRegistry;
 import org.apache.tuscany.spi.idl.java.JavaServiceContract;
@@ -35,7 +32,7 @@
 import org.apache.tuscany.spi.implementation.java.JavaMappedReference;
 import org.apache.tuscany.spi.implementation.java.JavaMappedService;
 import org.apache.tuscany.spi.implementation.java.PojoComponentType;
-import org.apache.tuscany.spi.model.BindlessServiceDefinition;
+import org.apache.tuscany.spi.model.BoundServiceDefinition;
 import org.apache.tuscany.spi.model.ComponentDefinition;
 import org.apache.tuscany.spi.model.CompositeComponentType;
 import org.apache.tuscany.spi.model.CompositeImplementation;
@@ -48,7 +45,7 @@
 
 import junit.framework.TestCase;
 import org.apache.tuscany.core.builder.BuilderRegistryImpl;
-import org.apache.tuscany.core.builder.ConnectorImpl;
+import org.apache.tuscany.core.component.scope.CompositeScopeContainer;
 import org.apache.tuscany.core.deployer.RootDeploymentContext;
 import org.apache.tuscany.core.idl.java.JavaInterfaceProcessorRegistryImpl;
 import org.apache.tuscany.core.implementation.java.JavaComponentBuilder;
@@ -60,7 +57,6 @@
 import org.apache.tuscany.core.mock.component.TargetImpl;
 import org.apache.tuscany.core.wire.jdk.JDKWireService;
 import org.easymock.EasyMock;
-import org.easymock.IAnswer;
 
 /**
  * @version $$Rev$$ $$Date$$
@@ -68,14 +64,8 @@
 public class CompositeBuilderTestCase extends TestCase {
     private DeploymentContext deploymentContext;
 
-    protected void setUp() throws Exception {
-        super.setUp();
-        ScopeContainer mock = createMock();
-        deploymentContext = new RootDeploymentContext(null, null, mock, null);
-    }
-
     @SuppressWarnings("unchecked")
-    public void testBuildConnect() throws Exception {
+    public void testBuild() throws Exception {
         CompositeComponent parent = new CompositeComponentImpl(null, null, null, null);
 
         CompositeBuilder builder = new CompositeBuilder();
@@ -94,9 +84,6 @@
         CompositeComponent component =
             (CompositeComponent) builder.build(parent, createTopComponentDef(), deploymentContext);
 
-        ConnectorImpl connector = new ConnectorImpl();
-        connector.connect(component);
-
         deploymentContext.getCompositeScope().start();
         component.start();
         CompositeComponent sourceComponent = (CompositeComponent) component.getChild("SourceComponent");
@@ -131,7 +118,7 @@
         JavaServiceContract targetContract = registry.introspect(Target.class);
         reference.setServiceContract(targetContract);
         innerType.add(reference);
-        BindlessServiceDefinition service = new BindlessServiceDefinition();
+        BoundServiceDefinition service = new BoundServiceDefinition();
         service.setName("InnerSourceService");
         JavaServiceContract sourceContract = registry.introspect(Source.class);
         service.setServiceContract(sourceContract);
@@ -211,26 +198,11 @@
         return new ComponentDefinition<JavaImplementation>("TargetComponent", targetImpl);
     }
 
-    private ScopeContainer createMock() throws TargetException {
-        ScopeContainer container = EasyMock.createMock(ScopeContainer.class);
-        container.start();
-        container.register(EasyMock.isA(AtomicComponent.class));
-        EasyMock.expectLastCall().anyTimes();
-        EasyMock.expect(container.getScope()).andReturn(Scope.COMPOSITE).anyTimes();
-        EasyMock.expect(container.getInstance(EasyMock.isA(AtomicComponent.class))).andAnswer(new IAnswer<Object>() {
-            private Map<AtomicComponent, Object> cache = new HashMap<AtomicComponent, Object>();
-
-            public Object answer() throws Throwable {
-                AtomicComponent component = (AtomicComponent) EasyMock.getCurrentArguments()[0];
-                Object instance = cache.get(component);
-                if (instance == null) {
-                    instance = component.createInstance();
-                    cache.put(component, instance);
-                }
-                return instance;
-            }
-        });
-        EasyMock.replay(container);
-        return container;
+    protected void setUp() throws Exception {
+        super.setUp();
+        ScopeContainerMonitor monitor = EasyMock.createNiceMock(ScopeContainerMonitor.class);
+        CompositeScopeContainer container = new CompositeScopeContainer(monitor);
+        deploymentContext = new RootDeploymentContext(null, null, container, null);
     }
+    
 }

Modified: incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeComponentImplBasicTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeComponentImplBasicTestCase.java?view=diff&rev=491325&r1=491324&r2=491325
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeComponentImplBasicTestCase.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeComponentImplBasicTestCase.java Sat Dec 30 13:42:22 2006
@@ -18,12 +18,14 @@
  */
 package org.apache.tuscany.core.implementation.composite;
 
+import java.util.Collections;
+
+import org.apache.tuscany.spi.component.AtomicComponent;
 import org.apache.tuscany.spi.component.CompositeComponent;
 import org.apache.tuscany.spi.component.Reference;
 import org.apache.tuscany.spi.component.Service;
 import org.apache.tuscany.spi.event.Event;
 import org.apache.tuscany.spi.event.RuntimeEventListener;
-import org.apache.tuscany.spi.extension.ServiceExtension;
 import org.apache.tuscany.spi.idl.InvalidServiceContractException;
 import org.apache.tuscany.spi.model.Scope;
 import org.apache.tuscany.spi.wire.InboundWire;
@@ -43,6 +45,7 @@
  * @version $Rev$ $Date$
  */
 public class CompositeComponentImplBasicTestCase extends TestCase {
+    private AtomicComponent component;
 
     public void testGetScope() {
         CompositeComponent composite = new CompositeComponentImpl("parent", null, null, null);
@@ -51,31 +54,48 @@
 
     public void testGetChildren() throws Exception {
         CompositeComponent composite = new CompositeComponentImpl("parent", null, null, null);
-        composite.register(new ServiceExtension("foo", null));
+        composite.register(component);
         Assert.assertEquals(1, composite.getChildren().size());
     }
 
     public void testGetServices() throws Exception {
         CompositeComponent composite = new CompositeComponentImpl("parent", null, null, null);
-        ServiceExtension extension = new ServiceExtension("foo", null);
-        InboundWire wire = TestUtils.createInboundWire(Foo.class);
-        wire.setContainer(extension);
-        extension.setInboundWire(wire);
-        composite.register(extension);
+        Service service = EasyMock.createMock(Service.class);
+        EasyMock.expect(service.getName()).andReturn("foo").atLeastOnce();
+        EasyMock.expect(service.isSystem()).andReturn(false).atLeastOnce();
+        service.getServiceBindings();
+        EasyMock.expectLastCall().andReturn(Collections.emptyList()).atLeastOnce();
+        EasyMock.replay(service);
+        composite.register(service);
         composite.register(getReference("bar"));
         Assert.assertEquals(1, composite.getServices().size());
     }
 
     public void testGetService() throws Exception {
         CompositeComponent composite = new CompositeComponentImpl("parent", null, null, null);
-        composite.register(new ServiceExtension("foo", null));
+        Service service = EasyMock.createMock(Service.class);
+        EasyMock.expect(service.getName()).andReturn("foo").atLeastOnce();
+        EasyMock.expect(service.isSystem()).andReturn(false).atLeastOnce();
+        service.start();
+        service.getServiceBindings();
+        EasyMock.expectLastCall().andReturn(Collections.emptyList()).atLeastOnce();
+        EasyMock.replay(service);
+        composite.register(service);
         composite.start();
         assertNotNull(composite.getService("foo"));
     }
 
     public void testServiceNotFound() throws Exception {
         CompositeComponent composite = new CompositeComponentImpl("parent", null, null, null);
-        composite.register(new ServiceExtension("foo", null));
+        Service service = EasyMock.createMock(Service.class);
+        EasyMock.expect(service.getName()).andReturn("foo").atLeastOnce();
+        EasyMock.expect(service.isSystem()).andReturn(false).atLeastOnce();
+        service.start();
+        service.getServiceBindings();
+        EasyMock.expectLastCall().andReturn(Collections.emptyList()).atLeastOnce();
+        EasyMock.replay(service);
+
+        composite.register(service);
         composite.start();
         assertNull(composite.getService("bar"));
     }
@@ -89,7 +109,13 @@
 
     public void testReferencesServices() throws Exception {
         CompositeComponent composite = new CompositeComponentImpl("parent", null, null, null);
-        composite.register(new ServiceExtension("foo", null));
+        Service service = EasyMock.createMock(Service.class);
+        EasyMock.expect(service.getName()).andReturn("foo").atLeastOnce();
+        EasyMock.expect(service.isSystem()).andReturn(false).atLeastOnce();
+        service.getServiceBindings();
+        EasyMock.expectLastCall().andReturn(Collections.emptyList()).atLeastOnce();
+        EasyMock.replay(service);
+        composite.register(service);
         composite.register(getReference("bar"));
         Assert.assertEquals(1, composite.getReferences().size());
     }
@@ -129,19 +155,14 @@
         return reference;
     }
 
-    private Service getService(String name, Class<?> interfaze) throws InvalidServiceContractException {
-        Service service = createMock(Service.class);
-        EasyMock.expect(service.isSystem()).andReturn(false).atLeastOnce();
-        service.getName();
-        expectLastCall().andReturn(name).anyTimes();
-        InboundWire wire = TestUtils.createInboundWire(interfaze);
-        wire.setContainer(service);
-        EasyMock.expect(service.getInboundWire()).andReturn(wire).atLeastOnce();
-        replay(service);
-        return service;
-    }
-
-    private interface Foo {
+    protected void setUp() throws Exception {
+        super.setUp();
+        component = EasyMock.createMock(AtomicComponent.class);
+        EasyMock.expect(component.getName()).andReturn("foo").atLeastOnce();
+        EasyMock.expect(component.isSystem()).andReturn(false).atLeastOnce();
+        component.getInboundWires();
+        EasyMock.expectLastCall().andReturn(Collections.emptyList()).atLeastOnce();
+        EasyMock.replay(component);
     }
 
     private interface Bar {

Modified: incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeComponentImplSystemWireTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeComponentImplSystemWireTestCase.java?view=diff&rev=491325&r1=491324&r2=491325
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeComponentImplSystemWireTestCase.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeComponentImplSystemWireTestCase.java Sat Dec 30 13:42:22 2006
@@ -44,7 +44,8 @@
 public class CompositeComponentImplSystemWireTestCase extends TestCase {
 
     /**
-     * Verifies system services in a CompositeComponentImpl are wired during the parent composite's prepare callback
+     * Verifies system serviceBindings in a CompositeComponentImpl are wired during the parent composite's prepare
+     * callback
      */
     public void testSystemServiceWire() throws Exception {
         InboundWire inbound = EasyMock.createMock(InboundWire.class);
@@ -71,7 +72,7 @@
         EasyMock.expect(source.getName()).andReturn("source").atLeastOnce();
         EasyMock.expect(source.getOutboundWires()).andReturn(wireMap);
         source.getInboundWires();
-        EasyMock.expectLastCall().andReturn(Collections.emptyMap()).atLeastOnce();
+        EasyMock.expectLastCall().andReturn(Collections.emptyList()).atLeastOnce();
         EasyMock.expect(source.isSystem()).andReturn(true).atLeastOnce();
         EasyMock.expect(source.getParent()).andReturn(parent).atLeastOnce();
 
@@ -86,8 +87,8 @@
         AtomicComponent target = EasyMock.createMock(AtomicComponent.class);
         EasyMock.expect(target.getName()).andReturn("target").atLeastOnce();
         EasyMock.expect(target.getInboundWire("bar")).andReturn(inbound).atLeastOnce();
-        Map<String, InboundWire> inboundWires = new HashMap<String, InboundWire>();
-        inboundWires.put("bar", inbound);
+        List<InboundWire> inboundWires = new ArrayList<InboundWire>();
+        inboundWires.add(inbound);
         EasyMock.expect(target.getInboundWires()).andReturn(inboundWires).atLeastOnce();
         EasyMock.expect(target.getScope()).andReturn(Scope.COMPOSITE).atLeastOnce();
         EasyMock.expect(target.getParent()).andReturn(parent).atLeastOnce();
@@ -133,8 +134,8 @@
         CompositeComponent parent = new CompositeComponentImpl("foo", "foo", null, new ConnectorImpl(), null);
         AtomicComponent source = EasyMock.createMock(AtomicComponent.class);
         EasyMock.expect(source.getName()).andReturn("source").atLeastOnce();
-        Map<String, InboundWire> inboundWires = new HashMap<String, InboundWire>();
-        inboundWires.put("bar", inbound);
+        List<InboundWire> inboundWires = new ArrayList<InboundWire>();
+        inboundWires.add(inbound);
         source.getInboundWires();
         EasyMock.expectLastCall().andReturn(inboundWires).atLeastOnce();
         EasyMock.expect(source.getOutboundWires()).andReturn(wireMap);
@@ -146,7 +147,7 @@
 
         AtomicComponent target = EasyMock.createMock(AtomicComponent.class);
         EasyMock.expect(target.getName()).andReturn("target").atLeastOnce();
-        inboundWires.put("bar", inbound);
+        inboundWires.add(inbound);
         EasyMock.expect(target.getInboundWires()).andReturn(inboundWires).atLeastOnce();
         EasyMock.expect(target.isSystem()).andReturn(false).atLeastOnce();
         EasyMock.replay(target);

Modified: incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeComponentImplTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeComponentImplTestCase.java?view=diff&rev=491325&r1=491324&r2=491325
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeComponentImplTestCase.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeComponentImplTestCase.java Sat Dec 30 13:42:22 2006
@@ -20,7 +20,6 @@
 
 import java.util.ArrayList;
 import java.util.List;
-import java.util.Map;
 
 import org.apache.tuscany.spi.component.AtomicComponent;
 import org.apache.tuscany.spi.component.CompositeComponent;
@@ -47,7 +46,7 @@
         AtomicComponent component = EasyMock.createMock(AtomicComponent.class);
         EasyMock.expect(component.getName()).andReturn("bar").atLeastOnce();
         EasyMock.expect(component.isSystem()).andReturn(true).atLeastOnce();
-        Map<String, InboundWire> wires = TestUtils.createInboundWires(services);
+        List<InboundWire> wires = TestUtils.createInboundWires(services);
         EasyMock.expect(component.getInboundWires()).andReturn(wires).atLeastOnce();
         EasyMock.replay(component);
         parent.register(component);
@@ -63,7 +62,7 @@
         AtomicComponent component = EasyMock.createMock(AtomicComponent.class);
         EasyMock.expect(component.getName()).andReturn("bar").atLeastOnce();
         EasyMock.expect(component.isSystem()).andReturn(false).atLeastOnce();
-        Map<String, InboundWire> wires = TestUtils.createInboundWires(services);
+        List<InboundWire> wires = TestUtils.createInboundWires(services);
         EasyMock.expect(component.getInboundWires()).andReturn(wires).atLeastOnce();
         EasyMock.replay(component);
         parent.register(component);
@@ -82,7 +81,7 @@
         AtomicComponent component = EasyMock.createMock(AtomicComponent.class);
         EasyMock.expect(component.getName()).andReturn("bar").atLeastOnce();
         EasyMock.expect(component.isSystem()).andReturn(true).atLeastOnce();
-        Map<String, InboundWire> wires = TestUtils.createInboundWires(services);
+        List<InboundWire> wires = TestUtils.createInboundWires(services);
         EasyMock.expect(component.getInboundWires()).andReturn(wires).atLeastOnce();
         EasyMock.replay(component);
         parent.register(component);
@@ -105,7 +104,7 @@
         EasyMock.expect(component.getName()).andReturn("bar").atLeastOnce();
         EasyMock.expect(component.isSystem()).andReturn(true).atLeastOnce();
         component.stop();
-        Map<String, InboundWire> wires = TestUtils.createInboundWires(services);
+        List<InboundWire> wires = TestUtils.createInboundWires(services);
         EasyMock.expect(component.getInboundWires()).andReturn(wires).atLeastOnce();
         EasyMock.replay(component);
         parent.register(component);
@@ -122,7 +121,7 @@
         component.start();
         EasyMock.expect(component.getName()).andReturn("bar").atLeastOnce();
         EasyMock.expect(component.isSystem()).andReturn(false).atLeastOnce();
-        Map<String, InboundWire> wires = TestUtils.createInboundWires(services);
+        List<InboundWire> wires = TestUtils.createInboundWires(services);
         EasyMock.expect(component.getInboundWires()).andReturn(wires).atLeastOnce();
         component.stop();
         EasyMock.replay(component);
@@ -140,7 +139,7 @@
         component.start();
         EasyMock.expect(component.getName()).andReturn("bar").atLeastOnce();
         EasyMock.expect(component.isSystem()).andReturn(true).atLeastOnce();
-        Map<String, InboundWire> wires = TestUtils.createInboundWires(services);
+        List<InboundWire> wires = TestUtils.createInboundWires(services);
         EasyMock.expect(component.getInboundWires()).andReturn(wires).atLeastOnce();
         component.stop();
         EasyMock.replay(component);
@@ -160,7 +159,7 @@
         AtomicComponent component = EasyMock.createMock(AtomicComponent.class);
         component.start();
         EasyMock.expect(component.getName()).andReturn("bar").atLeastOnce();
-        Map<String, InboundWire> wires = TestUtils.createInboundWires(services);
+        List<InboundWire> wires = TestUtils.createInboundWires(services);
         TestUtils.populateInboundWires(component, wires);
         EasyMock.expect(component.getInboundWires()).andReturn(wires).atLeastOnce();
         EasyMock.expect(component.isSystem()).andReturn(false).atLeastOnce();

Modified: incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeComponentResolutionTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeComponentResolutionTestCase.java?view=diff&rev=491325&r1=491324&r2=491325
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeComponentResolutionTestCase.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeComponentResolutionTestCase.java Sat Dec 30 13:42:22 2006
@@ -19,8 +19,8 @@
 package org.apache.tuscany.core.implementation.composite;
 
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.List;
-import java.util.Map;
 
 import org.apache.tuscany.spi.component.AtomicComponent;
 import org.apache.tuscany.spi.component.CompositeComponent;
@@ -47,7 +47,7 @@
         AtomicComponent component = EasyMock.createMock(AtomicComponent.class);
         EasyMock.expect(component.getName()).andReturn("source").atLeastOnce();
         EasyMock.expect(component.isSystem()).andReturn(true).atLeastOnce();
-        Map<String, InboundWire> wires = TestUtils.createInboundWires(interfaces);
+        List<InboundWire> wires = TestUtils.createInboundWires(interfaces);
         TestUtils.populateInboundWires(component, wires);
         EasyMock.expect(component.getInboundWires()).andReturn(wires).atLeastOnce();
         EasyMock.replay(component);
@@ -65,7 +65,7 @@
         AtomicComponent component = EasyMock.createMock(AtomicComponent.class);
         EasyMock.expect(component.getName()).andReturn("source").atLeastOnce();
         EasyMock.expect(component.isSystem()).andReturn(false).atLeastOnce();
-        Map<String, InboundWire> wires = TestUtils.createInboundWires(interfaces);
+        List<InboundWire> wires = TestUtils.createInboundWires(interfaces);
         TestUtils.populateInboundWires(component, wires);
         EasyMock.expect(component.getInboundWires()).andReturn(wires).atLeastOnce();
         EasyMock.replay(component);
@@ -84,7 +84,8 @@
         EasyMock.expect(service.isSystem()).andReturn(false).atLeastOnce();
         InboundWire wire = TestUtils.createInboundWire(Source.class);
         wire.setContainer(service);
-        EasyMock.expect(service.getInboundWire()).andReturn(wire).atLeastOnce();
+        service.getServiceBindings();
+        EasyMock.expectLastCall().andReturn(Collections.emptyList()).atLeastOnce();
         EasyMock.replay(service);
         parent.register(service);
         assertNotNull(parent.getService("source"));
@@ -93,18 +94,19 @@
     }
 
     public void testSystemGetService() throws Exception {
-        CompositeComponent parent = new CompositeComponentImpl("foo", null, null, true);
+        CompositeComponent parent = new CompositeComponentImpl("foo", null, null, null);
         parent.start();
         Service service = EasyMock.createMock(Service.class);
         EasyMock.expect(service.getName()).andReturn("source").atLeastOnce();
         EasyMock.expect(service.isSystem()).andReturn(true).atLeastOnce();
         InboundWire wire = TestUtils.createInboundWire(Source.class);
         wire.setContainer(service);
-        EasyMock.expect(service.getInboundWire()).andReturn(wire).atLeastOnce();
+        service.getServiceBindings();
+        EasyMock.expectLastCall().andReturn(Collections.emptyList()).atLeastOnce();
         EasyMock.replay(service);
         parent.register(service);
-        assertNotNull(parent.getSystemService("source"));
         assertNull(parent.getService("source"));
+        assertNotNull(parent.getSystemService("source"));
         EasyMock.verify(service);
     }
 

Modified: incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeLifecycleTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeLifecycleTestCase.java?view=diff&rev=491325&r1=491324&r2=491325
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeLifecycleTestCase.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeLifecycleTestCase.java Sat Dec 30 13:42:22 2006
@@ -20,7 +20,6 @@
 
 import java.util.ArrayList;
 import java.util.List;
-import java.util.Map;
 
 import org.apache.tuscany.spi.component.AtomicComponent;
 import org.apache.tuscany.spi.component.CompositeComponent;
@@ -56,7 +55,7 @@
         EasyMock.expect(component.getName()).andReturn("source").atLeastOnce();
         EasyMock.expect(component.isSystem()).andReturn(true).atLeastOnce();
 
-        Map<String, InboundWire> wires = TestUtils.createInboundWires(interfaces);
+        List<InboundWire> wires = TestUtils.createInboundWires(interfaces);
         TestUtils.populateInboundWires(component, wires);
         EasyMock.expect(component.getInboundWires()).andReturn(wires).atLeastOnce();
 
@@ -84,7 +83,7 @@
         EasyMock.expect(component.getName()).andReturn("source").atLeastOnce();
         EasyMock.expect(component.isSystem()).andReturn(false).atLeastOnce();
 
-        Map<String, InboundWire> wires = TestUtils.createInboundWires(interfaces);
+        List<InboundWire> wires = TestUtils.createInboundWires(interfaces);
         TestUtils.populateInboundWires(component, wires);
         EasyMock.expect(component.getInboundWires()).andReturn(wires).atLeastOnce();
 

Modified: incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeLoaderWireResolutionTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeLoaderWireResolutionTestCase.java?view=diff&rev=491325&r1=491324&r2=491325
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeLoaderWireResolutionTestCase.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeLoaderWireResolutionTestCase.java Sat Dec 30 13:42:22 2006
@@ -24,8 +24,6 @@
 
 import org.apache.tuscany.spi.implementation.java.PojoComponentType;
 import org.apache.tuscany.spi.loader.InvalidWireException;
-import org.apache.tuscany.spi.model.BindingDefinition;
-import org.apache.tuscany.spi.model.BindlessServiceDefinition;
 import org.apache.tuscany.spi.model.BoundServiceDefinition;
 import org.apache.tuscany.spi.model.ComponentDefinition;
 import org.apache.tuscany.spi.model.CompositeComponentType;
@@ -51,14 +49,11 @@
         componentType.setName("TestComposite");
         //add a service to the composite
         ServiceDefinition serviceDefn = new ServiceDefinition("compositeService1", null, true);
-        BindlessServiceDefinition bindlessSvcDefn = new BindlessServiceDefinition("bindlessSvc", null, true, null);
-        BoundServiceDefinition<BindingDefinition> boundSvcDefn =
-            new BoundServiceDefinition<BindingDefinition>("boundSvc", null, true, null, null);
-        BoundServiceDefinition<BindingDefinition> boundSvcDefnWithTarget =
-            new BoundServiceDefinition<BindingDefinition>("boundSvcWithTarget", null, true, null, new URI("orgTarget"));
+        BoundServiceDefinition boundSvcDefn = new BoundServiceDefinition("boundSvc", null, null, true, null);
+        BoundServiceDefinition boundSvcDefnWithTarget =
+            new BoundServiceDefinition("boundSvcWithTarget", null, null, true, new URI("orgTarget"));
         componentType.add(serviceDefn);
         componentType.add(boundSvcDefn);
-        componentType.add(bindlessSvcDefn);
         componentType.add(boundSvcDefnWithTarget);
 
         ReferenceDefinition compositeReference = new ReferenceDefinition("compositeReference", null);

Modified: incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositePropagationTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositePropagationTestCase.java?view=diff&rev=491325&r1=491324&r2=491325
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositePropagationTestCase.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositePropagationTestCase.java Sat Dec 30 13:42:22 2006
@@ -20,7 +20,6 @@
 
 import java.util.ArrayList;
 import java.util.List;
-import java.util.Map;
 
 import org.apache.tuscany.spi.component.AtomicComponent;
 import org.apache.tuscany.spi.component.CompositeComponent;
@@ -51,7 +50,7 @@
         expect(component.getName()).andReturn("source").anyTimes();
         component.stop();
         EasyMock.expect(component.isSystem()).andReturn(true).atLeastOnce();
-        Map<String, InboundWire> wires = TestUtils.createInboundWires(interfaces);
+        List<InboundWire> wires = TestUtils.createInboundWires(interfaces);
         TestUtils.populateInboundWires(component, wires);
         EasyMock.expect(component.getInboundWires()).andReturn(wires).atLeastOnce();
 
@@ -69,7 +68,7 @@
         expect(component.getName()).andReturn("source").anyTimes();
         component.stop();
         EasyMock.expect(component.isSystem()).andReturn(false).atLeastOnce();
-        Map<String, InboundWire> wires = TestUtils.createInboundWires(interfaces);
+        List<InboundWire> wires = TestUtils.createInboundWires(interfaces);
         TestUtils.populateInboundWires(component, wires);
         EasyMock.expect(component.getInboundWires()).andReturn(wires).atLeastOnce();
         replay(component);

Modified: incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/DuplicateRegistrationTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/DuplicateRegistrationTestCase.java?view=diff&rev=491325&r1=491324&r2=491325
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/DuplicateRegistrationTestCase.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/DuplicateRegistrationTestCase.java Sat Dec 30 13:42:22 2006
@@ -20,7 +20,6 @@
 
 import java.util.ArrayList;
 import java.util.List;
-import java.util.Map;
 
 import org.apache.tuscany.spi.component.AtomicComponent;
 import org.apache.tuscany.spi.component.CompositeComponent;
@@ -49,7 +48,7 @@
         EasyMock.expect(component1.getName()).andReturn("source").atLeastOnce();
         EasyMock.expect(component1.isSystem()).andReturn(true).atLeastOnce();
         component1.stop();
-        Map<String, InboundWire> wires = TestUtils.createInboundWires(interfaces);
+        List<InboundWire> wires = TestUtils.createInboundWires(interfaces);
         TestUtils.populateInboundWires(component1, wires);
         EasyMock.expect(component1.getInboundWires()).andReturn(wires).atLeastOnce();
         EasyMock.replay(component1);
@@ -77,7 +76,7 @@
         AtomicComponent component = EasyMock.createMock(AtomicComponent.class);
         EasyMock.expect(component.getName()).andReturn("bar").atLeastOnce();
         EasyMock.expect(component.isSystem()).andReturn(true).atLeastOnce();
-        Map<String, InboundWire> wires = TestUtils.createInboundWires(services);
+        List<InboundWire> wires = TestUtils.createInboundWires(services);
         TestUtils.populateInboundWires(component, wires);
         EasyMock.expect(component.getInboundWires()).andReturn(wires).atLeastOnce();
         EasyMock.replay(component);

Added: incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/ServiceImplTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/ServiceImplTestCase.java?view=auto&rev=491325
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/ServiceImplTestCase.java (added)
+++ incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/ServiceImplTestCase.java Sat Dec 30 13:42:22 2006
@@ -0,0 +1,61 @@
+/*
+ * 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.tuscany.core.implementation.composite;
+
+import org.apache.tuscany.spi.component.Service;
+import org.apache.tuscany.spi.component.ServiceBinding;
+
+import junit.framework.TestCase;
+import org.easymock.EasyMock;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ServiceImplTestCase extends TestCase {
+
+    public void testStart() {
+        ServiceBinding binding = EasyMock.createMock(ServiceBinding.class);
+        binding.setService(EasyMock.isA(Service.class));
+        binding.start();
+        EasyMock.replay(binding);
+        Service service = new ServiceImpl(null, null, null);
+        service.addServiceBinding(binding);
+        service.start();
+        EasyMock.verify(binding);
+
+    }
+
+    public void testStop() {
+        ServiceBinding binding = EasyMock.createMock(ServiceBinding.class);
+        binding.setService(EasyMock.isA(Service.class));
+        binding.stop();
+        EasyMock.replay(binding);
+        Service service = new ServiceImpl(null, null, null);
+        service.addServiceBinding(binding);
+        service.stop();
+        EasyMock.verify(binding);
+
+    }
+
+    public void testIsSystem() {
+        Service service = new ServiceImpl(null, null, null, null, true);
+        assertTrue(service.isSystem());
+    }
+
+}

Propchange: incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/ServiceImplTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/ServiceImplTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/HeuristicPojoProcessorTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/HeuristicPojoProcessorTestCase.java?view=diff&rev=491325&r1=491324&r2=491325
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/HeuristicPojoProcessorTestCase.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/HeuristicPojoProcessorTestCase.java Sat Dec 30 13:42:22 2006
@@ -176,7 +176,7 @@
         JavaMappedProperty<?> prop2 = new JavaMappedProperty();
         prop2.setName("string2");
         type.add(prop2);
-        processor.visitEnd(null, ServiceImpl.class, type, null);
+        processor.visitEnd(null, MockService.class, type, null);
         assertEquals(1, type.getServices().size());
     }
 
@@ -257,7 +257,7 @@
         String setInvalid3(String str); // return should be void
     }
 
-    public static class ServiceImpl implements PropertyInterface, RefInterface, HeuristicServiceInterface {
+    public static class MockService implements PropertyInterface, RefInterface, HeuristicServiceInterface {
 
         @Property
         public void setString1(String val) {

Modified: incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/system/builder/SystemBindingBuilderTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/system/builder/SystemBindingBuilderTestCase.java?view=diff&rev=491325&r1=491324&r2=491325
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/system/builder/SystemBindingBuilderTestCase.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/system/builder/SystemBindingBuilderTestCase.java Sat Dec 30 13:42:22 2006
@@ -23,7 +23,7 @@
 import org.apache.tuscany.spi.builder.BuilderRegistry;
 import org.apache.tuscany.spi.component.AtomicComponent;
 import org.apache.tuscany.spi.component.CompositeComponent;
-import org.apache.tuscany.spi.component.Service;
+import org.apache.tuscany.spi.component.ServiceBinding;
 import org.apache.tuscany.spi.deployer.DeploymentContext;
 import org.apache.tuscany.spi.model.BoundServiceDefinition;
 import org.apache.tuscany.spi.model.ServiceContract;
@@ -46,16 +46,16 @@
         EasyMock.replay(parent);
         DeploymentContext context = EasyMock.createMock(DeploymentContext.class);
         EasyMock.replay(context);
-        BoundServiceDefinition<SystemBindingDefinition> definition = new BoundServiceDefinition<SystemBindingDefinition>();
+        BoundServiceDefinition definition = new BoundServiceDefinition();
         definition.setName("bar");
         definition.setTarget(new URI("foo"));
         ServiceContract<Object> contract = new ServiceContract<Object>(Object.class) {
         };
         definition.setServiceContract(contract);
-        Service service = builder.build(parent, definition, context);
-        assertEquals("bar", service.getName());
-        assertEquals(contract, service.getBindingServiceContract());
-        assertEquals(parent, service.getParent());
+        ServiceBinding serviceBinding = builder.build(parent, definition, null, context);
+        assertEquals("bar", serviceBinding.getName());
+        assertEquals(contract, serviceBinding.getBindingServiceContract());
+        assertEquals(parent, serviceBinding.getParent());
     }
 
     public void testRegister() {



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