summaryrefslogtreecommitdiffstats
path: root/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/binding
diff options
context:
space:
mode:
Diffstat (limited to 'sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/binding')
-rw-r--r--sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/binding/local/AbstractLocalTargetInvokerTestCase.java72
-rw-r--r--sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/binding/local/LocalBindingBuilderTestCase.java40
-rw-r--r--sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/binding/local/LocalBindingLoaderTestCase.java70
-rw-r--r--sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/binding/local/LocalCallbackTargetInvokerInvocationExceptionTestCase.java84
-rw-r--r--sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/binding/local/LocalCallbackTargetInvokerTestCase.java83
-rw-r--r--sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/binding/local/LocalCallbackTargetInvokerThrowableTestCase.java89
-rw-r--r--sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/binding/local/LocalTargetInvokerTestCase.java115
7 files changed, 553 insertions, 0 deletions
diff --git a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/binding/local/AbstractLocalTargetInvokerTestCase.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/binding/local/AbstractLocalTargetInvokerTestCase.java
new file mode 100644
index 0000000000..dfda132671
--- /dev/null
+++ b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/binding/local/AbstractLocalTargetInvokerTestCase.java
@@ -0,0 +1,72 @@
+/*
+ * 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.binding.local;
+
+import org.apache.tuscany.spi.wire.Interceptor;
+import org.apache.tuscany.spi.wire.InvocationChain;
+import org.apache.tuscany.spi.wire.Message;
+import org.apache.tuscany.spi.wire.MessageImpl;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+
+import junit.framework.TestCase;
+import org.apache.tuscany.core.mock.wire.MockTargetInvoker;
+import org.easymock.EasyMock;
+import org.easymock.IAnswer;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class AbstractLocalTargetInvokerTestCase extends TestCase {
+
+ public void testInvokerWithInterceptor() throws Throwable {
+ AbstractLocalTargetInvoker invoker = new MockTargetInvoker();
+ Interceptor interceptor = EasyMock.createMock(Interceptor.class);
+ interceptor.invoke(EasyMock.isA(Message.class));
+ EasyMock.expectLastCall().andStubAnswer(new IAnswer<Object>() {
+ public Object answer() throws Throwable {
+ Message msg = (Message) EasyMock.getCurrentArguments()[0];
+ if (msg.getTargetInvoker() == null) {
+ fail("Target invoker not set");
+ }
+ return null;
+ }
+ });
+ EasyMock.replay(interceptor);
+ InvocationChain chain = EasyMock.createMock(InvocationChain.class);
+ EasyMock.expect(chain.getHeadInterceptor()).andReturn(interceptor);
+ EasyMock.replay(chain);
+ invoker.invoke(chain, EasyMock.createNiceMock(TargetInvoker.class), new MessageImpl());
+ EasyMock.verify(chain);
+ EasyMock.verify(interceptor);
+ }
+
+ public void testShortCircuitInvoke() throws Throwable {
+ AbstractLocalTargetInvoker invoker = new MockTargetInvoker();
+ TargetInvoker targetInvoker = EasyMock.createMock(TargetInvoker.class);
+ EasyMock.expect(targetInvoker.invoke(EasyMock.isA(Message.class))).andReturn(new MessageImpl());
+ EasyMock.replay(targetInvoker);
+ InvocationChain chain = EasyMock.createMock(InvocationChain.class);
+ EasyMock.expect(chain.getHeadInterceptor()).andReturn(null);
+ EasyMock.replay(chain);
+ invoker.invoke(chain, targetInvoker, new MessageImpl());
+ EasyMock.verify(chain);
+ EasyMock.verify(targetInvoker);
+ }
+
+}
diff --git a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/binding/local/LocalBindingBuilderTestCase.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/binding/local/LocalBindingBuilderTestCase.java
new file mode 100644
index 0000000000..e628df47e2
--- /dev/null
+++ b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/binding/local/LocalBindingBuilderTestCase.java
@@ -0,0 +1,40 @@
+/*
+ * 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.binding.local;
+
+import java.net.URI;
+
+import org.apache.tuscany.spi.component.ServiceBinding;
+import org.apache.tuscany.spi.model.ServiceDefinition;
+
+import junit.framework.TestCase;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class LocalBindingBuilderTestCase extends TestCase {
+
+ public void testBuild() throws Exception {
+ LocalBindingBuilder builder = new LocalBindingBuilder();
+ ServiceDefinition def = new ServiceDefinition();
+ def.setUri(new URI("#foo"));
+ ServiceBinding binding = builder.build(def, null, null);
+ assertEquals(LocalServiceBinding.class, binding.getClass());
+ }
+}
diff --git a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/binding/local/LocalBindingLoaderTestCase.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/binding/local/LocalBindingLoaderTestCase.java
new file mode 100644
index 0000000000..0c35ae9a09
--- /dev/null
+++ b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/binding/local/LocalBindingLoaderTestCase.java
@@ -0,0 +1,70 @@
+/*
+ * 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.binding.local;
+
+import java.net.URI;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.spi.loader.LoaderException;
+
+import junit.framework.TestCase;
+import org.easymock.EasyMock;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class LocalBindingLoaderTestCase extends TestCase {
+ private LocalBindingLoader loader;
+
+ public void testParse() throws Exception {
+ XMLStreamReader reader = EasyMock.createMock(XMLStreamReader.class);
+ EasyMock.expect(reader.getAttributeValue(null, "uri")).andReturn("foo");
+ EasyMock.replay(reader);
+ LocalBindingDefinition definition = loader.load(null, reader, null);
+ assertEquals(new URI("foo"), definition.getTargetUri());
+ EasyMock.verify(reader);
+ }
+
+ public void testNoUri() throws Exception {
+ XMLStreamReader reader = EasyMock.createMock(XMLStreamReader.class);
+ EasyMock.expect(reader.getAttributeValue(null, "uri")).andReturn(null);
+ EasyMock.replay(reader);
+ LocalBindingDefinition definition = loader.load(null, reader, null);
+ assertNull(definition.getTargetUri());
+ EasyMock.verify(reader);
+ }
+
+ public void testBadUri() throws Exception {
+ XMLStreamReader reader = EasyMock.createMock(XMLStreamReader.class);
+ EasyMock.expect(reader.getAttributeValue(null, "uri")).andReturn("foo foo");
+ EasyMock.replay(reader);
+ try {
+ loader.load(null, reader, null);
+ fail();
+ } catch (LoaderException e) {
+ // expected
+ }
+ EasyMock.verify(reader);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ loader = new LocalBindingLoader(null);
+ }
+}
diff --git a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/binding/local/LocalCallbackTargetInvokerInvocationExceptionTestCase.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/binding/local/LocalCallbackTargetInvokerInvocationExceptionTestCase.java
new file mode 100644
index 0000000000..9b83d95918
--- /dev/null
+++ b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/binding/local/LocalCallbackTargetInvokerInvocationExceptionTestCase.java
@@ -0,0 +1,84 @@
+/*
+ * 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.binding.local;
+
+import java.lang.reflect.Type;
+
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.wire.Interceptor;
+import org.apache.tuscany.spi.wire.InvocationChain;
+import org.apache.tuscany.spi.wire.Message;
+import org.apache.tuscany.spi.wire.MessageImpl;
+import org.apache.tuscany.spi.wire.Wire;
+
+import junit.framework.TestCase;
+import org.apache.tuscany.core.wire.InvocationChainImpl;
+import org.apache.tuscany.core.wire.WireImpl;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class LocalCallbackTargetInvokerInvocationExceptionTestCase extends TestCase {
+
+ /**
+ * Verfies an InvocationTargetException thrown when invoking the target is propagated to the client correctly and
+ * the originating error is unwrapped
+ */
+ public void testThrowableTargetInvocation() throws Exception {
+ Operation<Type> operation = new Operation<Type>("echo", null, null, null);
+ Interceptor head = new ErrorInterceptor();
+ InvocationChain chain = new InvocationChainImpl(operation);
+ chain.addInterceptor(head);
+ Wire wire = new WireImpl();
+ wire.addCallbackInvocationChain(operation, chain);
+ LocalCallbackTargetInvoker invoker = new LocalCallbackTargetInvoker(operation, wire);
+ Message msg = new MessageImpl();
+ msg.setBody("foo");
+ Message response = invoker.invoke(msg);
+ assertTrue(response.isFault());
+ Object body = response.getBody();
+ assertTrue(SomeException.class.equals(body.getClass()));
+ }
+
+ private class SomeException extends Exception {
+
+ }
+
+ private class ErrorInterceptor implements Interceptor {
+
+ public Message invoke(Message msg) {
+ msg.setBodyWithFault(new SomeException());
+ return msg;
+ }
+
+ public void setNext(Interceptor next) {
+
+ }
+
+ public Interceptor getNext() {
+ return null;
+ }
+
+ public boolean isOptimizable() {
+ return false;
+ }
+ }
+
+
+}
diff --git a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/binding/local/LocalCallbackTargetInvokerTestCase.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/binding/local/LocalCallbackTargetInvokerTestCase.java
new file mode 100644
index 0000000000..d922ec8033
--- /dev/null
+++ b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/binding/local/LocalCallbackTargetInvokerTestCase.java
@@ -0,0 +1,83 @@
+/*
+ * 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.binding.local;
+
+import java.lang.reflect.Type;
+import java.net.URI;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.wire.Interceptor;
+import org.apache.tuscany.spi.wire.InvocationChain;
+import org.apache.tuscany.spi.wire.Message;
+import org.apache.tuscany.spi.wire.MessageImpl;
+import org.apache.tuscany.spi.wire.Wire;
+
+import junit.framework.TestCase;
+import org.easymock.EasyMock;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class LocalCallbackTargetInvokerTestCase extends TestCase {
+ private Wire wire;
+ private Message message;
+ private InvocationChain chain;
+ private Interceptor head;
+ private LocalCallbackTargetInvoker invoker;
+
+ /**
+ * Verfies the normal execution path through a callback
+ */
+ public void testNormalPathMessageInvocation() throws Exception {
+ Message response = invoker.invoke(message);
+ assertEquals("response", response.getBody());
+ EasyMock.verify(wire);
+ EasyMock.verify(chain);
+ EasyMock.verify(head);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ URI targetAddress = URI.create("from");
+ message = new MessageImpl();
+ message.pushCallbackUri(targetAddress);
+ message.setBody("foo");
+ Message response = new MessageImpl();
+ response.setBody("response");
+ Operation<Type> operation = new Operation<Type>("echo", null, null, null);
+ head = EasyMock.createMock(Interceptor.class);
+ EasyMock.expect(head.invoke(EasyMock.isA(Message.class))).andReturn(response);
+ EasyMock.replay(head);
+ chain = EasyMock.createMock(InvocationChain.class);
+ EasyMock.expect(chain.getTargetInvoker()).andReturn(null);
+ EasyMock.expect(chain.getHeadInterceptor()).andReturn(head);
+ EasyMock.replay(chain);
+ Map<Operation<?>, InvocationChain> chains = new HashMap<Operation<?>, InvocationChain>();
+ chains.put(operation, chain);
+ wire = EasyMock.createMock(Wire.class);
+ EasyMock.expect(wire.getCallbackInvocationChains()).andReturn(chains);
+ EasyMock.replay(wire);
+
+ invoker = new LocalCallbackTargetInvoker(operation, wire);
+ }
+
+
+}
diff --git a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/binding/local/LocalCallbackTargetInvokerThrowableTestCase.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/binding/local/LocalCallbackTargetInvokerThrowableTestCase.java
new file mode 100644
index 0000000000..0c06842a60
--- /dev/null
+++ b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/binding/local/LocalCallbackTargetInvokerThrowableTestCase.java
@@ -0,0 +1,89 @@
+/*
+ * 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.binding.local;
+
+import java.lang.reflect.Type;
+
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.wire.Interceptor;
+import org.apache.tuscany.spi.wire.InvocationChain;
+import org.apache.tuscany.spi.wire.Message;
+import org.apache.tuscany.spi.wire.MessageImpl;
+import org.apache.tuscany.spi.wire.Wire;
+
+import junit.framework.TestCase;
+import org.apache.tuscany.core.wire.InvocationChainImpl;
+import org.apache.tuscany.core.wire.WireImpl;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class LocalCallbackTargetInvokerThrowableTestCase extends TestCase {
+ private LocalCallbackTargetInvoker invoker;
+
+ /**
+ * Verfies an exception thrown in the target is propagated to the client correctly
+ */
+ public void testThrowableTargetInvocation() throws Exception {
+ Message message = new MessageImpl();
+ message.setBody("foo");
+ Message response = invoker.invoke(message);
+ assertTrue(response.isFault());
+ Object body = response.getBody();
+ if (!(body instanceof InsidiousException)) {
+ fail();
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ protected void setUp() throws Exception {
+ super.setUp();
+ Operation<Type> operation = new Operation<Type>("echo", null, null, null);
+ InvocationChain chain = new InvocationChainImpl(operation);
+ chain.addInterceptor(new InsidiuousInterceptor());
+ Wire wire = new WireImpl();
+ wire.addCallbackInvocationChain(operation, chain);
+ invoker = new LocalCallbackTargetInvoker(operation, wire);
+ }
+
+ private class InsidiousException extends RuntimeException {
+
+ }
+
+ private class InsidiuousInterceptor implements Interceptor {
+
+ public Message invoke(Message msg) throws InsidiousException {
+ throw new InsidiousException();
+ }
+
+ public void setNext(Interceptor next) {
+
+ }
+
+ public Interceptor getNext() {
+ return null;
+ }
+
+ public boolean isOptimizable() {
+ return false;
+ }
+ }
+
+
+}
diff --git a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/binding/local/LocalTargetInvokerTestCase.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/binding/local/LocalTargetInvokerTestCase.java
new file mode 100644
index 0000000000..e49447164d
--- /dev/null
+++ b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/binding/local/LocalTargetInvokerTestCase.java
@@ -0,0 +1,115 @@
+/*
+ * 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.binding.local;
+
+import java.net.URI;
+
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.model.ServiceContract;
+import org.apache.tuscany.spi.wire.InvocationChain;
+import org.apache.tuscany.spi.wire.Message;
+import org.apache.tuscany.spi.wire.MessageImpl;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+import org.apache.tuscany.spi.wire.Wire;
+
+import junit.framework.TestCase;
+import org.apache.tuscany.core.wire.InvocationChainImpl;
+import org.apache.tuscany.core.wire.WireImpl;
+import org.easymock.EasyMock;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class LocalTargetInvokerTestCase extends TestCase {
+ private ServiceContract<Object> serviceContract;
+ private Operation<Object> operation;
+
+ public void testInvoke() {
+ TargetInvoker targetInvoker = EasyMock.createMock(TargetInvoker.class);
+ EasyMock.expect(targetInvoker.invoke(EasyMock.isA(Message.class))).andReturn(new MessageImpl());
+ EasyMock.replay(targetInvoker);
+ InvocationChain chain = new InvocationChainImpl(operation);
+ chain.setTargetInvoker(targetInvoker);
+ Wire wire = new WireImpl();
+ wire.addInvocationChain(operation, chain);
+ wire.setSourceContract(serviceContract);
+ TargetInvoker invoker = new LocalTargetInvoker(operation, wire);
+ Message msg = invoker.invoke(new MessageImpl());
+ assertFalse(msg.isFault());
+ EasyMock.verify(targetInvoker);
+ }
+
+ public void testCallbackSetInvoke() {
+ ServiceContract<?> contract = new ServiceContract<Object>() {
+
+ };
+ contract.setCallbackClass(Object.class);
+ TargetInvoker targetInvoker = EasyMock.createMock(TargetInvoker.class);
+ EasyMock.expect(targetInvoker.invoke(EasyMock.isA(Message.class))).andReturn(new MessageImpl());
+ EasyMock.replay(targetInvoker);
+
+ InvocationChain chain = new InvocationChainImpl(operation);
+ chain.setTargetInvoker(targetInvoker);
+ InvocationChain callbackChain = new InvocationChainImpl(operation);
+ Wire wire = new WireImpl();
+ wire.addInvocationChain(operation, chain);
+ wire.addCallbackInvocationChain(operation, callbackChain);
+ wire.setSourceContract(serviceContract);
+ URI uri = URI.create("foo");
+ wire.setSourceUri(uri);
+ wire.addInvocationChain(operation, chain);
+ TargetInvoker invoker = new LocalTargetInvoker(operation, wire);
+ Message msg = EasyMock.createMock(Message.class);
+ msg.pushCallbackUri(EasyMock.eq(uri));
+ EasyMock.replay(msg);
+ invoker.invoke(msg);
+ EasyMock.verify(msg);
+ EasyMock.verify(targetInvoker);
+ }
+
+ public void testFaultInvoke() {
+ TargetInvoker targetInvoker = EasyMock.createMock(TargetInvoker.class);
+ EasyMock.expect(targetInvoker.invoke(EasyMock.isA(Message.class))).andThrow(new TestException());
+ EasyMock.replay(targetInvoker);
+
+ InvocationChain chain = new InvocationChainImpl(operation);
+ chain.setTargetInvoker(targetInvoker);
+ Wire wire = new WireImpl();
+ wire.setSourceContract(serviceContract);
+ wire.addInvocationChain(operation, chain);
+ TargetInvoker invoker = new LocalTargetInvoker(operation, wire);
+ Message msg = invoker.invoke(new MessageImpl());
+ assertTrue(msg.isFault());
+ assertTrue(msg.getBody() instanceof TestException);
+ EasyMock.verify(targetInvoker);
+ }
+
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ serviceContract = new ServiceContract<Object>() {
+ };
+ operation = new Operation<Object>("foo", null, null, null);
+ }
+
+
+ private class TestException extends RuntimeException {
+
+ }
+}