summaryrefslogtreecommitdiffstats
path: root/sandbox/ant/container.python/src/test/java/org/apache/tuscany/container/python/PythonInvokerTestCase.java
diff options
context:
space:
mode:
Diffstat (limited to 'sandbox/ant/container.python/src/test/java/org/apache/tuscany/container/python/PythonInvokerTestCase.java')
-rw-r--r--sandbox/ant/container.python/src/test/java/org/apache/tuscany/container/python/PythonInvokerTestCase.java62
1 files changed, 62 insertions, 0 deletions
diff --git a/sandbox/ant/container.python/src/test/java/org/apache/tuscany/container/python/PythonInvokerTestCase.java b/sandbox/ant/container.python/src/test/java/org/apache/tuscany/container/python/PythonInvokerTestCase.java
new file mode 100644
index 0000000000..03a9151a47
--- /dev/null
+++ b/sandbox/ant/container.python/src/test/java/org/apache/tuscany/container/python/PythonInvokerTestCase.java
@@ -0,0 +1,62 @@
+package org.apache.tuscany.container.python;
+
+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 java.lang.reflect.Method;
+
+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 PythonInvokerTestCase extends TestCase {
+
+ private PythonComponent context;
+
+ private Method method;
+
+ private ScopeContainer scopeContainer;
+
+ public void testInvokeTarget() throws InvocationTargetException {
+ PythonInvoker invoker = new PythonInvoker(method, context);
+ Object o = invoker.invokeTarget(new Object[] { "petra" });
+ assertEquals("hello petra", o);
+ }
+
+ public void testInvokeTargetException() throws InvocationTargetException, SecurityException, NoSuchMethodException {
+ PythonInvoker invoker = new PythonInvoker(method, context);
+ try {
+ invoker.invokeTarget(null);
+ fail();
+ } catch (InvocationTargetException e) {
+ // expected
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ scopeContainer = createMock(ScopeContainer.class);
+ expect(scopeContainer.getInstance(isA(AtomicComponent.class))).andStubAnswer(new IAnswer() {
+ public Object answer() throws Throwable {
+ return "hello ";
+ }
+ });
+ expect(scopeContainer.getScope()).andStubAnswer(new IAnswer() {
+ public Object answer() throws Throwable {
+ return Scope.MODULE;
+ }
+ });
+ replay(scopeContainer);
+
+ context = new PythonComponent(null, null, null, null, scopeContainer, null, null);
+ method = String.class.getDeclaredMethod("concat", new Class[] { String.class });
+ }
+}