Author: jmarino
Date: Tue Jan 2 10:49:43 2007
New Revision: 491891
URL: http://svn.apache.org/viewvc?view=rev&rev=491891
Log:
more connector test cases
Added:
incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/builder/ServiceConnectorTestCase.java
(with props)
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/AbstractConnectorImplTestCase.java
incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/builder/LocalReferenceWiringTestCase.java
incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/builder/ReferenceConnectorTestCase.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=491891&r1=491890&r2=491891
==============================================================================
---
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
Tue Jan 2 10:49:43 2007
@@ -433,44 +433,44 @@
}
}
- private void handleAtomic(AtomicComponent sourceComponent) throws
WiringException {
- CompositeComponent parent = sourceComponent.getParent();
+ private void handleAtomic(AtomicComponent component) throws
WiringException {
+ CompositeComponent parent = component.getParent();
assert parent != null;
// connect outbound wires for component references to their targets
- for (List<OutboundWire> referenceWires :
sourceComponent.getOutboundWires().values()) {
+ for (List<OutboundWire> referenceWires :
component.getOutboundWires().values()) {
for (OutboundWire outboundWire : referenceWires) {
try {
- if (sourceComponent.isSystem()) {
+ if (component.isSystem()) {
if (outboundWire.isAutowire()) {
autowire(outboundWire, parent);
} else {
SCAObject target =
parent.getSystemChild(outboundWire.getTargetName().getPartName());
- connect(sourceComponent, outboundWire, target);
+ connect(component, outboundWire, target);
}
} else {
if (outboundWire.isAutowire()) {
autowire(outboundWire, parent);
} else {
SCAObject target =
parent.getChild(outboundWire.getTargetName().getPartName());
- connect(sourceComponent, outboundWire, target);
+ connect(component, outboundWire, target);
}
}
} catch (WiringException e) {
- e.addContextName(sourceComponent.getName());
+ e.addContextName(component.getName());
e.addContextName(parent.getName());
throw e;
}
}
}
// connect inbound wires
- for (InboundWire inboundWire : sourceComponent.getInboundWires()) {
+ for (InboundWire inboundWire : component.getInboundWires()) {
for (InboundInvocationChain chain :
inboundWire.getInvocationChains().values()) {
Operation<?> operation = chain.getOperation();
String serviceName = inboundWire.getServiceName();
TargetInvoker invoker;
try {
- invoker = sourceComponent.createTargetInvoker(serviceName,
operation, null);
+ invoker = component.createTargetInvoker(serviceName,
operation, null);
} catch (TargetInvokerCreationException e) {
String targetName = inboundWire.getContainer().getName();
throw new WireConnectException("Error processing inbound
wire",
Modified:
incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/builder/AbstractConnectorImplTestCase.java
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/builder/AbstractConnectorImplTestCase.java?view=diff&rev=491891&r1=491890&r2=491891
==============================================================================
---
incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/builder/AbstractConnectorImplTestCase.java
(original)
+++
incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/builder/AbstractConnectorImplTestCase.java
Tue Jan 2 10:49:43 2007
@@ -7,10 +7,15 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import javax.xml.namespace.QName;
import org.apache.tuscany.spi.QualifiedName;
import org.apache.tuscany.spi.component.AtomicComponent;
import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.component.ReferenceBinding;
+import org.apache.tuscany.spi.component.Service;
+import org.apache.tuscany.spi.component.ServiceBinding;
+import org.apache.tuscany.spi.component.TargetInvokerCreationException;
import org.apache.tuscany.spi.idl.java.JavaServiceContract;
import org.apache.tuscany.spi.model.Operation;
import org.apache.tuscany.spi.model.Scope;
@@ -26,11 +31,16 @@
import org.apache.tuscany.spi.wire.TargetInvoker;
import junit.framework.TestCase;
+import org.apache.tuscany.core.binding.local.LocalReferenceBinding;
+import org.apache.tuscany.core.binding.local.LocalServiceBinding;
+import org.apache.tuscany.core.implementation.composite.ServiceImpl;
+import org.apache.tuscany.core.mock.binding.MockServiceBinding;
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;
/**
@@ -108,6 +118,94 @@
outboundWire.setContainer(source);
return source;
}
+
+
+ protected Service createService() throws WireConnectException {
+ QName qName = new QName("foo", "bar");
+ ServiceBinding serviceBinding = new MockServiceBinding();
+ InboundInvocationChain targetInboundChain = new
InboundInvocationChainImpl(operation);
+ targetInboundChain.addInterceptor(new
SynchronousBridgingInterceptor());
+ InboundWireImpl targetInboundWire = new InboundWireImpl();
+ targetInboundWire.setBindingType(qName);
+ targetInboundWire.setServiceContract(contract);
+ targetInboundWire.addInvocationChain(operation, targetInboundChain);
+ targetInboundWire.setContainer(serviceBinding);
+
+ OutboundInvocationChain targetOutboundChain = new
OutboundInvocationChainImpl(operation);
+ // place an invoker interceptor on the end
+ targetOutboundChain.addInterceptor(new InvokerInterceptor());
+ OutboundWireImpl targetOutboundWire = new OutboundWireImpl();
+ targetOutboundWire.setServiceContract(contract);
+ targetOutboundWire.addInvocationChain(operation, targetOutboundChain);
+ targetOutboundWire.setContainer(serviceBinding);
+ targetOutboundWire.setBindingType(qName);
+
+ serviceBinding.setInboundWire(targetInboundWire);
+ serviceBinding.setOutboundWire(targetOutboundWire);
+ // manually connect the service chains
+ connector.connect(targetInboundChain, targetOutboundChain);
+ Service service = new ServiceImpl(TARGET, null, contract);
+ service.addServiceBinding(serviceBinding);
+ return service;
+ }
+
+ /**
+ * Creates a service configured with the local binding and places an
invoker interceptor on the end of each outbound
+ * chain for invocation testing without needing to wire the service to a
target
+ *
+ * @throws org.apache.tuscany.core.builder.WireConnectException
+ *
+ */
+ protected Service createLocalService(CompositeComponent parent) throws
WireConnectException {
+ LocalServiceBinding serviceBinding = new LocalServiceBinding(TARGET,
parent);
+ InboundInvocationChain targetInboundChain = new
InboundInvocationChainImpl(operation);
+ targetInboundChain.addInterceptor(new
SynchronousBridgingInterceptor());
+ InboundWire targetInboundWire = new InboundWireImpl();
+ targetInboundWire.setServiceContract(contract);
+ targetInboundWire.addInvocationChain(operation, targetInboundChain);
+ targetInboundWire.setContainer(serviceBinding);
+
+ OutboundInvocationChain targetOutboundChain = new
OutboundInvocationChainImpl(operation);
+ // place an invoker interceptor on the end
+ targetOutboundChain.addInterceptor(new InvokerInterceptor());
+ OutboundWire targetOutboundWire = new OutboundWireImpl();
+ targetOutboundWire.setServiceContract(contract);
+ targetOutboundWire.addInvocationChain(operation, targetOutboundChain);
+ targetOutboundWire.setContainer(serviceBinding);
+
+ serviceBinding.setInboundWire(targetInboundWire);
+ serviceBinding.setOutboundWire(targetOutboundWire);
+ // manually connect the service chains
+ connector.connect(targetInboundChain, targetOutboundChain);
+ Service service = new ServiceImpl(TARGET, null, contract);
+ service.addServiceBinding(serviceBinding);
+ return service;
+ }
+
+ protected ReferenceBinding createLocalReferenceBinding(QualifiedName
target)
+ throws TargetInvokerCreationException {
+ ReferenceBinding referenceBinding = new LocalReferenceBinding("local",
null);
+ InboundInvocationChain inboundChain = new
InboundInvocationChainImpl(operation);
+ InboundWire inboundWire = new InboundWireImpl();
+ inboundWire.setServiceContract(contract);
+ inboundWire.setContainer(referenceBinding);
+ inboundWire.addInvocationChain(operation, inboundChain);
+
+ OutboundInvocationChain outboundChain = new
OutboundInvocationChainImpl(operation);
+ // Outbound chains always contains at least one interceptor
+ outboundChain.addInterceptor(new SynchronousBridgingInterceptor());
+ OutboundWire outboundWire = new OutboundWireImpl();
+ outboundWire.setServiceContract(contract);
+ outboundWire.setTargetName(target);
+ outboundWire.addInvocationChain(operation, outboundChain);
+ outboundWire.setContainer(referenceBinding);
+
+ referenceBinding.setInboundWire(inboundWire);
+ referenceBinding.setOutboundWire(outboundWire);
+
+ return referenceBinding;
+ }
+
protected static class MockInvoker implements TargetInvoker {
public Object invokeTarget(final Object payload, final short sequence)
throws InvocationTargetException {
Modified:
incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/builder/LocalReferenceWiringTestCase.java
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/builder/LocalReferenceWiringTestCase.java?view=diff&rev=491891&r1=491890&r2=491891
==============================================================================
---
incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/builder/LocalReferenceWiringTestCase.java
(original)
+++
incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/builder/LocalReferenceWiringTestCase.java
Tue Jan 2 10:49:43 2007
@@ -1,37 +1,21 @@
package org.apache.tuscany.core.builder;
import java.util.Collections;
-import javax.xml.namespace.QName;
-import org.apache.tuscany.spi.QualifiedName;
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.ReferenceBinding;
import org.apache.tuscany.spi.component.Service;
-import org.apache.tuscany.spi.component.ServiceBinding;
-import org.apache.tuscany.spi.component.TargetInvokerCreationException;
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.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.QualifiedName;
-import org.apache.tuscany.core.binding.local.LocalReferenceBinding;
-import org.apache.tuscany.core.binding.local.LocalServiceBinding;
-import org.apache.tuscany.core.implementation.composite.ReferenceImpl;
-import org.apache.tuscany.core.implementation.composite.ServiceImpl;
-import org.apache.tuscany.core.mock.binding.MockServiceBinding;
-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;
import org.easymock.IAnswer;
+import org.apache.tuscany.core.implementation.composite.ReferenceImpl;
/**
* Verifies various wiring "scenarios" or paths through the connector
@@ -39,9 +23,9 @@
* @version $Rev$ $Date$
*/
public class LocalReferenceWiringTestCase extends
AbstractConnectorImplTestCase {
+ protected ReferenceBinding referenceBinding;
private Service service;
private Reference reference;
- protected ReferenceBinding referenceBinding;
private AtomicComponent atomicComponent;
/**
@@ -248,97 +232,11 @@
this.reference = createLocalReference(parent, TARGET_NAME);
}
- private Service createService() throws WireConnectException {
- QName qName = new QName("foo", "bar");
- ServiceBinding serviceBinding = new MockServiceBinding();
- InboundInvocationChain targetInboundChain = new
InboundInvocationChainImpl(operation);
- targetInboundChain.addInterceptor(new
SynchronousBridgingInterceptor());
- InboundWireImpl targetInboundWire = new InboundWireImpl();
- targetInboundWire.setBindingType(qName);
- targetInboundWire.setServiceContract(contract);
- targetInboundWire.addInvocationChain(operation, targetInboundChain);
- targetInboundWire.setContainer(serviceBinding);
-
- OutboundInvocationChain targetOutboundChain = new
OutboundInvocationChainImpl(operation);
- // place an invoker interceptor on the end
- targetOutboundChain.addInterceptor(new InvokerInterceptor());
- OutboundWireImpl targetOutboundWire = new OutboundWireImpl();
- targetOutboundWire.setServiceContract(contract);
- targetOutboundWire.addInvocationChain(operation, targetOutboundChain);
- targetOutboundWire.setContainer(serviceBinding);
- targetOutboundWire.setBindingType(qName);
-
- serviceBinding.setInboundWire(targetInboundWire);
- serviceBinding.setOutboundWire(targetOutboundWire);
- // manually connect the service chains
- connector.connect(targetInboundChain, targetOutboundChain);
- Service service = new ServiceImpl(TARGET, null, contract);
- service.addServiceBinding(serviceBinding);
- return service;
- }
-
- /**
- * Creates a service configured with the local binding and places an
invoker interceptor on the end of each outbound
- * chain for invocation testing without needing to wire the service to a
target
- *
- * @throws org.apache.tuscany.core.builder.WireConnectException
- *
- */
- private Service createLocalService(CompositeComponent parent) throws
WireConnectException {
- LocalServiceBinding serviceBinding = new LocalServiceBinding(TARGET,
parent);
- InboundInvocationChain targetInboundChain = new
InboundInvocationChainImpl(operation);
- targetInboundChain.addInterceptor(new
SynchronousBridgingInterceptor());
- InboundWire targetInboundWire = new InboundWireImpl();
- targetInboundWire.setServiceContract(contract);
- targetInboundWire.addInvocationChain(operation, targetInboundChain);
- targetInboundWire.setContainer(serviceBinding);
-
- OutboundInvocationChain targetOutboundChain = new
OutboundInvocationChainImpl(operation);
- // place an invoker interceptor on the end
- targetOutboundChain.addInterceptor(new InvokerInterceptor());
- OutboundWire targetOutboundWire = new OutboundWireImpl();
- targetOutboundWire.setServiceContract(contract);
- targetOutboundWire.addInvocationChain(operation, targetOutboundChain);
- targetOutboundWire.setContainer(serviceBinding);
-
- serviceBinding.setInboundWire(targetInboundWire);
- serviceBinding.setOutboundWire(targetOutboundWire);
- // manually connect the service chains
- connector.connect(targetInboundChain, targetOutboundChain);
- Service service = new ServiceImpl(TARGET, null, contract);
- service.addServiceBinding(serviceBinding);
- return service;
- }
-
private Reference createLocalReference(CompositeComponent parent,
QualifiedName target) throws Exception {
- ReferenceBinding referenceBinding =
createLocalReferenceBinding(target);
+ referenceBinding = createLocalReferenceBinding(target);
Reference reference = new ReferenceImpl("foo", parent, contract);
reference.addReferenceBinding(referenceBinding);
return reference;
- }
-
- private ReferenceBinding createLocalReferenceBinding(QualifiedName target)
- throws TargetInvokerCreationException {
- referenceBinding = new LocalReferenceBinding("local", null);
- InboundInvocationChain inboundChain = new
InboundInvocationChainImpl(operation);
- InboundWire inboundWire = new InboundWireImpl();
- inboundWire.setServiceContract(contract);
- inboundWire.setContainer(referenceBinding);
- inboundWire.addInvocationChain(operation, inboundChain);
-
- OutboundInvocationChain outboundChain = new
OutboundInvocationChainImpl(operation);
- // Outbound chains always contains at least one interceptor
- outboundChain.addInterceptor(new SynchronousBridgingInterceptor());
- OutboundWire outboundWire = new OutboundWireImpl();
- outboundWire.setServiceContract(contract);
- outboundWire.setTargetName(target);
- outboundWire.addInvocationChain(operation, outboundChain);
- outboundWire.setContainer(referenceBinding);
-
- referenceBinding.setInboundWire(inboundWire);
- referenceBinding.setOutboundWire(outboundWire);
-
- return referenceBinding;
}
Modified:
incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/builder/ReferenceConnectorTestCase.java
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/builder/ReferenceConnectorTestCase.java?view=diff&rev=491891&r1=491890&r2=491891
==============================================================================
---
incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/builder/ReferenceConnectorTestCase.java
(original)
+++
incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/builder/ReferenceConnectorTestCase.java
Tue Jan 2 10:49:43 2007
@@ -45,14 +45,12 @@
*/
public class ReferenceConnectorTestCase extends AbstractConnectorImplTestCase {
private AtomicComponent source;
- private AtomicComponent target;
private CompositeComponent parent;
public void testConnectReferenceWiresNoInboundInterceptors() throws
Exception {
InboundInvocationChain inboundChain = new
InboundInvocationChainImpl(operation);
InboundWire inboundWire = new InboundWireImpl();
inboundWire.setServiceContract(contract);
- inboundWire.setContainer(source);
inboundWire.addInvocationChain(operation, inboundChain);
OutboundInvocationChain outboundChain = new
OutboundInvocationChainImpl(operation);
@@ -61,7 +59,6 @@
OutboundWire outboundWire = new OutboundWireImpl();
outboundWire.setServiceContract(contract);
outboundWire.setTargetName(TARGET_SERVICE_NAME);
- outboundWire.setContainer(source);
outboundWire.addInvocationChain(operation, outboundChain);
ReferenceBinding referenceBinding =
EasyMock.createMock(ReferenceBinding.class);
@@ -92,7 +89,6 @@
InboundInvocationChain inboundChain = new
InboundInvocationChainImpl(operation);
inboundChain.addInterceptor(inboundInterceptor);
InboundWire inboundWire = new InboundWireImpl();
- inboundWire.setContainer(source);
inboundWire.setServiceContract(contract);
inboundWire.addInvocationChain(operation, inboundChain);
@@ -101,7 +97,6 @@
outboundChain.addInterceptor(new InvokerInterceptor());
OutboundWire outboundWire = new OutboundWireImpl();
outboundWire.setServiceContract(contract);
- outboundWire.setContainer(source);
outboundWire.setTargetName(TARGET_SERVICE_NAME);
outboundWire.addInvocationChain(operation, outboundChain);
@@ -144,7 +139,6 @@
InboundWire targetWire = new InboundWireImpl();
targetWire.setServiceContract(contract);
targetWire.addInvocationChain(operation, inboundChain);
- targetWire.setContainer(source);
targetWire.setContainer(target);
// create the outbound wire and chain from the source component
@@ -169,8 +163,6 @@
parent = EasyMock.createNiceMock(CompositeComponent.class);
source = EasyMock.createNiceMock(AtomicComponent.class);
EasyMock.replay(source);
- target = EasyMock.createNiceMock(AtomicComponent.class);
- EasyMock.replay(target);
}
}
Added:
incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/builder/ServiceConnectorTestCase.java
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/builder/ServiceConnectorTestCase.java?view=auto&rev=491891
==============================================================================
---
incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/builder/ServiceConnectorTestCase.java
(added)
+++
incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/builder/ServiceConnectorTestCase.java
Tue Jan 2 10:49:43 2007
@@ -0,0 +1,154 @@
+package org.apache.tuscany.core.builder;
+
+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.ReferenceBinding;
+import org.apache.tuscany.spi.component.Service;
+import org.apache.tuscany.spi.component.ServiceBinding;
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.model.Scope;
+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.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.core.implementation.composite.ReferenceImpl;
+import org.apache.tuscany.core.implementation.composite.ServiceImpl;
+import org.apache.tuscany.core.mock.binding.MockServiceBinding;
+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;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ServiceConnectorTestCase extends AbstractConnectorImplTestCase {
+ private AtomicComponent atomicTarget;
+ private CompositeComponent parent;
+ private CompositeComponent compositeTarget;
+ private InboundInvocationChain inboundChain;
+ private ServiceBinding sourceServiceBinding;
+ private Reference referenceTarget;
+
+ public void testConnectServiceToAtomicComponent() throws Exception {
+ configureAtomicTarget();
+ Service sourceService = new ServiceImpl("foo", parent, contract);
+ sourceService.addServiceBinding(sourceServiceBinding);
+ connector.connect(sourceService);
+ Interceptor interceptor = inboundChain.getHeadInterceptor();
+ MessageImpl msg = new MessageImpl();
+ msg.setTargetInvoker(new MockInvoker());
+ Message resp = interceptor.invoke(msg);
+ assertEquals(RESPONSE, resp.getBody());
+ }
+
+ public void testConnectServiceToChildCompositeService() throws Exception {
+ configureChildCompositeServiceTarget();
+ Service sourceService = new ServiceImpl("foo", parent, contract);
+ sourceService.addServiceBinding(sourceServiceBinding);
+ connector.connect(sourceService);
+ Interceptor interceptor = inboundChain.getHeadInterceptor();
+ MessageImpl msg = new MessageImpl();
+ msg.setTargetInvoker(new MockInvoker());
+ Message resp = interceptor.invoke(msg);
+ assertEquals(RESPONSE, resp.getBody());
+ }
+
+ public void testConnectServiceToReference() throws Exception {
+ configureReferenceTarget();
+ Service sourceService = new ServiceImpl("foo", parent, contract);
+ sourceService.addServiceBinding(sourceServiceBinding);
+ connector.connect(sourceService);
+ Interceptor interceptor = inboundChain.getHeadInterceptor();
+ MessageImpl msg = new MessageImpl();
+ msg.setTargetInvoker(new MockInvoker());
+ Message resp = interceptor.invoke(msg);
+ assertEquals(RESPONSE, resp.getBody());
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ inboundChain = new InboundInvocationChainImpl(operation);
+ InboundWire inboundWire = new InboundWireImpl();
+ inboundWire.setServiceContract(contract);
+ inboundWire.addInvocationChain(operation, inboundChain);
+
+ OutboundInvocationChain outboundChain = new
OutboundInvocationChainImpl(operation);
+ // Outbound chains always contains at least one interceptor
+ outboundChain.addInterceptor(new SynchronousBridgingInterceptor());
+ OutboundWire outboundWire = new OutboundWireImpl();
+ outboundWire.setServiceContract(contract);
+ outboundWire.setTargetName(TARGET_SERVICE_NAME);
+ outboundWire.addInvocationChain(operation, outboundChain);
+
+ sourceServiceBinding = new MockServiceBinding();
+ sourceServiceBinding.setInboundWire(inboundWire);
+ sourceServiceBinding.setOutboundWire(outboundWire);
+ inboundWire.setContainer(sourceServiceBinding);
+ outboundWire.setContainer(sourceServiceBinding);
+
+ }
+
+ private void configureAtomicTarget() throws Exception {
+ InboundInvocationChain inboundChain = new
InboundInvocationChainImpl(operation);
+ inboundChain.addInterceptor(new InvokerInterceptor());
+ InboundWire inboundWire = new InboundWireImpl();
+ inboundWire.setServiceContract(contract);
+ inboundWire.addInvocationChain(operation, inboundChain);
+
+ atomicTarget = EasyMock.createMock(AtomicComponent.class);
+
EasyMock.expect(atomicTarget.getInboundWire(EasyMock.isA(String.class))).andReturn(inboundWire).atLeastOnce();
+ EasyMock.expect(atomicTarget.getScope()).andReturn(Scope.COMPOSITE);
+
EasyMock.expect(atomicTarget.createTargetInvoker(EasyMock.isA(String.class),
+ EasyMock.isA(Operation.class),
+ EasyMock.isA(InboundWire.class))).andReturn(new MockInvoker());
+ EasyMock.replay(atomicTarget);
+
+ inboundWire.setContainer(atomicTarget);
+
+ parent = EasyMock.createNiceMock(CompositeComponent.class);
+ EasyMock.expect(parent.getChild(TARGET)).andReturn(atomicTarget);
+ EasyMock.replay(parent);
+ }
+
+ private void configureChildCompositeServiceTarget() throws Exception {
+ InboundInvocationChain inboundChain = new
InboundInvocationChainImpl(operation);
+ inboundChain.addInterceptor(new InvokerInterceptor());
+ InboundWire inboundWire = new InboundWireImpl();
+ inboundWire.setServiceContract(contract);
+ inboundWire.addInvocationChain(operation, inboundChain);
+
+ compositeTarget = EasyMock.createMock(CompositeComponent.class);
+ Service service = createLocalService(compositeTarget);
+
EasyMock.expect(compositeTarget.getService(TARGET_SERVICE)).andReturn(service);
+ EasyMock.replay(compositeTarget);
+
+ inboundWire.setContainer(compositeTarget);
+
+ parent = EasyMock.createNiceMock(CompositeComponent.class);
+ EasyMock.expect(parent.getChild(TARGET)).andReturn(compositeTarget);
+ EasyMock.replay(parent);
+ }
+
+
+ private void configureReferenceTarget() throws Exception {
+ ReferenceBinding binding = createLocalReferenceBinding(TARGET_NAME);
+ referenceTarget = new ReferenceImpl(TARGET, parent, contract);
+ referenceTarget.addReferenceBinding(binding);
+ // put a terminating interceptor on the outbound wire of the reference
for testing an invocation
+
binding.getOutboundWire().getInvocationChains().get(operation).addInterceptor(new
InvokerInterceptor());
+ connector.connect(binding.getInboundWire(), binding.getOutboundWire(),
true);
+ parent = EasyMock.createNiceMock(CompositeComponent.class);
+ EasyMock.expect(parent.getChild(TARGET)).andReturn(referenceTarget);
+ EasyMock.replay(parent);
+ }
+
+}
Propchange:
incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/builder/ServiceConnectorTestCase.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/builder/ServiceConnectorTestCase.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]