summaryrefslogtreecommitdiffstats
path: root/sandbox/ant/container.easy/src/test/java/org/apache/tuscany/container/easy/EasyInvokerTestCase.java
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--sandbox/ant/container.easy/src/test/java/org/apache/tuscany/container/easy/EasyInvokerTestCase.java61
1 files changed, 61 insertions, 0 deletions
diff --git a/sandbox/ant/container.easy/src/test/java/org/apache/tuscany/container/easy/EasyInvokerTestCase.java b/sandbox/ant/container.easy/src/test/java/org/apache/tuscany/container/easy/EasyInvokerTestCase.java
new file mode 100644
index 0000000000..bdd5c4a875
--- /dev/null
+++ b/sandbox/ant/container.easy/src/test/java/org/apache/tuscany/container/easy/EasyInvokerTestCase.java
@@ -0,0 +1,61 @@
+package org.apache.tuscany.container.easy;
+
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.isA;
+import static org.easymock.EasyMock.replay;
+
+import java.lang.reflect.InvocationTargetException;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.spi.component.AtomicComponent;
+import org.apache.tuscany.spi.component.ScopeContainer;
+import org.apache.tuscany.spi.model.Scope;
+import org.easymock.IAnswer;
+
+public class EasyInvokerTestCase extends TestCase {
+
+ private EasyComponent component;
+
+ public void testInvokeTarget() throws InvocationTargetException {
+ EasyInvoker invoker = new EasyInvoker("hello", component);
+ assertEquals("hello petra", invoker.invokeTarget(null));
+ }
+
+ public void testInvokeTargetException() throws InvocationTargetException, SecurityException, NoSuchMethodException {
+ EasyInvoker badInvoker = new EasyInvoker("bang", component);
+ try {
+ badInvoker.invokeTarget(null);
+ fail();
+ } catch (InvocationTargetException e) {
+ // expected
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ ScopeContainer scopeContainer = createMock(ScopeContainer.class);
+ expect(scopeContainer.getScope()).andStubAnswer(new IAnswer() {
+ public Object answer() throws Throwable {
+ return Scope.MODULE;
+ }
+ });
+ expect(scopeContainer.getInstance(isA(AtomicComponent.class))).andStubAnswer(new IAnswer() {
+ public Object answer() throws Throwable {
+ return new EasyInstance(){
+ public Object invokeTarget(String operationName, Object[] args) throws InvocationTargetException {
+ if ("bang".equals(operationName)) {
+ throw new RuntimeException("bang");
+ }
+ return "hello petra";
+ }};
+ }
+ });
+ replay(scopeContainer);
+
+ this.component = new EasyComponent(null, null, null, null, null, scopeContainer, null, null, null);
+ }
+}