summaryrefslogtreecommitdiffstats
path: root/sandbox/ant/container.script/src/test/java/org/apache/tuscany/container/script/helper/ScriptHelperInstanceFactoryTestCase.java
diff options
context:
space:
mode:
Diffstat (limited to 'sandbox/ant/container.script/src/test/java/org/apache/tuscany/container/script/helper/ScriptHelperInstanceFactoryTestCase.java')
-rw-r--r--sandbox/ant/container.script/src/test/java/org/apache/tuscany/container/script/helper/ScriptHelperInstanceFactoryTestCase.java56
1 files changed, 56 insertions, 0 deletions
diff --git a/sandbox/ant/container.script/src/test/java/org/apache/tuscany/container/script/helper/ScriptHelperInstanceFactoryTestCase.java b/sandbox/ant/container.script/src/test/java/org/apache/tuscany/container/script/helper/ScriptHelperInstanceFactoryTestCase.java
new file mode 100644
index 0000000000..132ea2bdfc
--- /dev/null
+++ b/sandbox/ant/container.script/src/test/java/org/apache/tuscany/container/script/helper/ScriptHelperInstanceFactoryTestCase.java
@@ -0,0 +1,56 @@
+package org.apache.tuscany.container.script.helper;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.container.script.helper.ScriptHelperInstance;
+import org.apache.tuscany.container.script.helper.mock.MockInstanceFactory;
+
+public class ScriptHelperInstanceFactoryTestCase extends TestCase {
+
+ public void testCreateInstance() throws InvocationTargetException {
+ MockInstanceFactory factory = new MockInstanceFactory("foo.mock", getClass().getClassLoader());
+ Map<String, Object> context = new HashMap<String, Object>();
+ context.put("foo", "bar");
+ ScriptHelperInstance instance = factory.createInstance(null, context);
+ assertNotNull(instance);
+ }
+
+ public void testCreateInstanceNoClass() throws InvocationTargetException {
+ MockInstanceFactory factory = new MockInstanceFactory("foo.mock", getClass().getClassLoader());
+ Map<String, Object> context = new HashMap<String, Object>();
+ context.put("foo", "bar");
+ ScriptHelperInstance instance = factory.createInstance(null, context);
+ assertNotNull(instance);
+ }
+
+ public void testCreateInstanceRuby() throws InvocationTargetException {
+ MockInstanceFactory factory = new MockInstanceFactory("foo.mock", getClass().getClassLoader());
+ Map<String, Object> context = new HashMap<String, Object>();
+ context.put("foo", "bar");
+ ScriptHelperInstance instance = factory.createInstance(null, context);
+ assertNotNull(instance);
+ }
+
+ public void testGetters() throws InvocationTargetException {
+ MockInstanceFactory factory = new MockInstanceFactory("foo", getClass().getClassLoader());
+ assertEquals("foo", factory.getResourceName());
+ assertEquals(getClass().getClassLoader(), factory.getClassLoader());
+ }
+
+ public void testGetResponseClasses() {
+ MockInstanceFactory factory = new MockInstanceFactory("foo", getClass().getClassLoader());
+ Map<String, Class> classes = factory.getResponseClasses(Arrays.asList( new Class[]{ Runnable.class}));
+ assertEquals(1, classes.size());
+ assertEquals("run", classes.keySet().iterator().next());
+ assertEquals(void.class, classes.get("run"));
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+}