diff options
Diffstat (limited to 'branches/sca-java-integration/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/wire/AbstractOutboundInvocationHandlerTestCase.java')
-rw-r--r-- | branches/sca-java-integration/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/wire/AbstractOutboundInvocationHandlerTestCase.java | 102 |
1 files changed, 0 insertions, 102 deletions
diff --git a/branches/sca-java-integration/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/wire/AbstractOutboundInvocationHandlerTestCase.java b/branches/sca-java-integration/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/wire/AbstractOutboundInvocationHandlerTestCase.java deleted file mode 100644 index 617a055e78..0000000000 --- a/branches/sca-java-integration/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/wire/AbstractOutboundInvocationHandlerTestCase.java +++ /dev/null @@ -1,102 +0,0 @@ -package org.apache.tuscany.spi.wire; - -import java.lang.reflect.Array; -import java.lang.reflect.InvocationTargetException; -import java.util.LinkedList; - -import junit.framework.TestCase; -import org.easymock.EasyMock; - -/** - * @version $Rev$ $Date$ - */ -public class AbstractOutboundInvocationHandlerTestCase extends TestCase { - - public void testInvocation() throws Throwable { - InvocationHandler handler = new InvocationHandler(); - Interceptor interceptor = new MockInterceptor(); - TargetInvoker invoker = EasyMock.createMock(TargetInvoker.class); - EasyMock.replay(invoker); - OutboundInvocationChain chain = EasyMock.createMock(OutboundInvocationChain.class); - EasyMock.expect(chain.getHeadInterceptor()).andReturn(interceptor); - EasyMock.replay(chain); - Object resp = handler.invoke(chain, invoker, new String[]{"foo"}, null, new LinkedList<Object>()); - assertEquals("response", resp); - } - - public void testShortCircuitInvocation() throws Throwable { - InvocationHandler handler = new InvocationHandler(); - TargetInvoker invoker = new MockInvoker(); - OutboundInvocationChain chain = EasyMock.createMock(OutboundInvocationChain.class); - EasyMock.expect(chain.getHeadInterceptor()).andReturn(null); - EasyMock.expect(chain.getTargetInvoker()).andReturn(invoker); - EasyMock.replay(chain); - Object resp = handler.invoke(chain, invoker, new String[]{"foo"}, null, new LinkedList<Object>()); - assertEquals("response", resp); - } - - - private class MockInvoker implements TargetInvoker { - - public Object invokeTarget(final Object payload, final short sequence) throws InvocationTargetException { - assertEquals("foo", Array.get(payload, 0)); - return "response"; - } - - public Message invoke(Message msg) throws InvocationRuntimeException { - fail(); - return null; - } - - public boolean isCacheable() { - return false; - } - - public void setCacheable(boolean cacheable) { - - } - - public boolean isOptimizable() { - return false; - } - - public Object clone() throws CloneNotSupportedException { - return super.clone(); - } - } - - private class InvocationHandler extends AbstractOutboundInvocationHandler { - - protected Object getFromAddress() { - return new Object(); - } - - } - - private class MockInterceptor implements Interceptor { - - public Message invoke(Message msg) { - assertNotNull(msg.getCorrelationId()); - assertNotNull(msg.getTargetInvoker()); - assertNotNull(msg.getMessageId()); - assertNotNull(msg.getCallbackRoutingChain()); - assertEquals("foo", Array.get(msg.getBody(), 0)); - msg.setBody("response"); - return msg; - } - - public void setNext(Interceptor next) { - - } - - public Interceptor getNext() { - return null; - } - - public boolean isOptimizable() { - return false; - } - } - - -} |