summaryrefslogtreecommitdiffstats
path: root/sandbox/ant/container.easy/src/test/java/org/apache/tuscany/container/easy/EasyInstanceFactoryTestCase.java
diff options
context:
space:
mode:
Diffstat (limited to 'sandbox/ant/container.easy/src/test/java/org/apache/tuscany/container/easy/EasyInstanceFactoryTestCase.java')
-rw-r--r--sandbox/ant/container.easy/src/test/java/org/apache/tuscany/container/easy/EasyInstanceFactoryTestCase.java55
1 files changed, 55 insertions, 0 deletions
diff --git a/sandbox/ant/container.easy/src/test/java/org/apache/tuscany/container/easy/EasyInstanceFactoryTestCase.java b/sandbox/ant/container.easy/src/test/java/org/apache/tuscany/container/easy/EasyInstanceFactoryTestCase.java
new file mode 100644
index 0000000000..c96d8425eb
--- /dev/null
+++ b/sandbox/ant/container.easy/src/test/java/org/apache/tuscany/container/easy/EasyInstanceFactoryTestCase.java
@@ -0,0 +1,55 @@
+package org.apache.tuscany.container.easy;
+
+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.easy.mock.MockInstanceFactory;
+
+public class EasyInstanceFactoryTestCase 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");
+ EasyInstance 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");
+ EasyInstance 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");
+ EasyInstance 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();
+ }
+}