tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmar...@apache.org
Subject svn commit: r449095 - in /incubator/tuscany/java/sca: kernel/core/src/main/java/org/apache/tuscany/core/builder/ kernel/core/src/test/java/org/apache/tuscany/core/builder/ kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/integratio...
Date Fri, 22 Sep 2006 21:22:12 GMT
Author: jmarino
Date: Fri Sep 22 14:22:11 2006
New Revision: 449095

URL: http://svn.apache.org/viewvc?view=rev&rev=449095
Log:
refactor connector implementation and interface signature; more test cases

Modified:
    incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/builder/ConnectorImpl.java
    incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/builder/ConnectorImplTestCase.java
    incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/builder/ConnectorPostProcessTestCase.java
    incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/builder/OutboundToInboundConnectTestCase.java
    incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/integration/component/CallbackInvocationTestCase.java
    incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/integration/component/OutboundWireToJavaTestCase.java
    incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/integration/implementation/system/builder/SystemBuilderWireTestCase.java
    incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/Connector.java
    incubator/tuscany/java/sca/services/containers/container.spring/src/test/java/org/apache/tuscany/container/spring/SpringTestUtils.java
    incubator/tuscany/java/sca/services/containers/container.spring/src/test/java/org/apache/tuscany/container/spring/impl/ServiceInvocationTestCase.java

Modified: incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/builder/ConnectorImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/builder/ConnectorImpl.java?view=diff&rev=449095&r1=449094&r2=449095
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/builder/ConnectorImpl.java
(original)
+++ incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/builder/ConnectorImpl.java
Fri Sep 22 14:22:11 2006
@@ -51,7 +51,6 @@
 import org.apache.tuscany.core.wire.BridgingInterceptor;
 import org.apache.tuscany.core.wire.InvokerInterceptor;
 import org.apache.tuscany.core.wire.OutboundAutowire;
-import org.apache.tuscany.core.wire.OutboundInvocationChainImpl;
 
 /**
  * The default connector implmentation
@@ -109,8 +108,9 @@
             for (InboundInvocationChain chain : inboundChains.values()) {
                 //TODO handle async
                 // add target invoker on inbound side
-                TargetInvoker invoker =
-                    reference.createTargetInvoker(inboundWire.getServiceContract(), chain.getOperation());
+                ServiceContract contract = inboundWire.getServiceContract();
+                Operation operation = chain.getOperation();
+                TargetInvoker invoker = reference.createTargetInvoker(contract, operation);
                 chain.setTargetInvoker(invoker);
                 chain.prepare();
             }
@@ -125,15 +125,14 @@
             connect(service, outboundWire);
             // NB: this connect must be done after the outbound service chain is connected
to its target above
             if (!(source instanceof CompositeService)) {
-                //REVIEW JFM: why is this special for composites?
+                //REVIEW JFM: do we need this to be special for composites?
                 connect(inboundWire, outboundWire, true);
             }
         }
     }
 
-    public void connect(InboundWire sourceWire,
-                        OutboundWire targetWire,
-                        boolean optimizable) throws BuilderConfigException {
+    public void connect(InboundWire sourceWire, OutboundWire targetWire, boolean optimizable)
+        throws BuilderConfigException {
         if (postProcessorRegistry != null) {
             // run wire post-processors
             postProcessorRegistry.process(sourceWire, targetWire);
@@ -157,19 +156,16 @@
     }
 
     /**
-     * Connects the source wire to a corresponding target wire
+     * Connects the source outbound wire to a corresponding target inbound wire
      *
-     * @param source      the owner of the source wire
-     * @param target      the owner of the target wire
      * @param sourceWire  the source wire to connect
      * @param targetWire  the target wire to connect to
      * @param optimizable true if the wire connection can be optimized
      */
