summaryrefslogtreecommitdiffstats
path: root/java/sca
diff options
context:
space:
mode:
authormcombellack <mcombellack@13f79535-47bb-0310-9956-ffa450edef68>2008-12-03 14:35:23 +0000
committermcombellack <mcombellack@13f79535-47bb-0310-9956-ffa450edef68>2008-12-03 14:35:23 +0000
commitec1f304793d6c8b8be2153377e1e49604316bf8b (patch)
treebfec45b6b2a09dd82ee0d003e48d9fa930d95070 /java/sca
parent0e1175437e6913d746cb235f35d80418ed44b7e0 (diff)
Converted unit tests from JUnit 3 to JUnit 4
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@722905 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/sca')
-rw-r--r--java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/context/MultiplicityTestCase.java6
-rw-r--r--java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/FieldInjectorTestCase.java13
-rw-r--r--java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/MethodEventInvokerTestCase.java15
-rw-r--r--java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/MethodInjectorTestCase.java15
-rw-r--r--java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/RequestContextObjectFactoryTestCase.java7
-rw-r--r--java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/SingletonObjectFactoryTestCase.java7
-rw-r--r--java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/TestObjectFactoryTestCase.java17
-rw-r--r--java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/util/JavaIntrospectionHelperTestCase.java26
8 files changed, 66 insertions, 40 deletions
diff --git a/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/context/MultiplicityTestCase.java b/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/context/MultiplicityTestCase.java
index ba8da101c6..629ba8b321 100644
--- a/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/context/MultiplicityTestCase.java
+++ b/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/context/MultiplicityTestCase.java
@@ -18,7 +18,8 @@
*/
package org.apache.tuscany.sca.implementation.java.context;
-import junit.framework.TestCase;
+import org.junit.Test;
+
/**
@@ -26,8 +27,9 @@ import junit.framework.TestCase;
*
* @version $Rev$ $Date$
*/
-public class MultiplicityTestCase extends TestCase {
+public class MultiplicityTestCase {
+ @Test
public void testMultiplicity() throws Exception {
// TODO implement
}
diff --git a/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/FieldInjectorTestCase.java b/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/FieldInjectorTestCase.java
index cc852cc677..098789f495 100644
--- a/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/FieldInjectorTestCase.java
+++ b/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/FieldInjectorTestCase.java
@@ -18,17 +18,21 @@
*/
package org.apache.tuscany.sca.implementation.java.injection;
+import static org.junit.Assert.assertEquals;
+
import java.lang.reflect.Field;
-import junit.framework.TestCase;
+import org.junit.Before;
+import org.junit.Test;
/**
* @version $Rev$ $Date$
*/
-public class FieldInjectorTestCase extends TestCase {
+public class FieldInjectorTestCase {
protected Field protectedField;
+ @Test
public void testIllegalAccess() throws Exception {
FieldInjector<Foo> injector = new FieldInjector<Foo>(protectedField, new SingletonObjectFactory<String>("foo"));
Foo foo = new Foo();
@@ -37,9 +41,8 @@ public class FieldInjectorTestCase extends TestCase {
}
- @Override
- protected void setUp() throws Exception {
- super.setUp();
+ @Before
+ public void setUp() throws Exception {
protectedField = Foo.class.getDeclaredField("hidden");
}
diff --git a/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/MethodEventInvokerTestCase.java b/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/MethodEventInvokerTestCase.java
index 4de0a4e8c7..e9cbce4390 100644
--- a/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/MethodEventInvokerTestCase.java
+++ b/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/MethodEventInvokerTestCase.java
@@ -18,20 +18,23 @@
*/
package org.apache.tuscany.sca.implementation.java.injection;
-import java.lang.reflect.Method;
+import static org.junit.Assert.fail;
-import junit.framework.TestCase;
+import java.lang.reflect.Method;
import org.apache.tuscany.sca.implementation.java.invocation.EventInvocationException;
import org.apache.tuscany.sca.implementation.java.invocation.MethodEventInvoker;
+import org.junit.Before;
+import org.junit.Test;
/**
* @version $Rev$ $Date$
*/
-public class MethodEventInvokerTestCase extends TestCase {
+public class MethodEventInvokerTestCase {
private Method privateMethod;
private Method exceptionMethod;
+ @Test
public void testIllegalAccess() throws Exception {
MethodEventInvoker<MethodEventInvokerTestCase.Foo> injector = new MethodEventInvoker<Foo>(privateMethod);
try {
@@ -42,6 +45,7 @@ public class MethodEventInvokerTestCase extends TestCase {
}
}
+ @Test
public void testException() throws Exception {
MethodEventInvoker<MethodEventInvokerTestCase.Foo> injector = new MethodEventInvoker<Foo>(exceptionMethod);
try {
@@ -52,9 +56,8 @@ public class MethodEventInvokerTestCase extends TestCase {
}
}
- @Override
- protected void setUp() throws Exception {
- super.setUp();
+ @Before
+ public void setUp() throws Exception {
privateMethod = MethodEventInvokerTestCase.Foo.class.getDeclaredMethod("hidden");
exceptionMethod = MethodEventInvokerTestCase.Foo.class.getDeclaredMethod("exception");
diff --git a/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/MethodInjectorTestCase.java b/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/MethodInjectorTestCase.java
index 214779ed3f..19184d5204 100644
--- a/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/MethodInjectorTestCase.java
+++ b/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/MethodInjectorTestCase.java
@@ -18,21 +18,24 @@
*/
package org.apache.tuscany.sca.implementation.java.injection;
-import java.lang.reflect.Method;
+import static org.junit.Assert.fail;
-import junit.framework.TestCase;
+import java.lang.reflect.Method;
import org.apache.tuscany.sca.core.factory.ObjectCreationException;
import org.apache.tuscany.sca.core.factory.ObjectFactory;
+import org.junit.Before;
+import org.junit.Test;
/**
* @version $Rev$ $Date$
*/
-public class MethodInjectorTestCase extends TestCase {
+public class MethodInjectorTestCase {
private Method fooMethod;
private Method privateMethod;
private Method exceptionMethod;
+ @Test
public void testIllegalArgument() throws Exception {
ObjectFactory<Object> factory = new SingletonObjectFactory<Object>(new Object());
MethodInjector<Foo> injector = new MethodInjector<Foo>(fooMethod, factory);
@@ -44,6 +47,7 @@ public class MethodInjectorTestCase extends TestCase {
}
}
+ @Test
public void testException() throws Exception {
ObjectFactory<Object> factory = new SingletonObjectFactory<Object>("foo");
MethodInjector<Foo> injector = new MethodInjector<Foo>(exceptionMethod, factory);
@@ -55,9 +59,8 @@ public class MethodInjectorTestCase extends TestCase {
}
}
- @Override
- protected void setUp() throws Exception {
- super.setUp();
+ @Before
+ public void setUp() throws Exception {
fooMethod = Foo.class.getMethod("foo", String.class);
privateMethod = Foo.class.getDeclaredMethod("hidden", String.class);
exceptionMethod = Foo.class.getDeclaredMethod("exception", String.class);
diff --git a/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/RequestContextObjectFactoryTestCase.java b/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/RequestContextObjectFactoryTestCase.java
index c470b8cf3d..61af4de19c 100644
--- a/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/RequestContextObjectFactoryTestCase.java
+++ b/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/RequestContextObjectFactoryTestCase.java
@@ -18,13 +18,16 @@
*/
package org.apache.tuscany.sca.implementation.java.injection;
-import junit.framework.TestCase;
+import static org.junit.Assert.assertNotNull;
+
+import org.junit.Test;
/**
* @version $Rev$ $Date$
*/
-public class RequestContextObjectFactoryTestCase extends TestCase {
+public class RequestContextObjectFactoryTestCase {
+ @Test
public void testInstanceCreate() {
RequestContextObjectFactory factory = new RequestContextObjectFactory(null);
assertNotNull(factory.getInstance());
diff --git a/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/SingletonObjectFactoryTestCase.java b/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/SingletonObjectFactoryTestCase.java
index 40ad1b1e95..0bb222bad4 100644
--- a/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/SingletonObjectFactoryTestCase.java
+++ b/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/SingletonObjectFactoryTestCase.java
@@ -18,13 +18,16 @@
*/
package org.apache.tuscany.sca.implementation.java.injection;
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
/**
* @version $Rev$ $Date$
*/
-public class SingletonObjectFactoryTestCase extends TestCase {
+public class SingletonObjectFactoryTestCase {
+ @Test
public void testSingleton() throws Exception {
Object o = new Object();
SingletonObjectFactory<Object> factory = new SingletonObjectFactory<Object>(o);
diff --git a/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/TestObjectFactoryTestCase.java b/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/TestObjectFactoryTestCase.java
index 1fb7abb917..ea9d15b3f6 100644
--- a/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/TestObjectFactoryTestCase.java
+++ b/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/TestObjectFactoryTestCase.java
@@ -18,21 +18,25 @@
*/
package org.apache.tuscany.sca.implementation.java.injection;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
import java.lang.reflect.Constructor;
import java.util.ArrayList;
import java.util.List;
-import junit.framework.TestCase;
-
import org.apache.tuscany.sca.core.factory.ObjectFactory;
+import org.junit.Before;
+import org.junit.Test;
/**
* @version $Rev$ $Date$
*/
-public class TestObjectFactoryTestCase extends TestCase {
+public class TestObjectFactoryTestCase {
private Constructor<Foo> ctor;
+ @Test
public void testConstructorInjection() throws Exception {
List<ObjectFactory> initializers = new ArrayList<ObjectFactory>();
initializers.add(new SingletonObjectFactory<String>("foo"));
@@ -45,6 +49,7 @@ public class TestObjectFactoryTestCase extends TestCase {
* Verifies null parameters can be passed to a constructor. This is valid when a reference is optional during
* constructor injection
*/
+ @Test
public void testConstructorInjectionOptionalParam() throws Exception {
List<ObjectFactory> initializers = new ArrayList<ObjectFactory>();
initializers.add(null);
@@ -53,6 +58,7 @@ public class TestObjectFactoryTestCase extends TestCase {
assertNull(foo.foo);
}
+ @Test
public void testConstructorInitializerInjection() throws Exception {
TestObjectFactory<Foo> factory = new TestObjectFactory<Foo>(ctor);
factory.setInitializerFactory(0, new SingletonObjectFactory<String>("foo"));
@@ -60,9 +66,8 @@ public class TestObjectFactoryTestCase extends TestCase {
assertEquals("foo", foo.foo);
}
- @Override
- protected void setUp() throws Exception {
- super.setUp();
+ @Before
+ public void setUp() throws Exception {
ctor = Foo.class.getConstructor(String.class);
}
diff --git a/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/util/JavaIntrospectionHelperTestCase.java b/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/util/JavaIntrospectionHelperTestCase.java
index b104f1a6c0..192536e2c9 100644
--- a/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/util/JavaIntrospectionHelperTestCase.java
+++ b/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/util/JavaIntrospectionHelperTestCase.java
@@ -18,6 +18,9 @@
*/
package org.apache.tuscany.sca.implementation.java.util;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
@@ -25,15 +28,14 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
-import junit.framework.TestCase;
-
import org.apache.tuscany.sca.implementation.java.introspect.JavaIntrospectionHelper;
+import org.junit.Test;
/**
*
* @version $Rev$ $Date$
*/
-public class JavaIntrospectionHelperTestCase extends TestCase {
+public class JavaIntrospectionHelperTestCase {
private List testNoGenericsList;
private List<String> testList;
@@ -41,29 +43,25 @@ public class JavaIntrospectionHelperTestCase extends TestCase {
private Entry[] testArray;
private String[] testStringArray;
- public JavaIntrospectionHelperTestCase() {
- super();
- }
-
- public JavaIntrospectionHelperTestCase(String arg0) {
- super(arg0);
- }
-
+ @Test
public void testBean1AllPublicProtectedFields() throws Exception {
Set<Field> beanFields = JavaIntrospectionHelper.getAllPublicAndProtectedFields(Bean1.class, true);
assertEquals(4, beanFields.size()); //Bean1.ALL_BEAN1_PUBLIC_PROTECTED_FIELDS
}
+ @Test
public void testGetSuperAllMethods() throws Exception {
Set<Method> superBeanMethods = JavaIntrospectionHelper.getAllUniquePublicProtectedMethods(SuperBean.class, true);
assertEquals(SuperBean.ALL_SUPER_METHODS, superBeanMethods.size());
}
+ @Test
public void testGetBean1AllMethods() throws Exception {
Set<Method> beanMethods = JavaIntrospectionHelper.getAllUniquePublicProtectedMethods(Bean1.class, true);
assertEquals(Bean1.ALL_BEAN1_METHODS, beanMethods.size());
}
+ @Test
public void testOverrideMethod() throws Exception {
Set<Method> beanFields = JavaIntrospectionHelper.getAllUniquePublicProtectedMethods(Bean1.class, true);
boolean invoked = false;
@@ -78,6 +76,7 @@ public class JavaIntrospectionHelperTestCase extends TestCase {
}
}
+ @Test
public void testNoOverrideMethod() throws Exception {
Set<Method> beanFields = JavaIntrospectionHelper.getAllUniquePublicProtectedMethods(Bean1.class, true);
boolean found = false;
@@ -91,6 +90,7 @@ public class JavaIntrospectionHelperTestCase extends TestCase {
}
}
+ @Test
public void testDefaultConstructor() throws Exception {
Constructor ctr = JavaIntrospectionHelper.getDefaultConstructor(Bean2.class);
assertEquals(ctr, Bean2.class.getConstructor());
@@ -98,6 +98,7 @@ public class JavaIntrospectionHelperTestCase extends TestCase {
}
+ @Test
public void testGetAllInterfaces() {
Set<Class> interfaces = JavaIntrospectionHelper.getAllInterfaces(Z.class);
assertEquals(2, interfaces.size());
@@ -106,11 +107,13 @@ public class JavaIntrospectionHelperTestCase extends TestCase {
}
+ @Test
public void testGetAllInterfacesObject() {
Set<Class> interfaces = JavaIntrospectionHelper.getAllInterfaces(Object.class);
assertEquals(0, interfaces.size());
}
+ @Test
public void testGetAllInterfacesNoInterfaces() {
Set<Class> interfaces = JavaIntrospectionHelper.getAllInterfaces(NoInterface.class);
assertEquals(0, interfaces.size());
@@ -119,6 +122,7 @@ public class JavaIntrospectionHelperTestCase extends TestCase {
/**
* Tests generics introspection capabilities
*/
+ @Test
public void testGenerics() throws Exception {
List classes = JavaIntrospectionHelper.getGenerics(getClass().getDeclaredField("testList").getGenericType());