From 1a46a0c08b3e56439e6760c2755609c73c5af4f8 Mon Sep 17 00:00:00 2001 From: mcombellack Date: Wed, 3 Dec 2008 12:09:11 +0000 Subject: Converted unit tests from JUnit 3 to JUnit 4 git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@722852 13f79535-47bb-0310-9956-ffa450edef68 --- .../introspect/impl/AbstractProcessorTest.java | 4 +-- .../impl/AbstractPropertyProcessorTestCase.java | 20 ++++++++++----- .../AllowsPassByReferenceProcessorTestCase.java | 15 ++++++----- .../impl/ConstructorProcessorTestCase.java | 16 +++++++++--- .../impl/ConstructorPropertyTestCase.java | 12 +++++++++ .../impl/ConstructorReferenceTestCase.java | 16 ++++++++---- .../impl/ConstructorResourceTestCase.java | 12 +++++++++ .../introspect/impl/ContextProcessorTestCase.java | 27 +++++++++++++++++--- .../impl/ConversationIDProcessorTestCase.java | 17 ++++++++----- .../impl/ConversationProcessorTestCase.java | 15 ++++++++--- .../introspect/impl/ConvertTimeMillisTestCase.java | 19 ++++++++++---- .../introspect/impl/DestroyProcessorTestCase.java | 13 +++++++--- .../impl/EagerInitProcessorTestCase.java | 7 +++--- .../impl/HeuristicAndPropertyTestCase.java | 14 ++++++----- .../impl/HeuristicConstructorTestCase.java | 18 ++++++++++++++ .../impl/HeuristicPojoProcessorTestCase.java | 19 ++++++++++++++ .../HeutisticExtensibleConstructorTestCase.java | 6 +++++ .../introspect/impl/InitProcessorTestCase.java | 15 ++++++++++- .../introspect/impl/PolicyProcessorTestCase.java | 15 ++++++----- .../introspect/impl/PropertyProcessorTestCase.java | 28 ++++++++++++++++----- .../impl/ReferenceProcessorTestCase.java | 29 +++++++++++++++++++--- .../introspect/impl/ResourceProcessorTestCase.java | 21 +++++++++++----- .../introspect/impl/ScopeProcessorTestCase.java | 17 +++++++++---- .../introspect/impl/ServiceCallbackTestCase.java | 21 ++++++++++++---- .../introspect/impl/ServiceProcessorTestCase.java | 24 +++++++++++++++--- 25 files changed, 330 insertions(+), 90 deletions(-) (limited to 'java/sca') diff --git a/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AbstractProcessorTest.java b/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AbstractProcessorTest.java index 805ea494b2..842897606c 100644 --- a/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AbstractProcessorTest.java +++ b/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AbstractProcessorTest.java @@ -20,8 +20,6 @@ package org.apache.tuscany.sca.implementation.java.introspect.impl; import java.lang.reflect.Constructor; -import junit.framework.TestCase; - import org.apache.tuscany.sca.assembly.AssemblyFactory; import org.apache.tuscany.sca.assembly.DefaultAssemblyFactory; import org.apache.tuscany.sca.implementation.java.IntrospectionException; @@ -37,7 +35,7 @@ import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory; * * @version $Rev$ $Date$ */ -public class AbstractProcessorTest extends TestCase { +public abstract class AbstractProcessorTest { protected AssemblyFactory factory; protected JavaInterfaceFactory javaFactory; protected ConstructorProcessor constructorProcessor; diff --git a/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AbstractPropertyProcessorTestCase.java b/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AbstractPropertyProcessorTestCase.java index 3c8022d1d8..bec0968788 100644 --- a/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AbstractPropertyProcessorTestCase.java +++ b/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AbstractPropertyProcessorTestCase.java @@ -20,14 +20,15 @@ package org.apache.tuscany.sca.implementation.java.introspect.impl; import static java.lang.annotation.RetentionPolicy.RUNTIME; import static org.apache.tuscany.sca.implementation.java.introspect.impl.ModelHelper.getProperty; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.fail; import java.lang.annotation.Retention; import java.lang.reflect.Constructor; import java.lang.reflect.Field; import java.lang.reflect.Method; -import junit.framework.TestCase; - import org.apache.tuscany.sca.assembly.DefaultAssemblyFactory; import org.apache.tuscany.sca.assembly.Property; import org.apache.tuscany.sca.implementation.java.DefaultJavaImplementationFactory; @@ -36,16 +37,19 @@ import org.apache.tuscany.sca.implementation.java.JavaImplementation; import org.apache.tuscany.sca.implementation.java.JavaImplementationFactory; import org.apache.tuscany.sca.implementation.java.JavaParameterImpl; import org.apache.tuscany.sca.implementation.java.introspect.JavaClassVisitor; +import org.junit.Before; +import org.junit.Test; /** * @version $Rev$ $Date$ */ -public class AbstractPropertyProcessorTestCase extends TestCase { +public class AbstractPropertyProcessorTestCase { private JavaClassVisitor extension; private JavaImplementationFactory javaImplementationFactory; + @Test public void testVisitMethod() throws Exception { Method method = Foo.class.getMethod("setBar", String.class); JavaImplementation type = javaImplementationFactory.createJavaImplementation(); @@ -54,6 +58,7 @@ public class AbstractPropertyProcessorTestCase extends TestCase { assertNotNull(prop); } + @Test public void testVisitNoParamsMethod() throws Exception { Method method = Foo.class.getMethod("setNoParamsBar"); JavaImplementation type = javaImplementationFactory.createJavaImplementation(); @@ -65,6 +70,7 @@ public class AbstractPropertyProcessorTestCase extends TestCase { } } + @Test public void testVisitNonVoidMethod() throws Exception { Method method = Foo.class.getMethod("setBadBar", String.class); JavaImplementation type = javaImplementationFactory.createJavaImplementation(); @@ -76,6 +82,7 @@ public class AbstractPropertyProcessorTestCase extends TestCase { } } + @Test public void testDuplicateMethod() throws Exception { Method method = Foo.class.getMethod("setBar", String.class); JavaImplementation type = javaImplementationFactory.createJavaImplementation(); @@ -88,6 +95,7 @@ public class AbstractPropertyProcessorTestCase extends TestCase { } } + @Test public void testVisitField() throws Exception { Field field = Foo.class.getDeclaredField("d"); JavaImplementation type = javaImplementationFactory.createJavaImplementation(); @@ -96,6 +104,7 @@ public class AbstractPropertyProcessorTestCase extends TestCase { assertNotNull(prop); } + @Test public void testVisitConstructor() throws Exception { Constructor ctor = Foo.class.getConstructor(String.class); JavaImplementation type = javaImplementationFactory.createJavaImplementation(); @@ -106,9 +115,8 @@ public class AbstractPropertyProcessorTestCase extends TestCase { assertNotNull(getProperty(type, "test")); } - @Override - protected void setUp() throws Exception { - super.setUp(); + @Before + public void setUp() throws Exception { extension = new TestProcessor(); javaImplementationFactory = new DefaultJavaImplementationFactory(); } diff --git a/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AllowsPassByReferenceProcessorTestCase.java b/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AllowsPassByReferenceProcessorTestCase.java index e5abb07760..689201dd99 100644 --- a/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AllowsPassByReferenceProcessorTestCase.java +++ b/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AllowsPassByReferenceProcessorTestCase.java @@ -18,25 +18,29 @@ */ package org.apache.tuscany.sca.implementation.java.introspect.impl; -import java.lang.reflect.Method; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; -import junit.framework.TestCase; +import java.lang.reflect.Method; import org.apache.tuscany.sca.assembly.DefaultAssemblyFactory; import org.apache.tuscany.sca.implementation.java.DefaultJavaImplementationFactory; import org.apache.tuscany.sca.implementation.java.JavaImplementation; import org.apache.tuscany.sca.implementation.java.JavaImplementationFactory; +import org.junit.Before; +import org.junit.Test; import org.osoa.sca.annotations.AllowsPassByReference; /** * @version $Rev$ $Date$ */ -public class AllowsPassByReferenceProcessorTestCase extends TestCase { +public class AllowsPassByReferenceProcessorTestCase { JavaImplementation type; AllowsPassByReferenceProcessor processor; private JavaImplementationFactory javaImplementationFactory; + @Test public void testClassAnnotation() throws Exception { processor.visitClass(Foo.class, type); assertEquals(true, type.isAllowsPassByReference()); @@ -49,9 +53,8 @@ public class AllowsPassByReferenceProcessorTestCase extends TestCase { assertTrue(type.isAllowsPassByReference(m1)); } - @Override - protected void setUp() throws Exception { - super.setUp(); + @Before + public void setUp() throws Exception { javaImplementationFactory = new DefaultJavaImplementationFactory(); type = javaImplementationFactory.createJavaImplementation(); processor = new AllowsPassByReferenceProcessor(new DefaultAssemblyFactory()); diff --git a/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConstructorProcessorTestCase.java b/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConstructorProcessorTestCase.java index a3c87afe63..e4b89ebf65 100644 --- a/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConstructorProcessorTestCase.java +++ b/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConstructorProcessorTestCase.java @@ -20,14 +20,17 @@ package org.apache.tuscany.sca.implementation.java.introspect.impl; import static org.apache.tuscany.sca.implementation.java.introspect.impl.ModelHelper.getProperty; import static org.apache.tuscany.sca.implementation.java.introspect.impl.ModelHelper.getReference; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; import java.lang.reflect.Constructor; import java.util.Collection; import java.util.List; import java.util.Set; -import junit.framework.TestCase; - import org.apache.tuscany.sca.assembly.AssemblyFactory; import org.apache.tuscany.sca.assembly.DefaultAssemblyFactory; import org.apache.tuscany.sca.assembly.Multiplicity; @@ -37,17 +40,19 @@ import org.apache.tuscany.sca.implementation.java.JavaImplementationFactory; import org.apache.tuscany.sca.implementation.java.JavaParameterImpl; import org.apache.tuscany.sca.interfacedef.java.DefaultJavaInterfaceFactory; import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory; +import org.junit.Test; import org.osoa.sca.annotations.Property; import org.osoa.sca.annotations.Reference; /** * @version $Rev$ $Date$ */ -public class ConstructorProcessorTestCase extends TestCase { +public class ConstructorProcessorTestCase { private ConstructorProcessor processor = new ConstructorProcessor(new DefaultAssemblyFactory()); private JavaImplementationFactory javaImplementationFactory = new DefaultJavaImplementationFactory(); + @Test public void testDuplicateConstructor() throws Exception { JavaImplementation type = javaImplementationFactory.createJavaImplementation(); try { @@ -58,6 +63,7 @@ public class ConstructorProcessorTestCase extends TestCase { } } + @Test public void testConstructorAnnotation() throws Exception { JavaImplementation type = javaImplementationFactory.createJavaImplementation(); Constructor ctor1 = Foo.class.getConstructor(String.class); @@ -65,6 +71,7 @@ public class ConstructorProcessorTestCase extends TestCase { assertEquals("foo", type.getConstructor().getParameters()[0].getName()); } + @Test public void testNoAnnotation() throws Exception { JavaImplementation type = javaImplementationFactory.createJavaImplementation(); Constructor ctor1 = NoAnnotation.class.getConstructor(); @@ -72,6 +79,7 @@ public class ConstructorProcessorTestCase extends TestCase { assertNull(type.getConstructor()); } + @Test public void testBadAnnotation() throws Exception { JavaImplementation type = javaImplementationFactory.createJavaImplementation(); Constructor ctor1 = BadAnnotation.class.getConstructor(String.class, Foo.class); @@ -83,6 +91,7 @@ public class ConstructorProcessorTestCase extends TestCase { } } + @Test public void testMixedParameters() throws Exception { JavaImplementation type = javaImplementationFactory.createJavaImplementation(); Constructor ctor1 = Mixed.class.getConstructor(String.class, String.class, String.class); @@ -154,6 +163,7 @@ public class ConstructorProcessorTestCase extends TestCase { } } + @Test public void testMultiplicity() throws Exception { JavaImplementation type = javaImplementationFactory.createJavaImplementation(); Constructor ctor1 = Multiple.class.getConstructor(Collection.class, diff --git a/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConstructorPropertyTestCase.java b/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConstructorPropertyTestCase.java index 690869ccb8..c736a96a01 100644 --- a/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConstructorPropertyTestCase.java +++ b/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConstructorPropertyTestCase.java @@ -19,6 +19,10 @@ package org.apache.tuscany.sca.implementation.java.introspect.impl; import static org.apache.tuscany.sca.implementation.java.introspect.impl.ModelHelper.getProperty; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; import java.lang.reflect.Constructor; import java.util.List; @@ -26,6 +30,7 @@ import java.util.List; import org.apache.tuscany.sca.implementation.java.DefaultJavaImplementationFactory; import org.apache.tuscany.sca.implementation.java.JavaImplementation; import org.apache.tuscany.sca.implementation.java.JavaImplementationFactory; +import org.junit.Test; import org.osoa.sca.annotations.Property; /** @@ -35,6 +40,7 @@ public class ConstructorPropertyTestCase extends AbstractProcessorTest { private JavaImplementationFactory javaImplementationFactory = new DefaultJavaImplementationFactory(); + @Test public void testProperty() throws Exception { JavaImplementation type = javaImplementationFactory.createJavaImplementation(); Constructor ctor = Foo.class.getConstructor(String.class); @@ -44,6 +50,7 @@ public class ConstructorPropertyTestCase extends AbstractProcessorTest { assertEquals("myProp", property.getName()); } + @Test public void testTwoPropertiesSameType() throws Exception { JavaImplementation type = javaImplementationFactory.createJavaImplementation(); Constructor ctor = Foo.class.getConstructor(String.class, String.class); @@ -52,6 +59,7 @@ public class ConstructorPropertyTestCase extends AbstractProcessorTest { assertNotNull(getProperty(type, "myProp2")); } + @Test public void testDuplicateProperty() throws Exception { JavaImplementation type = javaImplementationFactory.createJavaImplementation(); Constructor ctor = BadFoo.class.getConstructor(String.class, String.class); @@ -63,6 +71,7 @@ public class ConstructorPropertyTestCase extends AbstractProcessorTest { } } + @Test public void testNoName() throws Exception { JavaImplementation type = javaImplementationFactory.createJavaImplementation(); Constructor ctor = BadFoo.class.getConstructor(String.class); @@ -74,6 +83,7 @@ public class ConstructorPropertyTestCase extends AbstractProcessorTest { } } + @Test public void testNamesOnConstructor() throws Exception { JavaImplementation type = javaImplementationFactory.createJavaImplementation(); Constructor ctor = Foo.class.getConstructor(Integer.class); @@ -81,6 +91,7 @@ public class ConstructorPropertyTestCase extends AbstractProcessorTest { assertNotNull(getProperty(type, "myProp")); } + @Test public void testInvalidNumberOfNames() throws Exception { JavaImplementation type = javaImplementationFactory.createJavaImplementation(); Constructor ctor = BadFoo.class.getConstructor(Integer.class, Integer.class); @@ -92,6 +103,7 @@ public class ConstructorPropertyTestCase extends AbstractProcessorTest { } } + @Test public void testNoMatchingNames() throws Exception { JavaImplementation type = javaImplementationFactory.createJavaImplementation(); Constructor ctor = BadFoo.class.getConstructor(List.class, List.class); diff --git a/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConstructorReferenceTestCase.java b/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConstructorReferenceTestCase.java index 8c10df2146..5676d3e6a2 100644 --- a/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConstructorReferenceTestCase.java +++ b/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConstructorReferenceTestCase.java @@ -19,6 +19,9 @@ package org.apache.tuscany.sca.implementation.java.introspect.impl; import static org.apache.tuscany.sca.implementation.java.introspect.impl.ModelHelper.getReference; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.fail; import java.lang.reflect.Constructor; import java.util.List; @@ -27,6 +30,7 @@ import org.apache.tuscany.sca.assembly.Multiplicity; import org.apache.tuscany.sca.implementation.java.DefaultJavaImplementationFactory; import org.apache.tuscany.sca.implementation.java.JavaImplementation; import org.apache.tuscany.sca.implementation.java.JavaImplementationFactory; +import org.junit.Test; import org.osoa.sca.annotations.Reference; /** @@ -36,6 +40,7 @@ public class ConstructorReferenceTestCase extends AbstractProcessorTest { private JavaImplementationFactory javaImplementationFactory = new DefaultJavaImplementationFactory(); + @Test public void testReference() throws Exception { JavaImplementation type = javaImplementationFactory.createJavaImplementation(); Constructor ctor = Foo.class.getConstructor(String.class); @@ -45,6 +50,7 @@ public class ConstructorReferenceTestCase extends AbstractProcessorTest { assertEquals("myRef", reference.getName()); } + @Test public void testTwoReferencesSameType() throws Exception { JavaImplementation type = javaImplementationFactory.createJavaImplementation(); Constructor ctor = Foo.class.getConstructor(String.class, String.class); @@ -53,6 +59,7 @@ public class ConstructorReferenceTestCase extends AbstractProcessorTest { assertNotNull(getReference(type, "myRef2")); } + @Test public void testDuplicateProperty() throws Exception { JavaImplementation type = javaImplementationFactory.createJavaImplementation(); Constructor ctor = BadFoo.class.getConstructor(String.class, String.class); @@ -64,6 +71,7 @@ public class ConstructorReferenceTestCase extends AbstractProcessorTest { } } + @Test public void testNoName() throws Exception { JavaImplementation type = javaImplementationFactory.createJavaImplementation(); Constructor ctor = NoNameFoo.class.getConstructor(String.class); @@ -71,6 +79,7 @@ public class ConstructorReferenceTestCase extends AbstractProcessorTest { assertNotNull(getReference(type, "_ref0")); } + @Test public void testNamesOnConstructor() throws Exception { JavaImplementation type = javaImplementationFactory.createJavaImplementation(); Constructor ctor = Foo.class.getConstructor(Integer.class); @@ -78,6 +87,7 @@ public class ConstructorReferenceTestCase extends AbstractProcessorTest { assertNotNull(getReference(type, "myRef")); } + @Test public void testInvalidNumberOfNames() throws Exception { JavaImplementation type = javaImplementationFactory.createJavaImplementation(); Constructor ctor = BadFoo.class.getConstructor(Integer.class, Integer.class); @@ -89,6 +99,7 @@ public class ConstructorReferenceTestCase extends AbstractProcessorTest { } } + @Test public void testNoMatchingNames() throws Exception { JavaImplementation type = javaImplementationFactory.createJavaImplementation(); Constructor ctor = BadFoo.class.getConstructor(List.class, List.class); @@ -100,11 +111,6 @@ public class ConstructorReferenceTestCase extends AbstractProcessorTest { } } - @Override - protected void setUp() throws Exception { - super.setUp(); - } - // public void testMultiplicityRequired() throws Exception { // TODO multiplicity // } diff --git a/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConstructorResourceTestCase.java b/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConstructorResourceTestCase.java index b3bfee40e8..e1a0edc0f8 100644 --- a/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConstructorResourceTestCase.java +++ b/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConstructorResourceTestCase.java @@ -18,12 +18,17 @@ */ package org.apache.tuscany.sca.implementation.java.introspect.impl; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.fail; + import java.lang.reflect.Constructor; import java.util.List; import org.apache.tuscany.sca.implementation.java.DefaultJavaImplementationFactory; import org.apache.tuscany.sca.implementation.java.JavaImplementation; import org.apache.tuscany.sca.implementation.java.JavaImplementationFactory; +import org.junit.Test; /** * @version $Rev$ $Date$ @@ -32,6 +37,7 @@ public class ConstructorResourceTestCase extends AbstractProcessorTest { private JavaImplementationFactory javaImplementationFactory = new DefaultJavaImplementationFactory(); + @Test public void testResource() throws Exception { JavaImplementation type = javaImplementationFactory.createJavaImplementation(); Constructor ctor = Foo.class.getConstructor(String.class); @@ -40,6 +46,7 @@ public class ConstructorResourceTestCase extends AbstractProcessorTest { assertFalse(resource.isOptional()); } + @Test public void testTwoResourcesSameType() throws Exception { JavaImplementation type = javaImplementationFactory.createJavaImplementation(); Constructor ctor = Foo.class.getConstructor(String.class, String.class); @@ -48,6 +55,7 @@ public class ConstructorResourceTestCase extends AbstractProcessorTest { assertNotNull(type.getResources().get("myResource2")); } + @Test public void testDuplicateResource() throws Exception { JavaImplementation type = javaImplementationFactory.createJavaImplementation(); Constructor ctor = BadFoo.class.getConstructor(String.class, String.class); @@ -59,6 +67,7 @@ public class ConstructorResourceTestCase extends AbstractProcessorTest { } } + @Test public void testNoName() throws Exception { JavaImplementation type = javaImplementationFactory.createJavaImplementation(); Constructor ctor = @@ -71,6 +80,7 @@ public class ConstructorResourceTestCase extends AbstractProcessorTest { } } + @Test public void testNamesOnConstructor() throws Exception { JavaImplementation type = javaImplementationFactory.createJavaImplementation(); Constructor ctor = Foo.class.getConstructor(Integer.class); @@ -78,6 +88,7 @@ public class ConstructorResourceTestCase extends AbstractProcessorTest { assertNotNull(type.getResources().get("myResource")); } + @Test public void testInvalidNumberOfNames() throws Exception { JavaImplementation type = javaImplementationFactory.createJavaImplementation(); Constructor ctor = @@ -90,6 +101,7 @@ public class ConstructorResourceTestCase extends AbstractProcessorTest { } } + @Test public void testNoMatchingNames() throws Exception { JavaImplementation type = javaImplementationFactory.createJavaImplementation(); Constructor ctor = diff --git a/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ContextProcessorTestCase.java b/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ContextProcessorTestCase.java index f77c9abad9..44c5d71b9e 100644 --- a/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ContextProcessorTestCase.java +++ b/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ContextProcessorTestCase.java @@ -20,6 +20,12 @@ package org.apache.tuscany.sca.implementation.java.introspect.impl; import java.lang.reflect.Field; import java.lang.reflect.Method; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.fail; import junit.framework.TestCase; @@ -27,6 +33,8 @@ import org.apache.tuscany.sca.assembly.DefaultAssemblyFactory; import org.apache.tuscany.sca.implementation.java.DefaultJavaImplementationFactory; import org.apache.tuscany.sca.implementation.java.JavaImplementation; import org.apache.tuscany.sca.implementation.java.JavaImplementationFactory; +import org.junit.Before; +import org.junit.Test; import org.osoa.sca.ComponentContext; import org.osoa.sca.RequestContext; import org.osoa.sca.annotations.ComponentName; @@ -35,11 +43,12 @@ import org.osoa.sca.annotations.Context; /** * @version $Rev$ $Date$ */ -public class ContextProcessorTestCase extends TestCase { +public class ContextProcessorTestCase { private ContextProcessor processor; private ComponentNameProcessor nameProcessor; private JavaImplementationFactory javaImplementationFactory; + @Test public void testComponentContextMethod() throws Exception { Method method = Foo.class.getMethod("setContext", ComponentContext.class); JavaImplementation type = javaImplementationFactory.createJavaImplementation(); @@ -47,6 +56,7 @@ public class ContextProcessorTestCase extends TestCase { assertNotNull(type.getResources().get("context")); } + @Test public void testComponentContextField() throws Exception { Field field = Foo.class.getDeclaredField("context"); JavaImplementation type = javaImplementationFactory.createJavaImplementation(); @@ -54,6 +64,7 @@ public class ContextProcessorTestCase extends TestCase { assertNotNull(type.getResources().get("context")); } + @Test public void testRequestContextMethod() throws Exception { Method method = Foo.class.getMethod("setRequestContext", RequestContext.class); JavaImplementation type = javaImplementationFactory.createJavaImplementation(); @@ -61,6 +72,7 @@ public class ContextProcessorTestCase extends TestCase { assertNotNull(type.getResources().get("requestContext")); } + @Test public void testRequestContextField() throws Exception { Field field = Foo.class.getDeclaredField("requestContext"); JavaImplementation type = javaImplementationFactory.createJavaImplementation(); @@ -68,6 +80,7 @@ public class ContextProcessorTestCase extends TestCase { assertNotNull(type.getResources().get("requestContext")); } + @Test public void testComponentNameMethod() throws Exception { Method method = Foo.class.getMethod("setName", String.class); JavaImplementation type = javaImplementationFactory.createJavaImplementation(); @@ -75,6 +88,7 @@ public class ContextProcessorTestCase extends TestCase { assertNotNull(type.getResources().get("name")); } + @Test public void testComponentNameField() throws Exception { Field field = Foo.class.getDeclaredField("name"); JavaImplementation type = javaImplementationFactory.createJavaImplementation(); @@ -82,6 +96,7 @@ public class ContextProcessorTestCase extends TestCase { assertNotNull(type.getResources().get("name")); } + @Test public void testInvalidParamType() throws Exception { Method method = Foo.class.getMethod("setContext", String.class); JavaImplementation type = javaImplementationFactory.createJavaImplementation(); @@ -93,6 +108,7 @@ public class ContextProcessorTestCase extends TestCase { } } + @Test public void testInvalidParamTypeField() throws Exception { Field field = Foo.class.getDeclaredField("badContext"); JavaImplementation type = javaImplementationFactory.createJavaImplementation(); @@ -105,6 +121,7 @@ public class ContextProcessorTestCase extends TestCase { } + @Test public void testInvalidParamNum() throws Exception { Method method = Foo.class.getMethod("setContext", ComponentContext.class, String.class); JavaImplementation type = javaImplementationFactory.createJavaImplementation(); @@ -116,6 +133,7 @@ public class ContextProcessorTestCase extends TestCase { } } + @Test public void testInvalidNoParams() throws Exception { Method method = Foo.class.getMethod("setContext"); JavaImplementation type = javaImplementationFactory.createJavaImplementation(); @@ -127,6 +145,7 @@ public class ContextProcessorTestCase extends TestCase { } } + @Test public void testNoContext() throws Exception { Method method = Foo.class.getMethod("noContext", ComponentContext.class); JavaImplementation type = javaImplementationFactory.createJavaImplementation(); @@ -134,6 +153,7 @@ public class ContextProcessorTestCase extends TestCase { assertEquals(0, type.getResources().size()); } + @Test public void testNoContextField() throws Exception { Field field = Foo.class.getDeclaredField("noContext"); JavaImplementation type = javaImplementationFactory.createJavaImplementation(); @@ -141,9 +161,8 @@ public class ContextProcessorTestCase extends TestCase { assertEquals(0, type.getResources().size()); } - @Override - protected void setUp() throws Exception { - super.setUp(); + @Before + public void setUp() throws Exception { javaImplementationFactory = new DefaultJavaImplementationFactory(); processor = new ContextProcessor(new DefaultAssemblyFactory()); nameProcessor = new ComponentNameProcessor(new DefaultAssemblyFactory()); diff --git a/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConversationIDProcessorTestCase.java b/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConversationIDProcessorTestCase.java index c6b2626e9c..6516da3c20 100644 --- a/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConversationIDProcessorTestCase.java +++ b/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConversationIDProcessorTestCase.java @@ -18,15 +18,17 @@ */ package org.apache.tuscany.sca.implementation.java.introspect.impl; +import static org.junit.Assert.assertNotNull; + import java.lang.reflect.Field; import java.lang.reflect.Method; -import junit.framework.TestCase; - import org.apache.tuscany.sca.assembly.DefaultAssemblyFactory; import org.apache.tuscany.sca.implementation.java.DefaultJavaImplementationFactory; import org.apache.tuscany.sca.implementation.java.JavaImplementation; import org.apache.tuscany.sca.implementation.java.JavaImplementationFactory; +import org.junit.Before; +import org.junit.Test; import org.osoa.sca.annotations.ConversationID; /** @@ -34,10 +36,11 @@ import org.osoa.sca.annotations.ConversationID; * * @version $Rev$ $Date$ */ -public class ConversationIDProcessorTestCase extends TestCase { +public class ConversationIDProcessorTestCase { private ConversationIDProcessor processor; private JavaImplementationFactory javaImplementationFactory; + @Test public void testConversationIDMethod() throws Exception { Method method = Foo.class.getMethod("setConversationID", String.class); JavaImplementation type = javaImplementationFactory.createJavaImplementation(); @@ -45,6 +48,7 @@ public class ConversationIDProcessorTestCase extends TestCase { assertNotNull(type.getResources().get("conversationID")); } + @Test public void testConversationIDField() throws Exception { Field field = Foo.class.getDeclaredField("cid"); JavaImplementation type = javaImplementationFactory.createJavaImplementation(); @@ -52,6 +56,7 @@ public class ConversationIDProcessorTestCase extends TestCase { assertNotNull(type.getResources().get("cid")); } + @Test public void testConversationIDMethodNotString() throws Exception { Method method = Foo.class.getMethod("setConversationID", Long.class); JavaImplementation type = javaImplementationFactory.createJavaImplementation(); @@ -59,6 +64,7 @@ public class ConversationIDProcessorTestCase extends TestCase { assertNotNull(type.getResources().get("conversationID")); } + @Test public void testConversationIDFieldNotString() throws Exception { Field field = Foo.class.getDeclaredField("longCID"); JavaImplementation type = javaImplementationFactory.createJavaImplementation(); @@ -66,9 +72,8 @@ public class ConversationIDProcessorTestCase extends TestCase { assertNotNull(type.getResources().get("longCID")); } - @Override - protected void setUp() throws Exception { - super.setUp(); + @Before + public void setUp() throws Exception { javaImplementationFactory = new DefaultJavaImplementationFactory(); processor = new ConversationIDProcessor(new DefaultAssemblyFactory()); } diff --git a/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConversationProcessorTestCase.java b/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConversationProcessorTestCase.java index a682f8b2f0..eceb3fc6ae 100644 --- a/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConversationProcessorTestCase.java +++ b/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConversationProcessorTestCase.java @@ -18,15 +18,17 @@ */ package org.apache.tuscany.sca.implementation.java.introspect.impl; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + import java.lang.reflect.Field; import java.lang.reflect.Method; -import junit.framework.TestCase; - import org.apache.tuscany.sca.assembly.DefaultAssemblyFactory; import org.apache.tuscany.sca.implementation.java.DefaultJavaImplementationFactory; import org.apache.tuscany.sca.implementation.java.JavaImplementation; import org.apache.tuscany.sca.implementation.java.JavaImplementationFactory; +import org.junit.Test; import org.osoa.sca.annotations.ConversationAttributes; import org.osoa.sca.annotations.ConversationID; import org.osoa.sca.annotations.Scope; @@ -34,10 +36,11 @@ import org.osoa.sca.annotations.Scope; /** * @version $Rev$ $Date$ */ -public class ConversationProcessorTestCase extends TestCase { +public class ConversationProcessorTestCase { private ConversationProcessor processor = new ConversationProcessor(new DefaultAssemblyFactory()); private JavaImplementationFactory javaImplementationFactory = new DefaultJavaImplementationFactory(); + @Test public void testMaxIdleTime() throws Exception { JavaImplementation type = javaImplementationFactory.createJavaImplementation(); processor.visitClass(FooMaxIdle.class, type); @@ -45,6 +48,7 @@ public class ConversationProcessorTestCase extends TestCase { assertEquals(-1, type.getMaxAge()); } + @Test public void testMaxAge() throws Exception { JavaImplementation type = javaImplementationFactory.createJavaImplementation(); processor.visitClass(FooMaxAge.class, type); @@ -52,6 +56,7 @@ public class ConversationProcessorTestCase extends TestCase { assertEquals(-1, type.getMaxIdleTime()); } + @Test public void testImplicitScope() throws Exception { JavaImplementation type = javaImplementationFactory.createJavaImplementation(); processor.visitClass(ImplicitFooScope.class, type); @@ -70,6 +75,7 @@ public class ConversationProcessorTestCase extends TestCase { } */ + @Test public void testBadFooBoth() throws Exception { JavaImplementation type = javaImplementationFactory.createJavaImplementation(); processor.visitClass(BadFooBoth.class, type); @@ -77,6 +83,7 @@ public class ConversationProcessorTestCase extends TestCase { assertEquals(10000L, type.getMaxIdleTime()); } + @Test public void testJustConversation() throws Exception { // TODO do we want these semantics JavaImplementation type = javaImplementationFactory.createJavaImplementation(); @@ -86,6 +93,7 @@ public class ConversationProcessorTestCase extends TestCase { assertEquals(-1, type.getMaxIdleTime()); } + @Test public void testSetConversationIDField() throws Exception { JavaImplementation type = javaImplementationFactory.createJavaImplementation(); Field field = FooWithConversationIDField.class.getDeclaredField("conversationID"); @@ -94,6 +102,7 @@ public class ConversationProcessorTestCase extends TestCase { assertEquals(field, type.getConversationIDMembers().get(0)); } + @Test public void testSetConversationIDMethod() throws Exception { JavaImplementation type = javaImplementationFactory.createJavaImplementation(); Method method = FooWithConversationIDMethod.class.getDeclaredMethods()[0]; diff --git a/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConvertTimeMillisTestCase.java b/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConvertTimeMillisTestCase.java index aa2671071c..728c6c89b8 100644 --- a/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConvertTimeMillisTestCase.java +++ b/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConvertTimeMillisTestCase.java @@ -18,16 +18,20 @@ */ package org.apache.tuscany.sca.implementation.java.introspect.impl; -import junit.framework.TestCase; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; import org.apache.tuscany.sca.assembly.DefaultAssemblyFactory; +import org.junit.Before; +import org.junit.Test; /** * @version $Rev$ $Date$ */ -public class ConvertTimeMillisTestCase extends TestCase { +public class ConvertTimeMillisTestCase { private MockProcessor registy; + @Test public void testConvertSeconds() throws Exception { assertEquals(10000L, registy.convertTimeMillis("10 seconds")); assertEquals(10000L, registy.convertTimeMillis("10 SECONDS")); @@ -39,6 +43,7 @@ public class ConvertTimeMillisTestCase extends TestCase { } } + @Test public void testConvertMinutes() throws Exception { assertEquals(600000L, registy.convertTimeMillis("10 minutes")); assertEquals(600000L, registy.convertTimeMillis("10 MINUTES")); @@ -50,6 +55,7 @@ public class ConvertTimeMillisTestCase extends TestCase { } } + @Test public void testConvertHours() throws Exception { assertEquals(36000000L, registy.convertTimeMillis("10 hours")); assertEquals(36000000L, registy.convertTimeMillis("10 HOURS")); @@ -61,6 +67,7 @@ public class ConvertTimeMillisTestCase extends TestCase { } } + @Test public void testConvertDays() throws Exception { assertEquals(864000000L, registy.convertTimeMillis("10 days")); assertEquals(864000000L, registy.convertTimeMillis("10 DAYS")); @@ -72,6 +79,7 @@ public class ConvertTimeMillisTestCase extends TestCase { } } + @Test public void testConvertYears() throws Exception { assertEquals(315569260000L, registy.convertTimeMillis("10 years")); assertEquals(315569260000L, registy.convertTimeMillis("10 YEARS")); @@ -83,11 +91,13 @@ public class ConvertTimeMillisTestCase extends TestCase { } } + @Test public void testConvertDefault() throws Exception { assertEquals(10000L, registy.convertTimeMillis("10 ")); assertEquals(10000L, registy.convertTimeMillis("10")); } + @Test public void testInvalid() throws Exception { try { registy.convertTimeMillis("foo"); @@ -97,9 +107,8 @@ public class ConvertTimeMillisTestCase extends TestCase { } } - @Override - protected void setUp() throws Exception { - super.setUp(); + @Before + public void setUp() throws Exception { registy = new MockProcessor(); } diff --git a/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DestroyProcessorTestCase.java b/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DestroyProcessorTestCase.java index ffc67325fa..c46af80cec 100644 --- a/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DestroyProcessorTestCase.java +++ b/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DestroyProcessorTestCase.java @@ -18,25 +18,28 @@ */ package org.apache.tuscany.sca.implementation.java.introspect.impl; -import java.lang.reflect.Method; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.fail; -import junit.framework.TestCase; +import java.lang.reflect.Method; import org.apache.tuscany.sca.assembly.AssemblyFactory; import org.apache.tuscany.sca.assembly.DefaultAssemblyFactory; import org.apache.tuscany.sca.implementation.java.DefaultJavaImplementationFactory; import org.apache.tuscany.sca.implementation.java.JavaImplementation; import org.apache.tuscany.sca.implementation.java.JavaImplementationFactory; +import org.junit.Test; import org.osoa.sca.annotations.Destroy; /** * @version $Rev$ $Date$ */ -public class DestroyProcessorTestCase extends TestCase { +public class DestroyProcessorTestCase { private AssemblyFactory assemblyFactory = new DefaultAssemblyFactory(); private JavaImplementationFactory javaImplementationFactory = new DefaultJavaImplementationFactory(); + @Test public void testDestroy() throws Exception { DestroyProcessor processor = new DestroyProcessor(assemblyFactory); JavaImplementation type = javaImplementationFactory.createJavaImplementation(); @@ -45,6 +48,7 @@ public class DestroyProcessorTestCase extends TestCase { assertNotNull(type.getDestroyMethod()); } + @Test public void testBadDestroy() throws Exception { DestroyProcessor processor = new DestroyProcessor(assemblyFactory); JavaImplementation type = javaImplementationFactory.createJavaImplementation(); @@ -57,6 +61,7 @@ public class DestroyProcessorTestCase extends TestCase { } } + @Test public void testTwoDestroy() throws Exception { DestroyProcessor processor = new DestroyProcessor(assemblyFactory); JavaImplementation type = javaImplementationFactory.createJavaImplementation(); @@ -71,6 +76,7 @@ public class DestroyProcessorTestCase extends TestCase { } } + @Test public void testProtectedDestroy() throws Exception { DestroyProcessor processor = new DestroyProcessor(assemblyFactory); JavaImplementation type = javaImplementationFactory.createJavaImplementation(); @@ -83,6 +89,7 @@ public class DestroyProcessorTestCase extends TestCase { } } + @Test public void testPrivateDestroy() throws Exception { DestroyProcessor processor = new DestroyProcessor(assemblyFactory); JavaImplementation type = javaImplementationFactory.createJavaImplementation(); diff --git a/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/EagerInitProcessorTestCase.java b/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/EagerInitProcessorTestCase.java index 09bcc7ab6c..6a27d1c957 100644 --- a/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/EagerInitProcessorTestCase.java +++ b/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/EagerInitProcessorTestCase.java @@ -18,30 +18,31 @@ */ package org.apache.tuscany.sca.implementation.java.introspect.impl; -import junit.framework.TestCase; - import org.apache.tuscany.sca.assembly.AssemblyFactory; import org.apache.tuscany.sca.assembly.DefaultAssemblyFactory; import org.apache.tuscany.sca.implementation.java.DefaultJavaImplementationFactory; import org.apache.tuscany.sca.implementation.java.IntrospectionException; import org.apache.tuscany.sca.implementation.java.JavaImplementation; import org.apache.tuscany.sca.implementation.java.JavaImplementationFactory; +import org.junit.Test; import org.osoa.sca.annotations.EagerInit; /** * @version $Rev$ $Date$ */ -public class EagerInitProcessorTestCase extends TestCase { +public class EagerInitProcessorTestCase { private AssemblyFactory assemblyFactory = new DefaultAssemblyFactory(); private JavaImplementationFactory javaImplementationFactory = new DefaultJavaImplementationFactory(); + @Test public void testNoLevel() throws IntrospectionException { EagerInitProcessor processor = new EagerInitProcessor(assemblyFactory); JavaImplementation type = javaImplementationFactory.createJavaImplementation(); processor.visitClass(Level.class, type); } + @Test public void testSubclass() throws IntrospectionException { EagerInitProcessor processor = new EagerInitProcessor(assemblyFactory); JavaImplementation type = javaImplementationFactory.createJavaImplementation(); diff --git a/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/HeuristicAndPropertyTestCase.java b/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/HeuristicAndPropertyTestCase.java index 58ff81a06c..90f70d6590 100644 --- a/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/HeuristicAndPropertyTestCase.java +++ b/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/HeuristicAndPropertyTestCase.java @@ -18,9 +18,9 @@ */ package org.apache.tuscany.sca.implementation.java.introspect.impl; -import java.lang.reflect.Constructor; +import static org.junit.Assert.assertEquals; -import junit.framework.TestCase; +import java.lang.reflect.Constructor; import org.apache.tuscany.sca.assembly.AssemblyFactory; import org.apache.tuscany.sca.assembly.DefaultAssemblyFactory; @@ -29,12 +29,14 @@ import org.apache.tuscany.sca.implementation.java.JavaConstructorImpl; import org.apache.tuscany.sca.implementation.java.JavaImplementation; import org.apache.tuscany.sca.implementation.java.JavaImplementationFactory; import org.apache.tuscany.sca.interfacedef.java.DefaultJavaInterfaceFactory; +import org.junit.Before; +import org.junit.Test; import org.osoa.sca.annotations.Property; /** * @version $Rev$ $Date$ */ -public class HeuristicAndPropertyTestCase extends TestCase { +public class HeuristicAndPropertyTestCase { private PropertyProcessor propertyProcessor; private HeuristicPojoProcessor heuristicProcessor; @@ -45,6 +47,7 @@ public class HeuristicAndPropertyTestCase extends TestCase { * Verifies the property and heuristic processors don't collide */ @SuppressWarnings("unchecked") + @Test public void testPropertyProcessorWithHeuristicProcessor() throws Exception { JavaImplementation type = javaImplementationFactory.createJavaImplementation(); Constructor ctor = Foo.class.getConstructor(String.class); @@ -55,9 +58,8 @@ public class HeuristicAndPropertyTestCase extends TestCase { assertEquals("foo", type.getProperties().get(0).getName()); } - @Override - protected void setUp() throws Exception { - super.setUp(); + @Before + public void setUp() throws Exception { propertyProcessor = new PropertyProcessor(assemblyFactory); heuristicProcessor = new HeuristicPojoProcessor(assemblyFactory, new DefaultJavaInterfaceFactory()); } diff --git a/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/HeuristicConstructorTestCase.java b/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/HeuristicConstructorTestCase.java index d837be8806..277fad699f 100644 --- a/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/HeuristicConstructorTestCase.java +++ b/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/HeuristicConstructorTestCase.java @@ -19,6 +19,10 @@ package org.apache.tuscany.sca.implementation.java.introspect.impl; import static org.apache.tuscany.sca.implementation.java.introspect.impl.ModelHelper.getProperty; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; import java.lang.reflect.Constructor; @@ -31,6 +35,7 @@ import org.apache.tuscany.sca.implementation.java.JavaImplementation; import org.apache.tuscany.sca.implementation.java.JavaImplementationFactory; import org.apache.tuscany.sca.interfacedef.java.DefaultJavaInterfaceFactory; import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory; +import org.junit.Test; import org.osoa.sca.annotations.Property; import org.osoa.sca.annotations.Reference; import org.osoa.sca.annotations.Remotable; @@ -62,6 +67,7 @@ public class HeuristicConstructorTestCase extends AbstractProcessorTest { /** * Verifies a single constructor is chosen with a parameter as the type */ + @Test public void testSingleConstructorWithParam() throws Exception { JavaImplementation type = javaImplementationFactory.createJavaImplementation(); org.apache.tuscany.sca.assembly.Property prop = factory.createProperty(); @@ -78,6 +84,7 @@ public class HeuristicConstructorTestCase extends AbstractProcessorTest { /** * Verifies a single constructor is chosen with a reference as the type */ + @Test public void testSingleConstructorWithRef() throws Exception { JavaImplementation type = javaImplementationFactory.createJavaImplementation(); org.apache.tuscany.sca.assembly.Reference ref = factory.createReference(); @@ -93,6 +100,7 @@ public class HeuristicConstructorTestCase extends AbstractProcessorTest { * Verifies a single constructor is chosen with a property and a reference * as the type */ + @Test public void testSingleConstructorWithPropRef() throws Exception { JavaImplementation type = javaImplementationFactory.createJavaImplementation(); @@ -111,18 +119,21 @@ public class HeuristicConstructorTestCase extends AbstractProcessorTest { assertEquals(2, type.getConstructor().getParameters().length); } + @Test public void testSingleConstructorResolvableParam() throws Exception { JavaImplementation type = javaImplementationFactory.createJavaImplementation(); visitEnd(Foo5.class, type); assertEquals(String.class, type.getPropertyMembers().get("string").getType()); } + @Test public void testSingleConstructorResolvableRef() throws Exception { JavaImplementation type = javaImplementationFactory.createJavaImplementation(); visitEnd(Foo6.class, type); assertTrue(ModelHelper.matches(ModelHelper.getReference(type, "ref"), Ref.class)); } + @Test public void testSingleConstructorAmbiguousRef() throws Exception { JavaImplementation type = javaImplementationFactory.createJavaImplementation(); org.apache.tuscany.sca.assembly.Reference ref = ModelHelper.createReference(factory, javaFactory, "ref", Foo1.class); @@ -139,24 +150,28 @@ public class HeuristicConstructorTestCase extends AbstractProcessorTest { } } + @Test public void testConstructorPropertyAnnotatedParamsOnly() throws Exception { JavaImplementation type = javaImplementationFactory.createJavaImplementation(); visitEnd(Foo7.class, type); assertNotNull(getProperty(type, "myProp")); } + @Test public void testConstructorReferenceAnnotatedParamsOnly() throws Exception { JavaImplementation type = javaImplementationFactory.createJavaImplementation(); visitEnd(Foo8.class, type); assertNotNull(ModelHelper.getReference(type, "myRef")); } + @Test public void testDefaultConstructor() throws Exception { JavaImplementation type = javaImplementationFactory.createJavaImplementation(); visitEnd(Foo3.class, type); assertNotNull(type.getConstructor().getConstructor()); } + @Test public void testSameTypesButAnnotated() throws Exception { JavaImplementation type = javaImplementationFactory.createJavaImplementation(); visitEnd(Foo12.class, type); @@ -168,6 +183,7 @@ public class HeuristicConstructorTestCase extends AbstractProcessorTest { /** * Verifies processing executes with additional extension annotations */ + @Test public void testRandomAnnotation() throws Exception { JavaImplementation type = javaImplementationFactory.createJavaImplementation(); visitEnd(Foo11.class, type); @@ -175,6 +191,7 @@ public class HeuristicConstructorTestCase extends AbstractProcessorTest { assertNotNull(getProperty(type, "prop1")); } + @Test public void testPrivateConstructor() throws Exception { JavaImplementation type = javaImplementationFactory.createJavaImplementation(); try { @@ -185,6 +202,7 @@ public class HeuristicConstructorTestCase extends AbstractProcessorTest { } } + @Test public void testMultipleConstructors() throws Exception { // throw new UnsupportedOperationException("Finish heuristic multiple // constructors - Foo10"); diff --git a/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/HeuristicPojoProcessorTestCase.java b/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/HeuristicPojoProcessorTestCase.java index fbc971a3e2..f7cee88a3e 100644 --- a/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/HeuristicPojoProcessorTestCase.java +++ b/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/HeuristicPojoProcessorTestCase.java @@ -18,6 +18,10 @@ */ package org.apache.tuscany.sca.implementation.java.introspect.impl; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + import java.lang.reflect.Constructor; import java.util.Collection; import java.util.List; @@ -34,6 +38,7 @@ import org.apache.tuscany.sca.implementation.java.JavaImplementation; import org.apache.tuscany.sca.implementation.java.JavaImplementationFactory; import org.apache.tuscany.sca.interfacedef.java.DefaultJavaInterfaceFactory; import org.apache.tuscany.sca.interfacedef.util.JavaXMLMapper; +import org.junit.Test; import org.osoa.sca.annotations.Property; import org.osoa.sca.annotations.Reference; import org.osoa.sca.annotations.Remotable; @@ -66,6 +71,7 @@ public class HeuristicPojoProcessorTestCase extends AbstractProcessorTest { * Verifies a single service interface is computed when only one interface * is implemented */ + @Test public void testSingleInterface() throws Exception { JavaImplementation type = javaImplementationFactory.createJavaImplementation(); Constructor ctor = SingleInterfaceImpl.class.getConstructor(); @@ -81,6 +87,7 @@ public class HeuristicPojoProcessorTestCase extends AbstractProcessorTest { /** * Verifies property and reference setters are computed */ + @Test public void testPropertyReference() throws Exception { JavaImplementation type = javaImplementationFactory.createJavaImplementation(); Constructor ctor = SingleInterfaceWithPropertyReferenceImpl.class @@ -102,6 +109,7 @@ public class HeuristicPojoProcessorTestCase extends AbstractProcessorTest { * Verifies that a property setter is not introspected if an analogous * operation is in the service interface */ + @Test public void testPropertySetterInInterface() throws Exception { JavaImplementation type = javaImplementationFactory.createJavaImplementation(); Constructor ctor = SingleInterfaceImpl.class.getConstructor(); @@ -114,6 +122,7 @@ public class HeuristicPojoProcessorTestCase extends AbstractProcessorTest { * Verifies that a reference setter is not introspected if an analogous * operation is in the service interface */ + @Test public void testReferenceSetterInInterface() throws Exception { JavaImplementation type = javaImplementationFactory.createJavaImplementation(); Constructor ctor = RefInterfaceImpl.class.getConstructor(); @@ -126,6 +135,7 @@ public class HeuristicPojoProcessorTestCase extends AbstractProcessorTest { * Verifies collection generic types or array types are introspected as * references according to specification rules */ + @Test public void testReferenceCollectionType() throws Exception { JavaImplementation type = javaImplementationFactory.createJavaImplementation(); Constructor ctor = ReferenceCollectionImpl.class.getConstructor(); @@ -139,6 +149,7 @@ public class HeuristicPojoProcessorTestCase extends AbstractProcessorTest { * Verifies collection generic types or array types are introspected as * properties according to specification rules */ + @Test public void testPropertyCollectionType() throws Exception { JavaImplementation type = javaImplementationFactory.createJavaImplementation(); Constructor ctor = PropertyCollectionImpl.class.getConstructor(); @@ -153,6 +164,7 @@ public class HeuristicPojoProcessorTestCase extends AbstractProcessorTest { * * @Remotable */ + @Test public void testRemotableRef() throws Exception { JavaImplementation type = javaImplementationFactory.createJavaImplementation(); Constructor ctor = RemotableRefImpl.class.getConstructor(); @@ -162,6 +174,7 @@ public class HeuristicPojoProcessorTestCase extends AbstractProcessorTest { assertEquals(0, type.getProperties().size()); } + @Test public void testParentInterface() throws IntrospectionException, NoSuchMethodException { JavaImplementation type = javaImplementationFactory.createJavaImplementation(); Constructor ctor = Child.class.getConstructor(); @@ -174,6 +187,7 @@ public class HeuristicPojoProcessorTestCase extends AbstractProcessorTest { * Verifies a service interface is calculated when only props and refs are * given */ + @Test public void testExcludedPropertyAndReference() throws Exception { JavaImplementation type = javaImplementationFactory.createJavaImplementation(); org.apache.tuscany.sca.assembly.Reference ref = factory.createReference(); @@ -196,6 +210,7 @@ public class HeuristicPojoProcessorTestCase extends AbstractProcessorTest { assertEquals(1, type.getServices().size()); } + @Test public void testProtectedRemotableRefField() throws IntrospectionException, NoSuchMethodException { JavaImplementation type = javaImplementationFactory.createJavaImplementation(); Constructor ctor = ProtectedRemotableRefFieldImpl.class.getConstructor(); @@ -204,6 +219,7 @@ public class HeuristicPojoProcessorTestCase extends AbstractProcessorTest { assertNotNull(ModelHelper.getReference(type, "otherRef")); } + @Test public void testProtectedRemotableRefMethod() throws IntrospectionException, NoSuchMethodException { JavaImplementation type = javaImplementationFactory.createJavaImplementation(); Constructor ctor = ProtectedRemotableRefMethodImpl.class.getConstructor(); @@ -212,6 +228,7 @@ public class HeuristicPojoProcessorTestCase extends AbstractProcessorTest { assertNotNull(ModelHelper.getReference(type, "otherRef")); } + @Test public void testSetDataTypes() throws Exception { JavaImplementation type = javaImplementationFactory.createJavaImplementation(); Constructor ctor = PropertyIntTypeOnConstructor.class.getConstructor(); @@ -228,6 +245,7 @@ public class HeuristicPojoProcessorTestCase extends AbstractProcessorTest { * is corrected as per the errata. A notable difference is that the interfaces annotated with @Service * no longer result in references. */ + @Test public void testUpdatedRule() throws Exception { JavaImplementation type = javaImplementationFactory.createJavaImplementation(); visitEnd(SomeServiceImpl.class, type); @@ -273,6 +291,7 @@ public class HeuristicPojoProcessorTestCase extends AbstractProcessorTest { * Interfaces with "@WebService" annotation implemented by the class should result * in a Service in the same manner as an "@Remotable" annotation would. */ + @Test public void testInterfaceWithWebServiceAnnotation() throws Exception{ JavaImplementation type = javaImplementationFactory.createJavaImplementation(); visitEnd(SomeWebServiceImpl.class, type); diff --git a/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/HeutisticExtensibleConstructorTestCase.java b/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/HeutisticExtensibleConstructorTestCase.java index 315c99c06c..e678c87349 100644 --- a/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/HeutisticExtensibleConstructorTestCase.java +++ b/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/HeutisticExtensibleConstructorTestCase.java @@ -18,6 +18,8 @@ */ package org.apache.tuscany.sca.implementation.java.introspect.impl; +import static org.junit.Assert.assertEquals; + import java.lang.reflect.Constructor; import org.apache.tuscany.sca.assembly.DefaultAssemblyFactory; @@ -29,6 +31,7 @@ import org.apache.tuscany.sca.implementation.java.JavaElementImpl; import org.apache.tuscany.sca.implementation.java.JavaImplementation; import org.apache.tuscany.sca.implementation.java.JavaImplementationFactory; import org.apache.tuscany.sca.interfacedef.java.DefaultJavaInterfaceFactory; +import org.junit.Test; /** * Verifies constructors that have extensible annotation types, i.e. that have @@ -58,6 +61,7 @@ public class HeutisticExtensibleConstructorTestCase extends AbstractProcessorTes * Verifies heuristic processing can be called prior to an extension * annotation processors being called. */ + @Test public void testBarAnnotationProcessedFirst() throws Exception { JavaImplementation type = javaImplementationFactory.createJavaImplementation(); Constructor ctor = Foo.class.getConstructor(String.class, String.class); @@ -84,6 +88,7 @@ public class HeutisticExtensibleConstructorTestCase extends AbstractProcessorTes * @Bar * @throws Exception */ + @Test public void testBarAnnotationProcessedLast() throws Exception { JavaImplementation type = javaImplementationFactory.createJavaImplementation(); visitEnd(Foo.class, type); @@ -105,6 +110,7 @@ public class HeutisticExtensibleConstructorTestCase extends AbstractProcessorTes * position. Specifically, verifies that the heuristic processor updates * injection names and preserves their ordering. */ + @Test public void testBarAnnotationProcessedFirstInMiddle() throws Exception { JavaImplementation type = javaImplementationFactory.createJavaImplementation(); Constructor ctor = Foo2.class.getConstructor(String.class, String.class, String.class); diff --git a/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InitProcessorTestCase.java b/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InitProcessorTestCase.java index 70c615ca24..49b337ff53 100644 --- a/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InitProcessorTestCase.java +++ b/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InitProcessorTestCase.java @@ -19,6 +19,12 @@ package org.apache.tuscany.sca.implementation.java.introspect.impl; import java.lang.reflect.Method; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.fail; import junit.framework.TestCase; @@ -26,12 +32,13 @@ import org.apache.tuscany.sca.assembly.DefaultAssemblyFactory; import org.apache.tuscany.sca.implementation.java.DefaultJavaImplementationFactory; import org.apache.tuscany.sca.implementation.java.JavaImplementation; import org.apache.tuscany.sca.implementation.java.JavaImplementationFactory; +import org.junit.Test; import org.osoa.sca.annotations.Init; /** * @version $Rev$ $Date$ */ -public class InitProcessorTestCase extends TestCase { +public class InitProcessorTestCase { private JavaImplementationFactory javaImplementationFactory; @@ -39,6 +46,7 @@ public class InitProcessorTestCase extends TestCase { javaImplementationFactory = new DefaultJavaImplementationFactory(); } + @Test public void testInit() throws Exception { InitProcessor processor = new InitProcessor(new DefaultAssemblyFactory()); JavaImplementation type = javaImplementationFactory.createJavaImplementation(); @@ -47,6 +55,7 @@ public class InitProcessorTestCase extends TestCase { assertNotNull(type.getInitMethod()); } + @Test public void testBadInit() throws Exception { InitProcessor processor = new InitProcessor(new DefaultAssemblyFactory()); JavaImplementation type = javaImplementationFactory.createJavaImplementation(); @@ -59,6 +68,7 @@ public class InitProcessorTestCase extends TestCase { } } + @Test public void testTwoInit() throws Exception { InitProcessor processor = new InitProcessor(new DefaultAssemblyFactory()); JavaImplementation type = javaImplementationFactory.createJavaImplementation(); @@ -73,6 +83,7 @@ public class InitProcessorTestCase extends TestCase { } } + @Test public void testProtectedInit() throws Exception { InitProcessor processor = new InitProcessor(new DefaultAssemblyFactory()); JavaImplementation type = javaImplementationFactory.createJavaImplementation(); @@ -85,6 +96,7 @@ public class InitProcessorTestCase extends TestCase { } } + @Test public void testPrivateInit() throws Exception { InitProcessor processor = new InitProcessor(new DefaultAssemblyFactory()); JavaImplementation type = javaImplementationFactory.createJavaImplementation(); @@ -97,6 +109,7 @@ public class InitProcessorTestCase extends TestCase { } } + @Test public void testBadInit2() throws Exception { InitProcessor processor = new InitProcessor(new DefaultAssemblyFactory()); JavaImplementation type = javaImplementationFactory.createJavaImplementation(); diff --git a/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/PolicyProcessorTestCase.java b/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/PolicyProcessorTestCase.java index 4a625982b0..1f3722e129 100644 --- a/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/PolicyProcessorTestCase.java +++ b/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/PolicyProcessorTestCase.java @@ -18,13 +18,14 @@ */ package org.apache.tuscany.sca.implementation.java.introspect.impl; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + import java.lang.reflect.Method; import java.util.HashMap; import java.util.List; import java.util.Map; -import junit.framework.TestCase; - import org.apache.tuscany.sca.assembly.ConfiguredOperation; import org.apache.tuscany.sca.assembly.DefaultAssemblyFactory; import org.apache.tuscany.sca.assembly.OperationsConfigurator; @@ -37,13 +38,15 @@ import org.apache.tuscany.sca.interfacedef.java.impl.PolicyJavaInterfaceVisitor; import org.apache.tuscany.sca.policy.DefaultPolicyFactory; import org.apache.tuscany.sca.policy.Intent; import org.apache.tuscany.sca.policy.PolicySetAttachPoint; +import org.junit.Before; +import org.junit.Test; import org.osoa.sca.annotations.Requires; import org.osoa.sca.annotations.Service; /** * @version $Rev$ $Date$ */ -public class PolicyProcessorTestCase extends TestCase { +public class PolicyProcessorTestCase { private ServiceProcessor serviceProcessor; private PolicyProcessor policyProcessor; private PolicyJavaInterfaceVisitor visitor; @@ -87,6 +90,7 @@ public class PolicyProcessorTestCase extends TestCase { verifyIntents(Service5.class, type); } + @Test public void testSingleInterfaceWithIntentsOnServiceAndInterfaceAtImplAndInertfaceAndMethodLevel() throws Exception { serviceProcessor.visitClass(Service6.class, type); visitor.visitInterface((JavaInterface)type.getServices().get(0).getInterfaceContract().getInterface()); @@ -231,9 +235,8 @@ public class PolicyProcessorTestCase extends TestCase { } } - @Override - protected void setUp() throws Exception { - super.setUp(); + @Before + public void setUp() throws Exception { serviceProcessor = new ServiceProcessor(new DefaultAssemblyFactory(), new DefaultJavaInterfaceFactory()); policyProcessor = new PolicyProcessor(new DefaultAssemblyFactory(), new DefaultPolicyFactory()); visitor = new PolicyJavaInterfaceVisitor(new DefaultPolicyFactory()); diff --git a/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/PropertyProcessorTestCase.java b/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/PropertyProcessorTestCase.java index ad8edd83ea..8afeb710c5 100644 --- a/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/PropertyProcessorTestCase.java +++ b/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/PropertyProcessorTestCase.java @@ -19,33 +19,39 @@ package org.apache.tuscany.sca.implementation.java.introspect.impl; import static org.apache.tuscany.sca.implementation.java.introspect.impl.ModelHelper.getProperty; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertSame; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; import java.util.Collection; import java.util.List; -import junit.framework.TestCase; - import org.apache.tuscany.sca.assembly.DefaultAssemblyFactory; import org.apache.tuscany.sca.implementation.java.DefaultJavaImplementationFactory; import org.apache.tuscany.sca.implementation.java.JavaElementImpl; import org.apache.tuscany.sca.implementation.java.JavaImplementation; import org.apache.tuscany.sca.implementation.java.JavaImplementationFactory; import org.apache.tuscany.sca.implementation.java.introspect.JavaIntrospectionHelper; +import org.junit.Before; +import org.junit.Test; import org.osoa.sca.annotations.Property; /** * @version $Rev$ $Date$ */ -public class PropertyProcessorTestCase extends TestCase { +public class PropertyProcessorTestCase { JavaImplementation type; PropertyProcessor processor; + @Test public void testMethodAnnotation() throws Exception { processor.visitMethod(Foo.class.getMethod("setFoo", String.class), type); assertNotNull(getProperty(type, "foo")); } + @Test public void testMethodRequired() throws Exception { processor.visitMethod(Foo.class.getMethod("setFooRequired", String.class), type); org.apache.tuscany.sca.assembly.Property prop = getProperty(type, "fooRequired"); @@ -53,16 +59,19 @@ public class PropertyProcessorTestCase extends TestCase { assertTrue(prop.isMustSupply()); } + @Test public void testMethodName() throws Exception { processor.visitMethod(Foo.class.getMethod("setBarMethod", String.class), type); assertNotNull(getProperty(type, "bar")); } + @Test public void testFieldAnnotation() throws Exception { processor.visitField(Foo.class.getDeclaredField("baz"), type); assertNotNull(getProperty(type, "baz")); } + @Test public void testFieldRequired() throws Exception { processor.visitField(Foo.class.getDeclaredField("bazRequired"), type); org.apache.tuscany.sca.assembly.Property prop = getProperty(type, "bazRequired"); @@ -70,11 +79,13 @@ public class PropertyProcessorTestCase extends TestCase { assertTrue(prop.isMustSupply()); } + @Test public void testFieldName() throws Exception { processor.visitField(Foo.class.getDeclaredField("bazField"), type); assertNotNull(getProperty(type, "theBaz")); } + @Test public void testDuplicateFields() throws Exception { processor.visitField(Bar.class.getDeclaredField("dup"), type); try { @@ -85,6 +96,7 @@ public class PropertyProcessorTestCase extends TestCase { } } + @Test public void testDuplicateMethods() throws Exception { processor.visitMethod(Bar.class.getMethod("setDupMethod", String.class), type); try { @@ -95,6 +107,7 @@ public class PropertyProcessorTestCase extends TestCase { } } + @Test public void testInvalidProperty() throws Exception { try { processor.visitMethod(Bar.class.getMethod("badMethod"), type); @@ -104,9 +117,8 @@ public class PropertyProcessorTestCase extends TestCase { } } - @Override - protected void setUp() throws Exception { - super.setUp(); + @Before + public void setUp() throws Exception { JavaImplementationFactory javaImplementationFactory = new DefaultJavaImplementationFactory(); type = javaImplementationFactory.createJavaImplementation(); processor = new PropertyProcessor(new DefaultAssemblyFactory()); @@ -178,6 +190,7 @@ public class PropertyProcessorTestCase extends TestCase { return JavaIntrospectionHelper.getBaseType(element.getType(), element.getGenericType()); } + @Test public void testMultiplicityCollection() throws Exception { processor.visitField(Multiple.class.getDeclaredField("refs1"), type); org.apache.tuscany.sca.assembly.Property prop = getProperty(type, "refs1"); @@ -186,6 +199,7 @@ public class PropertyProcessorTestCase extends TestCase { assertTrue(prop.isMany()); } + @Test public void testMultiplicityArray() throws Exception { processor.visitField(Multiple.class.getDeclaredField("refs2"), type); org.apache.tuscany.sca.assembly.Property prop = getProperty(type, "refs2"); @@ -194,6 +208,7 @@ public class PropertyProcessorTestCase extends TestCase { assertTrue(prop.isMany()); } + @Test public void testMultiplicityArrayMethod() throws Exception { processor.visitMethod(Multiple.class.getMethod("setRefs3", String[].class), type); org.apache.tuscany.sca.assembly.Property prop = getProperty(type, "refs3"); @@ -202,6 +217,7 @@ public class PropertyProcessorTestCase extends TestCase { assertTrue(prop.isMany()); } + @Test public void testMultiplicityCollectionMethod() throws Exception { processor.visitMethod(Multiple.class.getMethod("setRefs4", Collection.class), type); org.apache.tuscany.sca.assembly.Property prop = getProperty(type, "refs4"); diff --git a/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ReferenceProcessorTestCase.java b/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ReferenceProcessorTestCase.java index d68b1530f0..0a2cc9717a 100644 --- a/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ReferenceProcessorTestCase.java +++ b/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ReferenceProcessorTestCase.java @@ -22,6 +22,13 @@ import static org.apache.tuscany.sca.implementation.java.introspect.impl.ModelHe import java.util.Collection; import java.util.List; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertSame; +import static org.junit.Assert.fail; import junit.framework.TestCase; @@ -32,16 +39,19 @@ import org.apache.tuscany.sca.implementation.java.JavaImplementation; import org.apache.tuscany.sca.implementation.java.JavaImplementationFactory; import org.apache.tuscany.sca.interfacedef.java.DefaultJavaInterfaceFactory; import org.apache.tuscany.sca.interfacedef.java.JavaInterface; +import org.junit.Before; +import org.junit.Test; import org.osoa.sca.annotations.Reference; /** * @version $Rev$ $Date$ */ -public class ReferenceProcessorTestCase extends TestCase { +public class ReferenceProcessorTestCase { private JavaImplementation type; private ReferenceProcessor processor; + @Test public void testMethodAnnotation() throws Exception { processor.visitMethod(ReferenceProcessorTestCase.Foo.class.getMethod("setFoo", Ref.class), type); org.apache.tuscany.sca.assembly.Reference reference = getReference(type, "foo"); @@ -49,6 +59,7 @@ public class ReferenceProcessorTestCase extends TestCase { assertEquals(Ref.class, ((JavaInterface)reference.getInterfaceContract().getInterface()).getJavaClass()); } + @Test public void testMethodRequired() throws Exception { processor.visitMethod(ReferenceProcessorTestCase.Foo.class.getMethod("setFooRequired", Ref.class), type); org.apache.tuscany.sca.assembly.Reference ref = getReference(type, "fooRequired"); @@ -56,11 +67,13 @@ public class ReferenceProcessorTestCase extends TestCase { assertEquals(Multiplicity.ONE_ONE, ref.getMultiplicity()); } + @Test public void testMethodName() throws Exception { processor.visitMethod(ReferenceProcessorTestCase.Foo.class.getMethod("setBarMethod", Ref.class), type); assertNotNull(getReference(type, "bar")); } + @Test public void testFieldAnnotation() throws Exception { processor.visitField(ReferenceProcessorTestCase.Foo.class.getDeclaredField("baz"), type); org.apache.tuscany.sca.assembly.Reference reference = getReference(type, "baz"); @@ -68,6 +81,7 @@ public class ReferenceProcessorTestCase extends TestCase { assertEquals(Ref.class, ((JavaInterface)reference.getInterfaceContract().getInterface()).getJavaClass()); } + @Test public void testFieldRequired() throws Exception { processor.visitField(ReferenceProcessorTestCase.Foo.class.getDeclaredField("bazRequired"), type); org.apache.tuscany.sca.assembly.Reference ref = getReference(type, "bazRequired"); @@ -75,11 +89,13 @@ public class ReferenceProcessorTestCase extends TestCase { assertEquals(Multiplicity.ONE_ONE, ref.getMultiplicity()); } + @Test public void testFieldName() throws Exception { processor.visitField(ReferenceProcessorTestCase.Foo.class.getDeclaredField("bazField"), type); assertNotNull(getReference(type, "theBaz")); } + @Test public void testDuplicateFields() throws Exception { processor.visitField(ReferenceProcessorTestCase.Bar.class.getDeclaredField("dup"), type); try { @@ -90,6 +106,7 @@ public class ReferenceProcessorTestCase extends TestCase { } } + @Test public void testDuplicateMethods() throws Exception { processor.visitMethod(ReferenceProcessorTestCase.Bar.class.getMethod("setDupMethod", Ref.class), type); try { @@ -100,6 +117,7 @@ public class ReferenceProcessorTestCase extends TestCase { } } + @Test public void testInvalidProperty() throws Exception { try { processor.visitMethod(ReferenceProcessorTestCase.Bar.class.getMethod("badMethod"), type); @@ -109,9 +127,8 @@ public class ReferenceProcessorTestCase extends TestCase { } } - @Override - protected void setUp() throws Exception { - super.setUp(); + @Before + public void setUp() throws Exception { JavaImplementationFactory javaImplementationFactory = new DefaultJavaImplementationFactory(); type = javaImplementationFactory.createJavaImplementation(); processor = new ReferenceProcessor(new DefaultAssemblyFactory(), new DefaultJavaInterfaceFactory()); @@ -182,6 +199,7 @@ public class ReferenceProcessorTestCase extends TestCase { } + @Test public void testMultiplicity1ToN() throws Exception { processor.visitField(Multiple.class.getDeclaredField("refs1"), type); org.apache.tuscany.sca.assembly.Reference ref = getReference(type, "refs1"); @@ -191,6 +209,7 @@ public class ReferenceProcessorTestCase extends TestCase { // assertEquals(Multiplicity.ONE_ONE, ref.getMultiplicity()); } + @Test public void testMultiplicityTo0ToN() throws Exception { processor.visitField(Multiple.class.getDeclaredField("refs2"), type); org.apache.tuscany.sca.assembly.Reference ref = getReference(type, "refs2"); @@ -200,6 +219,7 @@ public class ReferenceProcessorTestCase extends TestCase { // assertFalse(ref.isMustSupply()); } + @Test public void testMultiplicity1ToNMethod() throws Exception { processor.visitMethod(Multiple.class.getMethod("setRefs3", Ref[].class), type); org.apache.tuscany.sca.assembly.Reference ref = getReference(type, "refs3"); @@ -209,6 +229,7 @@ public class ReferenceProcessorTestCase extends TestCase { // assertEquals(Multiplicity.ONE_ONE, ref.getMultiplicity()); } + @Test public void testMultiplicity0ToNMethod() throws Exception { processor.visitMethod(Multiple.class.getMethod("setRefs4", Collection.class), type); org.apache.tuscany.sca.assembly.Reference ref = getReference(type, "refs4"); diff --git a/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ResourceProcessorTestCase.java b/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ResourceProcessorTestCase.java index 207d00e945..c09b0547c9 100644 --- a/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ResourceProcessorTestCase.java +++ b/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ResourceProcessorTestCase.java @@ -18,25 +18,31 @@ */ package org.apache.tuscany.sca.implementation.java.introspect.impl; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.fail; + import java.lang.reflect.Field; import java.lang.reflect.Method; -import junit.framework.TestCase; - import org.apache.tuscany.sca.assembly.DefaultAssemblyFactory; import org.apache.tuscany.sca.implementation.java.DefaultJavaImplementationFactory; import org.apache.tuscany.sca.implementation.java.JavaImplementation; import org.apache.tuscany.sca.implementation.java.JavaImplementationFactory; import org.apache.tuscany.sca.implementation.java.JavaResourceImpl; +import org.junit.Before; +import org.junit.Test; /** * @version $Rev$ $Date$ */ -public class ResourceProcessorTestCase extends TestCase { +public class ResourceProcessorTestCase { JavaImplementation type; ResourceProcessor processor = new ResourceProcessor(new DefaultAssemblyFactory()); + @Test public void testVisitField() throws Exception { Field field = Foo.class.getDeclaredField("bar"); processor.visitField(field, type); @@ -46,6 +52,7 @@ public class ResourceProcessorTestCase extends TestCase { assertEquals(field.getType(), resource.getElement().getType()); } + @Test public void testVisitMethod() throws Exception { Method method = Foo.class.getMethod("setBar", Bar.class); processor.visitMethod(method, type); @@ -55,6 +62,7 @@ public class ResourceProcessorTestCase extends TestCase { assertEquals(method.getParameterTypes()[0], resource.getElement().getType()); } + @Test public void testVisitNamedMethod() throws Exception { Method method = Foo.class.getMethod("setBar2", Bar.class); processor.visitMethod(method, type); @@ -63,6 +71,7 @@ public class ResourceProcessorTestCase extends TestCase { assertEquals("mapped", resource.getMappedName()); } + @Test public void testVisitBadMethod() throws Exception { Method method = Foo.class.getMethod("setBad"); try { @@ -73,6 +82,7 @@ public class ResourceProcessorTestCase extends TestCase { } } + @Test public void testDuplicateResources() throws Exception { Field field = Foo.class.getDeclaredField("bar"); processor.visitField(field, type); @@ -84,9 +94,8 @@ public class ResourceProcessorTestCase extends TestCase { } } - @Override - protected void setUp() throws Exception { - super.setUp(); + @Before + public void setUp() throws Exception { JavaImplementationFactory javaImplementationFactory = new DefaultJavaImplementationFactory(); type = javaImplementationFactory.createJavaImplementation(); } diff --git a/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ScopeProcessorTestCase.java b/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ScopeProcessorTestCase.java index 471d4366f6..5097a1d6be 100644 --- a/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ScopeProcessorTestCase.java +++ b/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ScopeProcessorTestCase.java @@ -18,7 +18,7 @@ */ package org.apache.tuscany.sca.implementation.java.introspect.impl; -import junit.framework.TestCase; +import static org.junit.Assert.assertEquals; import org.apache.tuscany.sca.assembly.DefaultAssemblyFactory; import org.apache.tuscany.sca.implementation.java.DefaultJavaImplementationFactory; @@ -26,14 +26,17 @@ import org.apache.tuscany.sca.implementation.java.IntrospectionException; import org.apache.tuscany.sca.implementation.java.JavaImplementation; import org.apache.tuscany.sca.implementation.java.JavaImplementationFactory; import org.apache.tuscany.sca.implementation.java.JavaScopeImpl; +import org.junit.Before; +import org.junit.Test; /** * @version $Rev$ $Date$ */ -public class ScopeProcessorTestCase extends TestCase { +public class ScopeProcessorTestCase { private JavaImplementationFactory javaImplementationFactory; + @Test public void testCompositeScope() throws IntrospectionException { ScopeProcessor processor = new ScopeProcessor(new DefaultAssemblyFactory()); JavaImplementation type = javaImplementationFactory.createJavaImplementation(); @@ -42,6 +45,7 @@ public class ScopeProcessorTestCase extends TestCase { assertEquals(JavaScopeImpl.COMPOSITE, type.getJavaScope()); } + @Test public void testSessionScope() throws IntrospectionException { ScopeProcessor processor = new ScopeProcessor(new DefaultAssemblyFactory()); JavaImplementation type = javaImplementationFactory.createJavaImplementation(); @@ -49,6 +53,7 @@ public class ScopeProcessorTestCase extends TestCase { assertEquals(JavaScopeImpl.SESSION, type.getJavaScope()); } + @Test public void testConversationalScope() throws IntrospectionException { ScopeProcessor processor = new ScopeProcessor(new DefaultAssemblyFactory()); JavaImplementation type = javaImplementationFactory.createJavaImplementation(); @@ -56,6 +61,7 @@ public class ScopeProcessorTestCase extends TestCase { assertEquals(JavaScopeImpl.CONVERSATION, type.getJavaScope()); } + @Test public void testRequestScope() throws IntrospectionException { ScopeProcessor processor = new ScopeProcessor(new DefaultAssemblyFactory()); JavaImplementation type = javaImplementationFactory.createJavaImplementation(); @@ -63,6 +69,7 @@ public class ScopeProcessorTestCase extends TestCase { assertEquals(JavaScopeImpl.REQUEST, type.getJavaScope()); } + @Test public void testStatelessScope() throws IntrospectionException { ScopeProcessor processor = new ScopeProcessor(new DefaultAssemblyFactory()); JavaImplementation type = javaImplementationFactory.createJavaImplementation(); @@ -70,6 +77,7 @@ public class ScopeProcessorTestCase extends TestCase { assertEquals(JavaScopeImpl.STATELESS, type.getJavaScope()); } + @Test public void testNoScope() throws IntrospectionException { ScopeProcessor processor = new ScopeProcessor(new DefaultAssemblyFactory()); JavaImplementation type = javaImplementationFactory.createJavaImplementation(); @@ -77,9 +85,8 @@ public class ScopeProcessorTestCase extends TestCase { assertEquals(JavaScopeImpl.STATELESS, type.getJavaScope()); } - @Override - protected void setUp() throws Exception { - super.setUp(); + @Before + public void setUp() throws Exception { javaImplementationFactory = new DefaultJavaImplementationFactory(); } diff --git a/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ServiceCallbackTestCase.java b/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ServiceCallbackTestCase.java index 10f0500e4d..f612232fd7 100644 --- a/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ServiceCallbackTestCase.java +++ b/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ServiceCallbackTestCase.java @@ -19,12 +19,14 @@ package org.apache.tuscany.sca.implementation.java.introspect.impl; import static org.apache.tuscany.sca.implementation.java.introspect.impl.ModelHelper.getService; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; import java.lang.reflect.Field; import java.lang.reflect.Method; -import junit.framework.TestCase; - import org.apache.tuscany.sca.assembly.DefaultAssemblyFactory; import org.apache.tuscany.sca.implementation.java.DefaultJavaImplementationFactory; import org.apache.tuscany.sca.implementation.java.IntrospectionException; @@ -32,6 +34,8 @@ import org.apache.tuscany.sca.implementation.java.JavaImplementation; import org.apache.tuscany.sca.implementation.java.JavaImplementationFactory; import org.apache.tuscany.sca.interfacedef.InvalidCallbackException; import org.apache.tuscany.sca.interfacedef.java.DefaultJavaInterfaceFactory; +import org.junit.Before; +import org.junit.Test; import org.osoa.sca.CallableReference; import org.osoa.sca.annotations.Callback; import org.osoa.sca.annotations.Service; @@ -39,16 +43,17 @@ import org.osoa.sca.annotations.Service; /** * @version $Rev$ $Date$ */ -public class ServiceCallbackTestCase extends TestCase { +public class ServiceCallbackTestCase { private ServiceProcessor processor; private JavaImplementationFactory javaImplementationFactory; - @Override - protected void setUp() throws Exception { + @Before + public void setUp() throws Exception { processor = new ServiceProcessor(new DefaultAssemblyFactory(), new DefaultJavaInterfaceFactory()); javaImplementationFactory = new DefaultJavaImplementationFactory(); } + @Test public void testMethodCallbackInterface() throws Exception { JavaImplementation type = javaImplementationFactory.createJavaImplementation(); processor.visitClass(FooImpl.class, type); @@ -59,6 +64,7 @@ public class ServiceCallbackTestCase extends TestCase { assertEquals(method, type.getCallbackMembers().get(FooCallback.class.getName()).iterator().next().getAnchor()); } + @Test public void testFieldCallbackInterface() throws Exception { JavaImplementation type = javaImplementationFactory.createJavaImplementation(); processor.visitClass(FooImpl.class, type); @@ -69,6 +75,7 @@ public class ServiceCallbackTestCase extends TestCase { assertEquals(field, type.getCallbackMembers().get(FooCallback.class.getName()).iterator().next().getAnchor()); } + @Test public void testFieldCallbackInterface1() throws Exception { JavaImplementation type = javaImplementationFactory.createJavaImplementation(); processor.visitClass(FooImpl1.class, type); @@ -80,6 +87,7 @@ public class ServiceCallbackTestCase extends TestCase { } + @Test public void testMethodDoesNotMatchCallback() throws Exception { JavaImplementation type = javaImplementationFactory.createJavaImplementation(); processor.visitClass(BadBarImpl.class, type); @@ -92,6 +100,7 @@ public class ServiceCallbackTestCase extends TestCase { } } + @Test public void testNoParamCallback() throws Exception { JavaImplementation type = javaImplementationFactory.createJavaImplementation(); processor.visitClass(BadBarImpl.class, type); @@ -104,6 +113,7 @@ public class ServiceCallbackTestCase extends TestCase { } } + @Test public void testFieldDoesNotMatchCallback() throws Exception { JavaImplementation type = javaImplementationFactory.createJavaImplementation(); processor.visitClass(BadBarImpl.class, type); @@ -116,6 +126,7 @@ public class ServiceCallbackTestCase extends TestCase { } } + @Test public void testBadCallbackInterfaceAnnotation() throws Exception { JavaImplementation type = javaImplementationFactory.createJavaImplementation(); try { diff --git a/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ServiceProcessorTestCase.java b/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ServiceProcessorTestCase.java index aea90aa6eb..26dbbda8e4 100644 --- a/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ServiceProcessorTestCase.java +++ b/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ServiceProcessorTestCase.java @@ -28,17 +28,27 @@ import org.apache.tuscany.sca.implementation.java.JavaImplementation; import org.apache.tuscany.sca.implementation.java.JavaImplementationFactory; import org.apache.tuscany.sca.interfacedef.java.DefaultJavaInterfaceFactory; import org.apache.tuscany.sca.interfacedef.java.JavaInterface; +import org.junit.Before; +import org.junit.Test; import org.osoa.sca.annotations.Callback; import org.osoa.sca.annotations.Remotable; import org.osoa.sca.annotations.Service; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertSame; +import static org.junit.Assert.fail; /** * @version $Rev$ $Date$ */ -public class ServiceProcessorTestCase extends TestCase { +public class ServiceProcessorTestCase { private ServiceProcessor processor; private JavaImplementation type; + @Test public void testMultipleInterfaces() throws Exception { processor.visitClass(FooMultiple.class, type); assertEquals(2, type.getServices().size()); @@ -48,12 +58,14 @@ public class ServiceProcessorTestCase extends TestCase { assertNotNull(ModelHelper.getService(type, Bar.class.getSimpleName())); } + @Test public void testSingleInterfaces() throws Exception { processor.visitClass(FooSingle.class, type); assertEquals(1, type.getServices().size()); assertNotNull(ModelHelper.getService(type, Baz.class.getSimpleName())); } + @Test public void testMultipleNoService() throws Exception { processor.visitClass(FooMultipleNoService.class, type); assertEquals(0, type.getServices().size()); @@ -62,17 +74,20 @@ public class ServiceProcessorTestCase extends TestCase { /** * Verifies a service with a callback annotation is recognized */ + @Test public void testMultipleWithCallbackAnnotation() throws Exception { processor.visitClass(FooMultipleWithCalback.class, type); assertEquals(1, type.getServices().size()); } + @Test public void testMultipleWithWebServiceAnnotation() throws Exception { processor.visitClass(FooMultipleWithWebService.class, type); assertEquals(2, type.getServices().size()); } + @Test public void testRemotableNoService() throws Exception { processor.visitClass(FooRemotableNoService.class, type); assertEquals(1, type.getServices().size()); @@ -80,10 +95,12 @@ public class ServiceProcessorTestCase extends TestCase { assertEquals(BazRemotable.class, ((JavaInterface)service.getInterfaceContract().getInterface()).getJavaClass()); } + @Test public void testNonInterface() throws Exception { processor.visitClass(FooServiceUsingClassImpl.class, type); } + @Test public void testNoInterfaces() throws Exception { try { processor.visitClass(BadDefinition.class, type); @@ -93,9 +110,8 @@ public class ServiceProcessorTestCase extends TestCase { } } - @Override - protected void setUp() throws Exception { - super.setUp(); + @Before + public void setUp() throws Exception { processor = new ServiceProcessor(new DefaultAssemblyFactory(), new DefaultJavaInterfaceFactory()); JavaImplementationFactory javaImplementationFactory = new DefaultJavaImplementationFactory(); type = javaImplementationFactory.createJavaImplementation(); -- cgit v1.2.3