-    public void connect(SCAObject source,
-                        SCAObject target,
-                        OutboundWire sourceWire,
-                        InboundWire targetWire,
-                        boolean optimizable) {
+    void connect(OutboundWire sourceWire, InboundWire targetWire, boolean optimizable) {
+        SCAObject source = sourceWire.getContainer();
+        SCAObject target = targetWire.getContainer();
+        ServiceContract contract = sourceWire.getServiceContract();
         if (postProcessorRegistry != null) {
             // run wire post-processors
             postProcessorRegistry.process(sourceWire, targetWire);
@@ -182,9 +178,8 @@
             sourceWire.setTargetWire(targetWire);
             return;
         }
-        ServiceContract contract = sourceWire.getServiceContract();
+        // match outbound to inbound chains
         for (OutboundInvocationChain outboundChain : sourceWire.getInvocationChains().values())
{
-            // match wire chains
             Operation<?> operation = outboundChain.getOperation();
             InboundInvocationChain inboundChain = targetChains.get(operation);
             if (inboundChain == null) {
@@ -193,20 +188,20 @@
                 e.setIdentifier(sourceWire.getReferenceName());
                 throw e;
             }
-            TargetInvoker invoker = null;
             boolean isOneWayOperation = operation.isNonBlocking();
             boolean operationHasCallback = contract.getCallbackName() != null;
             if (isOneWayOperation && operationHasCallback) {
                 throw new ComponentRuntimeException("Operation cannot be marked one-way and
have a callback");
             }
-
+            TargetInvoker invoker = null;
             if (target instanceof Component) {
                 Component component = (Component) target;
                 if (isOneWayOperation || operationHasCallback) {
                     invoker = component.createAsyncTargetInvoker(targetWire, operation);
                 } else {
                     Operation<?> inboundOperation = inboundChain.getOperation();
-                    invoker = component.createTargetInvoker(sourceWire.getTargetName().getPortName(),
inboundOperation);
+                    String portName = sourceWire.getTargetName().getPortName();
+                    invoker = component.createTargetInvoker(portName, inboundOperation);
                 }
             } else if (target instanceof Reference) {
                 Reference reference = (Reference) target;
@@ -214,8 +209,9 @@
                     // Notice that for bound references we only use async target invokers
for callback operations
                     invoker = reference.createAsyncTargetInvoker(sourceWire, operation);
                 } else {
-                    invoker =
-                        reference.createTargetInvoker(targetWire.getServiceContract(), inboundChain.getOperation());
+                    ServiceContract targetContract = targetWire.getServiceContract();
+                    Operation targetOperation = inboundChain.getOperation();
+                    invoker = reference.createTargetInvoker(targetContract, targetOperation);
                 }
             } else if (target instanceof CompositeService) {
                 CompositeService compServ = (CompositeService) target;
@@ -239,13 +235,14 @@
         for (InboundInvocationChain inboundChain : sourceWire.getTargetCallbackInvocationChains().values())
{
             Operation<?> operation = inboundChain.getOperation();
             if (sourceCallbackChains != null && sourceCallbackChains.get(operation)
!= null) {
+                String name = operation.getName();
                 BuilderConfigException e =
-                    new BuilderConfigException(
-                        "Source callback chain should not exist for operation [" + operation.getName()
+ "]");
+                    new BuilderConfigException("Source callback chain should not exist for
operation [" + name + "]");
                 e.setIdentifier(sourceWire.getReferenceName());
                 throw e;
             }
-            OutboundInvocationChain outboundChain = new OutboundInvocationChainImpl(operation);
+            OutboundInvocationChain outboundChain = wireService.createOutboundChain(operation);
+            //  connectCallbackChain(source, outboundChain, inboundChain);
             targetWire.addSourceCallbackInvocationChain(source.getName(), operation, outboundChain);
             if (source instanceof Component) {
                 Component component = (Component) source;
@@ -253,22 +250,19 @@
                 connect(outboundChain, inboundChain, invoker);
             } else if (source instanceof CompositeReference) {
                 CompositeReference compRef = (CompositeReference) source;
-                TargetInvoker invoker = compRef.createCallbackTargetInvoker(sourceWire.getServiceContract(),
operation);
+                ServiceContract sourceContract = sourceWire.getServiceContract();
+                TargetInvoker invoker = compRef.createCallbackTargetInvoker(sourceContract,
operation);
                 connect(outboundChain, inboundChain, invoker);
             } else if (source instanceof Service) {
                 Service service = (Service) source;
                 ServiceContract sourceContract = sourceWire.getServiceContract();
                 TargetInvoker invoker = service.createCallbackTargetInvoker(sourceContract,
operation);
                 connect(outboundChain, inboundChain, invoker);
-            } else if (target instanceof Service) {
-                throw new UnsupportedOperationException();
             }
         }
     }
 
-    public void connect(OutboundInvocationChain sourceChain,
-                        InboundInvocationChain targetChain,
-                        TargetInvoker invoker) {
+    void connect(OutboundInvocationChain sourceChain, InboundInvocationChain targetChain,
TargetInvoker invoker) {
         Interceptor headInterceptor = targetChain.getHeadInterceptor();
         if (headInterceptor == null) {
             BuilderConfigException e = new BuilderConfigException("No interceptor for operation");
@@ -291,7 +285,7 @@
      * @param sourceChain
      * @param targetChain
      */
-    public void connect(InboundInvocationChain sourceChain, OutboundInvocationChain targetChain)
{
+    void connect(InboundInvocationChain sourceChain, OutboundInvocationChain targetChain)
{
         // the are always interceptors so the connection algorithm is simple
         sourceChain.addInterceptor(new BridgingInterceptor(targetChain.getHeadInterceptor()));
     }
@@ -303,8 +297,7 @@
      * @param sourceWire
      * @throws BuilderConfigException
      */
-    private void connect(SCAObject source,
-                         OutboundWire sourceWire) throws BuilderConfigException {
+    private void connect(SCAObject source, OutboundWire sourceWire) throws BuilderConfigException
{
         assert sourceWire.getTargetName() != null : "Wire target name was null";
         QualifiedName targetName = sourceWire.getTargetName();
         CompositeComponent parent = source.getParent();
@@ -334,13 +327,13 @@
             }
             checkIfWireable(sourceWire, targetWire);
             boolean optimizable = isOptimizable(source.getScope(), target.getScope());
-            connect(source, target, sourceWire, targetWire, optimizable);
+            connect(sourceWire, targetWire, optimizable);
         } else if (target instanceof Reference) {
             InboundWire targetWire = ((Reference) target).getInboundWire();
             assert targetWire != null;
             checkIfWireable(sourceWire, targetWire);
             boolean optimizable = isOptimizable(source.getScope(), target.getScope());
-            connect(source, target, sourceWire, targetWire, optimizable);
+            connect(sourceWire, targetWire, optimizable);
         } else if (target instanceof CompositeComponent) {
             CompositeComponent composite = (CompositeComponent) target;
             InboundWire targetWire = null;
@@ -363,7 +356,7 @@
                 throw new BuilderConfigException("No target composite service in composite");
             }
             boolean optimizable = isOptimizable(source.getScope(), target.getScope());
-            connect(source, target, sourceWire, targetWire, optimizable);
+            connect(sourceWire, targetWire, optimizable);
         } else {
             String name = sourceWire.getReferenceName();
             BuilderConfigException e = new BuilderConfigException("Invalid target type for
reference " + name);

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=449095&r1=449094&r2=449095
==============================================================================
--- 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
Fri Sep 22 14:22:11 2006
@@ -8,7 +8,6 @@
 import java.util.Map;
 
 import org.apache.tuscany.spi.QualifiedName;
-import org.apache.tuscany.spi.builder.Connector;
 import org.apache.tuscany.spi.component.AtomicComponent;
 import org.apache.tuscany.spi.component.CompositeComponent;
 import org.apache.tuscany.spi.component.Reference;
@@ -22,6 +21,7 @@
 import org.apache.tuscany.spi.wire.Interceptor;
 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.wire.BridgingInterceptor;
@@ -32,7 +32,7 @@
  */
 public class ConnectorImplTestCase extends TestCase {
 
-    private Connector connector = new ConnectorImpl();
+    private ConnectorImpl connector = new ConnectorImpl();
 
     public void testConnectReferenceWires() {
         // create the wire contract, operation
@@ -66,7 +66,7 @@
         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.expect(outboundWire.getInvocationChains()).andReturn(outboundChains).anyTimes();
         EasyMock.replay(outboundWire);
 
         Reference reference = EasyMock.createMock(Reference.class);
@@ -110,7 +110,6 @@
         EasyMock.expect(targetWire.getInvocationChains()).andReturn(targetChains);
         targetWire.getSourceCallbackInvocationChains("source");
         EasyMock.expectLastCall().andReturn(Collections.emptyMap());
-        EasyMock.replay(targetWire);
 
         // create the target
         AtomicComponent target = EasyMock.createMock(AtomicComponent.class);
@@ -121,6 +120,9 @@
         EasyMock.expectLastCall().andReturn(null);
         EasyMock.replay(target);
 
+        EasyMock.expect(targetWire.getContainer()).andReturn(target);
+        EasyMock.replay(targetWire);
+
         // create the parent composite
         CompositeComponent parent = EasyMock.createMock(CompositeComponent.class);
         EasyMock.expect(parent.getChild("target")).andReturn(target);
@@ -157,7 +159,6 @@
         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);
 
         // create the service
         Service service = EasyMock.createMock(Service.class);
@@ -168,6 +169,9 @@
         EasyMock.expect(service.getOutboundWire()).andReturn(outboundWire);
         EasyMock.replay(service);
 
+        EasyMock.expect(outboundWire.getContainer()).andReturn(service);
+        EasyMock.replay(outboundWire);
+
         connector.connect(service);
 
         EasyMock.verify(service);
@@ -203,7 +207,6 @@
         EasyMock.expect(targetWire.getInvocationChains()).andReturn(inboundChains);
         targetWire.getSourceCallbackInvocationChains("source");
         EasyMock.expectLastCall().andReturn(Collections.emptyMap());
-        EasyMock.replay(targetWire);
 
         // create the target
         AtomicComponent target = EasyMock.createMock(AtomicComponent.class);
@@ -214,6 +217,9 @@
         EasyMock.expectLastCall().andReturn(null);
         EasyMock.replay(target);
 
+        EasyMock.expect(targetWire.getContainer()).andReturn(target);
+        EasyMock.replay(targetWire);
+
         // create the parent composite
         CompositeComponent parent = EasyMock.createMock(CompositeComponent.class);
         EasyMock.expect(parent.getChild("target")).andReturn(target);
@@ -233,10 +239,10 @@
         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.expect(outboundWire.getInvocationChains()).andReturn(outboundChains).anyTimes();
         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);
@@ -252,6 +258,9 @@
         EasyMock.expectLastCall().andReturn(Collections.emptyMap());
         EasyMock.replay(source);
 
+        EasyMock.expect(outboundWire.getContainer()).andReturn(source);
+        EasyMock.replay(outboundWire);
+
         connector.connect(source);
         EasyMock.verify(headInterceptor);
         EasyMock.verify(tailInterceptor);
@@ -303,4 +312,67 @@
         EasyMock.verify(chain);
 
     }
+
+    public void testOutboundToInboundOptimization() {
+        InboundWire inboundWire = EasyMock.createMock(InboundWire.class);
+        EasyMock.expect(inboundWire.getContainer()).andReturn(null);
+        inboundWire.getInvocationChains();
+        EasyMock.expectLastCall().andReturn(Collections.emptyMap());
+        EasyMock.replay(inboundWire);
+
+        OutboundWire outboundWire = EasyMock.createMock(OutboundWire.class);
+        outboundWire.getInvocationChains();
+        EasyMock.expectLastCall().andReturn(Collections.emptyMap());
+        outboundWire.setTargetWire(inboundWire);
+        EasyMock.expect(outboundWire.getContainer()).andReturn(null);
+        EasyMock.expect(outboundWire.getServiceContract()).andReturn(null);
+        EasyMock.replay(outboundWire);
+
+        connector.connect(outboundWire, inboundWire, true);
+        EasyMock.verify(inboundWire);
+        EasyMock.verify(outboundWire);
+
+    }
+
+    public void testOutboundToInboundChainConnect() {
+        Interceptor head = EasyMock.createMock(Interceptor.class);
+        EasyMock.replay(head);
+        Interceptor tail = EasyMock.createMock(Interceptor.class);
+        EasyMock.replay(tail);
+
+        TargetInvoker invoker = EasyMock.createMock(TargetInvoker.class);
+        EasyMock.replay(invoker);
+
+        InboundInvocationChain inboundChain = EasyMock.createMock(InboundInvocationChain.class);
+        EasyMock.expect(inboundChain.getHeadInterceptor()).andReturn(head);
+        EasyMock.replay(inboundChain);
+
+        OutboundInvocationChain outboundChain = EasyMock.createMock(OutboundInvocationChain.class);
+        EasyMock.expect(outboundChain.getTailInterceptor()).andReturn(tail);
+        outboundChain.prepare();
+        outboundChain.setTargetInterceptor(head);
+        outboundChain.setTargetInvoker(invoker);
+        EasyMock.replay(outboundChain);
+        connector.connect(outboundChain, inboundChain, invoker);
+        EasyMock.verify(outboundChain);
+    }
+
+    public void testInboundToOutboundChainConnect() {
+        Interceptor head = EasyMock.createMock(Interceptor.class);
+        EasyMock.replay(head);
+
+        InboundInvocationChain inboundChain = EasyMock.createMock(InboundInvocationChain.class);
+        inboundChain.addInterceptor(EasyMock.isA(BridgingInterceptor.class));
+        EasyMock.replay(inboundChain);
+
+        OutboundInvocationChain outboundChain = EasyMock.createMock(OutboundInvocationChain.class);
+        EasyMock.expect(outboundChain.getHeadInterceptor()).andReturn(head);
+        outboundChain.prepare();
+        outboundChain.setTargetInterceptor(head);
+        EasyMock.replay(outboundChain);
+        connector.connect(inboundChain, outboundChain);
+        EasyMock.verify(inboundChain);
+    }
+
+
 }

Modified: incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/builder/ConnectorPostProcessTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/builder/ConnectorPostProcessTestCase.java?view=diff&rev=449095&r1=449094&r2=449095
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/builder/ConnectorPostProcessTestCase.java
(original)
+++ incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/builder/ConnectorPostProcessTestCase.java
Fri Sep 22 14:22:11 2006
@@ -64,7 +64,13 @@
     }
 
     public void testOutboundToInboundPostProcessCalled() throws Exception {
+        Component source = createNiceMock(Component.class);
+        expect(source.getName()).andReturn("Component");
+        replay(source);
+
         OutboundWire owire = createNiceMock(OutboundWire.class);
+        EasyMock.expect(owire.getContainer()).andReturn(source);
+
         Map<Operation<?>, OutboundInvocationChain> chains = new HashMap<Operation<?>,
OutboundInvocationChain>();
         expect(owire.getInvocationChains()).andReturn(chains);
         Map<Operation<?>, InboundInvocationChain> ichains = new HashMap<Operation<?>,
InboundInvocationChain>();
@@ -81,10 +87,8 @@
             (ServiceContract<?>) EasyMock.anyObject())).andReturn(true).anyTimes();
         replay(wireService);
         ConnectorImpl connector = new ConnectorImpl(wireService, registry);
-        Component source = createNiceMock(Component.class);
-        expect(source.getName()).andReturn("Component");
-        replay(source);
-        connector.connect(source, null, owire, iwire, false);
+
+        connector.connect(owire, iwire, false);
         verify(registry);
     }
 

Modified: incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/builder/OutboundToInboundConnectTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/builder/OutboundToInboundConnectTestCase.java?view=diff&rev=449095&r1=449094&r2=449095
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/builder/OutboundToInboundConnectTestCase.java
(original)
+++ incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/builder/OutboundToInboundConnectTestCase.java
Fri Sep 22 14:22:11 2006
@@ -144,7 +144,6 @@
 
 
     public InboundInvocationChain setupTarget(List<Interceptor> interceptors) {
-
         JavaInterfaceProcessorRegistry registry = new JavaInterfaceProcessorRegistryImpl();
         ServiceContract<?> contract;
         try {

Modified: incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/integration/component/CallbackInvocationTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/integration/component/CallbackInvocationTestCase.java?view=diff&rev=449095&r1=449094&r2=449095
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/integration/component/CallbackInvocationTestCase.java
(original)
+++ incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/integration/component/CallbackInvocationTestCase.java
Fri Sep 22 14:22:11 2006
@@ -91,7 +91,8 @@
         wireService.createWires(clientComponent, sourceDefinition);
         container.register(clientComponent);
 
-        Connector connector = new ConnectorImpl();
+        Connector connector = new ConnectorImpl(new JDKWireService(), null);
+
         connector.connect(clientComponent);
         FooClient client = (FooClient) clientComponent.getServiceInstance();
         client.invoke();
@@ -125,7 +126,7 @@
         wireService.createWires(clientComponent2, sourceDefinition2);
         container.register(clientComponent2);
 
-        Connector connector = new ConnectorImpl();
+        Connector connector = new ConnectorImpl(new JDKWireService(), null);
         connector.connect(clientComponent1);
         connector.connect(clientComponent2);
         FooClient client1 = (FooClient) clientComponent1.getServiceInstance();

Modified: incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/integration/component/OutboundWireToJavaTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/integration/component/OutboundWireToJavaTestCase.java?view=diff&rev=449095&r1=449094&r2=449095
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/integration/component/OutboundWireToJavaTestCase.java
(original)
+++ incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/integration/component/OutboundWireToJavaTestCase.java
Fri Sep 22 14:22:11 2006
@@ -25,6 +25,7 @@
 import java.util.concurrent.FutureTask;
 
 import org.apache.tuscany.spi.QualifiedName;
+import org.apache.tuscany.spi.component.CompositeComponent;
 import org.apache.tuscany.spi.component.ScopeContainer;
 import org.apache.tuscany.spi.component.WorkContext;
 import org.apache.tuscany.spi.idl.InvalidServiceContractException;
@@ -60,6 +61,7 @@
 import org.apache.tuscany.core.wire.OutboundInvocationChainImpl;
 import org.apache.tuscany.core.wire.OutboundWireImpl;
 import org.apache.tuscany.core.wire.jdk.JDKWireService;
+import org.easymock.EasyMock;
 
 /**
  * Validates wiring from a service context to Java atomic contexts by scope
@@ -174,18 +176,32 @@
     private OutboundWire getWire(ScopeContainer scope) throws NoSuchMethodException,
                                                               InvalidServiceContractException
{
         ConnectorImpl connector = new ConnectorImpl();
-        OutboundWire wire = createOutboundWire(new QualifiedName("target/Target"), Target.class);
+
+        CompositeComponent parent = EasyMock.createMock(CompositeComponent.class);
 
         PojoConfiguration configuration = new PojoConfiguration();
         configuration.setScopeContainer(scope);
         configuration.setInstanceFactory(new PojoObjectFactory<TargetImpl>(TargetImpl.class.getConstructor()));
         configuration.addServiceInterface(Target.class);
-        JavaAtomicComponent atomicComponent = new JavaAtomicComponent("target", configuration,
null);
+        configuration.setParent(parent);
+
+        JavaAtomicComponent source = new JavaAtomicComponent("source", configuration, null);
+        OutboundWire outboundWire = createOutboundWire(new QualifiedName("target/Target"),
Target.class);
+        outboundWire.setContainer(source);
+        source.addOutboundWire(outboundWire);
+        JavaAtomicComponent target = new JavaAtomicComponent("target", configuration, null);
         InboundWire targetWire = MockFactory.createTargetWire("Target", Target.class);
-        atomicComponent.addInboundWire(targetWire);
-        connector.connect(atomicComponent, atomicComponent, wire, atomicComponent.getInboundWire("Target"),
false);
-        atomicComponent.start();
-        return wire;
+        targetWire.setContainer(target);
+        target.addInboundWire(targetWire);
+        InboundWire inboundWire = target.getInboundWire("Target");
+        inboundWire.setContainer(target);
+
+        EasyMock.expect(parent.getChild("target")).andReturn(target);
+        EasyMock.replay(parent);
+
+        connector.connect(source);
+        target.start();
+        return outboundWire;
     }
 
     public static <T> OutboundWire createOutboundWire(QualifiedName targetName, Class<T>
interfaze)

Modified: incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/integration/implementation/system/builder/SystemBuilderWireTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/integration/implementation/system/builder/SystemBuilderWireTestCase.java?view=diff&rev=449095&r1=449094&r2=449095
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/integration/implementation/system/builder/SystemBuilderWireTestCase.java
(original)
+++ incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/integration/implementation/system/builder/SystemBuilderWireTestCase.java
Fri Sep 22 14:22:11 2006
@@ -158,15 +158,9 @@
         Service service = bindingBuilder.build(parent, serviceDefinition, deploymentContext);
         parent.register(service);
 
-        connector.connect(service.getInboundWire(), service.getOutboundWire(), true);
-
         connector.connect(sourceComponent);
-        String serviceName = service.getOutboundWire().getTargetName().getPortName();
-        connector.connect(sourceComponent,
-            parent,
-            service.getOutboundWire(),
-            sourceComponent.getInboundWire(serviceName),
-            true);
+        connector.connect(service);
+
         parent.start();
         scope.onEvent(new CompositeStart(this, parent));
         Target target = (Target) parent.getChild("serviceDefinition").getServiceInstance();

Modified: incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/Connector.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/Connector.java?view=diff&rev=449095&r1=449094&r2=449095
==============================================================================
--- incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/Connector.java
(original)
+++ incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/Connector.java
Fri Sep 22 14:22:11 2006
@@ -40,12 +40,11 @@
     /**
      * Bridges the invocation chains associated with an inbound and outbound wire.
      *
-     * @param inboundWire  the wire to bridge from
-     * @param outboundWire the target wire
-     * @param optimizable  if the bridge may be optimized
+     * @param inbound     the wire to bridge from
+     * @param outbound    the target wire
+     * @param optimizable if the bridge may be optimized
      * @throws BuilderConfigException
      */
-    void connect(InboundWire inboundWire, OutboundWire outboundWire, boolean optimizable)
-        throws BuilderConfigException;
+    void connect(InboundWire inbound, OutboundWire outbound, boolean optimizable) throws
BuilderConfigException;
 
 }

Modified: incubator/tuscany/java/sca/services/containers/container.spring/src/test/java/org/apache/tuscany/container/spring/SpringTestUtils.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/services/containers/container.spring/src/test/java/org/apache/tuscany/container/spring/SpringTestUtils.java?view=diff&rev=449095&r1=449094&r2=449095
==============================================================================
--- incubator/tuscany/java/sca/services/containers/container.spring/src/test/java/org/apache/tuscany/container/spring/SpringTestUtils.java
(original)
+++ incubator/tuscany/java/sca/services/containers/container.spring/src/test/java/org/apache/tuscany/container/spring/SpringTestUtils.java
Fri Sep 22 14:22:11 2006
@@ -54,7 +54,7 @@
         service.setOutboundWire(outboundWire);
         outboundWire.setTargetName(new QualifiedName("foo"));
         Connector connector = ArtifactFactory.createConnector();
-        connector.connect(inboundWire, outboundWire, true);
+        connector.connect(service);
         ArtifactFactory.terminateWire(inboundWire);
         return service;
     }

Modified: incubator/tuscany/java/sca/services/containers/container.spring/src/test/java/org/apache/tuscany/container/spring/impl/ServiceInvocationTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/services/containers/container.spring/src/test/java/org/apache/tuscany/container/spring/impl/ServiceInvocationTestCase.java?view=diff&rev=449095&r1=449094&r2=449095
==============================================================================
--- incubator/tuscany/java/sca/services/containers/container.spring/src/test/java/org/apache/tuscany/container/spring/impl/ServiceInvocationTestCase.java
(original)
+++ incubator/tuscany/java/sca/services/containers/container.spring/src/test/java/org/apache/tuscany/container/spring/impl/ServiceInvocationTestCase.java
Fri Sep 22 14:22:11 2006
@@ -25,6 +25,7 @@
 import org.apache.tuscany.spi.wire.InboundInvocationChain;
 import org.apache.tuscany.spi.wire.InboundWire;
 import org.apache.tuscany.spi.wire.OutboundWire;
+import org.apache.tuscany.spi.QualifiedName;
 
 import junit.framework.TestCase;
 import org.apache.tuscany.container.spring.mock.TestBean;
@@ -44,21 +45,22 @@
 
     public void testInvocation() throws InvalidServiceContractException {
         AbstractApplicationContext springContext = createSpringContext();
-        SpringCompositeComponent context = new SpringCompositeComponent("parent", springContext,
null, null, null);
+        SpringCompositeComponent composite = new SpringCompositeComponent("parent", springContext,
null, null, null);
         InboundWire inboundWire = ArtifactFactory.createInboundWire("fooService", TestBean.class);
         OutboundWire outboundWire = ArtifactFactory.createOutboundWire("fooService", TestBean.class);
+        outboundWire.setTargetName(new QualifiedName("foo"));
         ArtifactFactory.terminateWire(outboundWire);
         Service service =
-            new ServiceExtension("fooService", TestBean.class, context, createWireService());
+            new ServiceExtension("fooService", TestBean.class, composite, createWireService());
         service.setInboundWire(inboundWire);
         service.setOutboundWire(outboundWire);
         Connector connector = ArtifactFactory.createConnector();
         connector.connect(inboundWire, outboundWire, true);
         for (InboundInvocationChain chain : inboundWire.getInvocationChains().values()) {
-            chain.setTargetInvoker(context.createTargetInvoker("foo", chain.getOperation()));
+            chain.setTargetInvoker(composite.createTargetInvoker("foo", chain.getOperation()));
         }
-        context.register(service);
-        TestBean serviceInstance = (TestBean) context.getService("fooService").getServiceInstance();
+        composite.register(service);
+        TestBean serviceInstance = (TestBean) composite.getService("fooService").getServiceInstance();
         assertEquals("bar", serviceInstance.echo("bar"));
     }
 



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


Mime
View raw message