You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by mc...@apache.org on 2008/12/03 13:09:13 UTC
svn commit: r722852 [1/2] -
/tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/
Author: mcombellack
Date: Wed Dec 3 04:09:11 2008
New Revision: 722852
URL: http://svn.apache.org/viewvc?rev=722852&view=rev
Log:
Converted unit tests from JUnit 3 to JUnit 4
Modified:
tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AbstractProcessorTest.java
tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AbstractPropertyProcessorTestCase.java
tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AllowsPassByReferenceProcessorTestCase.java
tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConstructorProcessorTestCase.java
tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConstructorPropertyTestCase.java
tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConstructorReferenceTestCase.java
tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConstructorResourceTestCase.java
tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ContextProcessorTestCase.java
tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConversationIDProcessorTestCase.java
tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConversationProcessorTestCase.java
tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConvertTimeMillisTestCase.java
tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DestroyProcessorTestCase.java
tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/EagerInitProcessorTestCase.java
tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/HeuristicAndPropertyTestCase.java
tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/HeuristicConstructorTestCase.java
tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/HeuristicPojoProcessorTestCase.java
tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/HeutisticExtensibleConstructorTestCase.java
tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InitProcessorTestCase.java
tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/PolicyProcessorTestCase.java
tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/PropertyProcessorTestCase.java
tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ReferenceProcessorTestCase.java
tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ResourceProcessorTestCase.java
tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ScopeProcessorTestCase.java
tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ServiceCallbackTestCase.java
tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ServiceProcessorTestCase.java
Modified: tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AbstractProcessorTest.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AbstractProcessorTest.java?rev=722852&r1=722851&r2=722852&view=diff
==============================================================================
--- tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AbstractProcessorTest.java (original)
+++ tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AbstractProcessorTest.java Wed Dec 3 04:09:11 2008
@@ -20,8 +20,6 @@
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 @@
*
* @version $Rev$ $Date$
*/
-public class AbstractProcessorTest extends TestCase {
+public abstract class AbstractProcessorTest {
protected AssemblyFactory factory;
protected JavaInterfaceFactory javaFactory;
protected ConstructorProcessor constructorProcessor;
Modified: tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AbstractPropertyProcessorTestCase.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AbstractPropertyProcessorTestCase.java?rev=722852&r1=722851&r2=722852&view=diff
==============================================================================
--- tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AbstractPropertyProcessorTestCase.java (original)
+++ tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AbstractPropertyProcessorTestCase.java Wed Dec 3 04:09:11 2008
@@ -20,14 +20,15 @@
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.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 @@
assertNotNull(prop);
}
+ @Test
public void testVisitNoParamsMethod() throws Exception {
Method method = Foo.class.getMethod("setNoParamsBar");
JavaImplementation type = javaImplementationFactory.createJavaImplementation();
@@ -65,6 +70,7 @@
}
}
+ @Test
public void testVisitNonVoidMethod() throws Exception {
Method method = Foo.class.getMethod("setBadBar", String.class);
JavaImplementation type = javaImplementationFactory.createJavaImplementation();
@@ -76,6 +82,7 @@
}
}
+ @Test
public void testDuplicateMethod() throws Exception {
Method method = Foo.class.getMethod("setBar", String.class);
JavaImplementation type = javaImplementationFactory.createJavaImplementation();
@@ -88,6 +95,7 @@
}
}
+ @Test
public void testVisitField() throws Exception {
Field field = Foo.class.getDeclaredField("d");
JavaImplementation type = javaImplementationFactory.createJavaImplementation();
@@ -96,6 +104,7 @@
assertNotNull(prop);
}
+ @Test
public void testVisitConstructor() throws Exception {
Constructor<Foo> ctor = Foo.class.getConstructor(String.class);
JavaImplementation type = javaImplementationFactory.createJavaImplementation();
@@ -106,9 +115,8 @@
assertNotNull(getProperty(type, "test"));
}
- @Override
- protected void setUp() throws Exception {
- super.setUp();
+ @Before
+ public void setUp() throws Exception {
extension = new TestProcessor();
javaImplementationFactory = new DefaultJavaImplementationFactory();
}
Modified: tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AllowsPassByReferenceProcessorTestCase.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AllowsPassByReferenceProcessorTestCase.java?rev=722852&r1=722851&r2=722852&view=diff
==============================================================================
--- tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AllowsPassByReferenceProcessorTestCase.java (original)
+++ tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AllowsPassByReferenceProcessorTestCase.java Wed Dec 3 04:09:11 2008
@@ -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 @@
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());
Modified: tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConstructorProcessorTestCase.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConstructorProcessorTestCase.java?rev=722852&r1=722851&r2=722852&view=diff
==============================================================================
--- tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConstructorProcessorTestCase.java (original)
+++ tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConstructorProcessorTestCase.java Wed Dec 3 04:09:11 2008
@@ -20,14 +20,17 @@
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.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 @@
}
}
+ @Test
public void testConstructorAnnotation() throws Exception {
JavaImplementation type = javaImplementationFactory.createJavaImplementation();
Constructor<Foo> ctor1 = Foo.class.getConstructor(String.class);
@@ -65,6 +71,7 @@
assertEquals("foo", type.getConstructor().getParameters()[0].getName());
}
+ @Test
public void testNoAnnotation() throws Exception {
JavaImplementation type = javaImplementationFactory.createJavaImplementation();
Constructor<NoAnnotation> ctor1 = NoAnnotation.class.getConstructor();
@@ -72,6 +79,7 @@
assertNull(type.getConstructor());
}
+ @Test
public void testBadAnnotation() throws Exception {
JavaImplementation type = javaImplementationFactory.createJavaImplementation();
Constructor<BadAnnotation> ctor1 = BadAnnotation.class.getConstructor(String.class, Foo.class);
@@ -83,6 +91,7 @@
}
}
+ @Test
public void testMixedParameters() throws Exception {
JavaImplementation type = javaImplementationFactory.createJavaImplementation();
Constructor<Mixed> ctor1 = Mixed.class.getConstructor(String.class, String.class, String.class);
@@ -154,6 +163,7 @@
}
}
+ @Test
public void testMultiplicity() throws Exception {
JavaImplementation type = javaImplementationFactory.createJavaImplementation();
Constructor<Multiple> ctor1 = Multiple.class.getConstructor(Collection.class,
Modified: tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConstructorPropertyTestCase.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConstructorPropertyTestCase.java?rev=722852&r1=722851&r2=722852&view=diff
==============================================================================
--- tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConstructorPropertyTestCase.java (original)
+++ tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConstructorPropertyTestCase.java Wed Dec 3 04:09:11 2008
@@ -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 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 @@
private JavaImplementationFactory javaImplementationFactory = new DefaultJavaImplementationFactory();
+ @Test
public void testProperty() throws Exception {
JavaImplementation type = javaImplementationFactory.createJavaImplementation();
Constructor<Foo> ctor = Foo.class.getConstructor(String.class);
@@ -44,6 +50,7 @@
assertEquals("myProp", property.getName());
}
+ @Test
public void testTwoPropertiesSameType() throws Exception {
JavaImplementation type = javaImplementationFactory.createJavaImplementation();
Constructor<Foo> ctor = Foo.class.getConstructor(String.class, String.class);
@@ -52,6 +59,7 @@
assertNotNull(getProperty(type, "myProp2"));
}
+ @Test
public void testDuplicateProperty() throws Exception {
JavaImplementation type = javaImplementationFactory.createJavaImplementation();
Constructor<BadFoo> ctor = BadFoo.class.getConstructor(String.class, String.class);
@@ -63,6 +71,7 @@
}
}
+ @Test
public void testNoName() throws Exception {
JavaImplementation type = javaImplementationFactory.createJavaImplementation();
Constructor<BadFoo> ctor = BadFoo.class.getConstructor(String.class);
@@ -74,6 +83,7 @@
}
}
+ @Test
public void testNamesOnConstructor() throws Exception {
JavaImplementation type = javaImplementationFactory.createJavaImplementation();
Constructor<Foo> ctor = Foo.class.getConstructor(Integer.class);
@@ -81,6 +91,7 @@
assertNotNull(getProperty(type, "myProp"));
}
+ @Test
public void testInvalidNumberOfNames() throws Exception {
JavaImplementation type = javaImplementationFactory.createJavaImplementation();
Constructor<BadFoo> ctor = BadFoo.class.getConstructor(Integer.class, Integer.class);
@@ -92,6 +103,7 @@
}
}
+ @Test
public void testNoMatchingNames() throws Exception {
JavaImplementation type = javaImplementationFactory.createJavaImplementation();
Constructor<BadFoo> ctor = BadFoo.class.getConstructor(List.class, List.class);
Modified: tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConstructorReferenceTestCase.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConstructorReferenceTestCase.java?rev=722852&r1=722851&r2=722852&view=diff
==============================================================================
--- tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConstructorReferenceTestCase.java (original)
+++ tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConstructorReferenceTestCase.java Wed Dec 3 04:09:11 2008
@@ -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.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 @@
private JavaImplementationFactory javaImplementationFactory = new DefaultJavaImplementationFactory();
+ @Test
public void testReference() throws Exception {
JavaImplementation type = javaImplementationFactory.createJavaImplementation();
Constructor<Foo> ctor = Foo.class.getConstructor(String.class);
@@ -45,6 +50,7 @@
assertEquals("myRef", reference.getName());
}
+ @Test
public void testTwoReferencesSameType() throws Exception {
JavaImplementation type = javaImplementationFactory.createJavaImplementation();
Constructor<Foo> ctor = Foo.class.getConstructor(String.class, String.class);
@@ -53,6 +59,7 @@
assertNotNull(getReference(type, "myRef2"));
}
+ @Test
public void testDuplicateProperty() throws Exception {
JavaImplementation type = javaImplementationFactory.createJavaImplementation();
Constructor<BadFoo> ctor = BadFoo.class.getConstructor(String.class, String.class);
@@ -64,6 +71,7 @@
}
}
+ @Test
public void testNoName() throws Exception {
JavaImplementation type = javaImplementationFactory.createJavaImplementation();
Constructor<NoNameFoo> ctor = NoNameFoo.class.getConstructor(String.class);
@@ -71,6 +79,7 @@
assertNotNull(getReference(type, "_ref0"));
}
+ @Test
public void testNamesOnConstructor() throws Exception {
JavaImplementation type = javaImplementationFactory.createJavaImplementation();
Constructor<Foo> ctor = Foo.class.getConstructor(Integer.class);
@@ -78,6 +87,7 @@
assertNotNull(getReference(type, "myRef"));
}
+ @Test
public void testInvalidNumberOfNames() throws Exception {
JavaImplementation type = javaImplementationFactory.createJavaImplementation();
Constructor<BadFoo> ctor = BadFoo.class.getConstructor(Integer.class, Integer.class);
@@ -89,6 +99,7 @@
}
}
+ @Test
public void testNoMatchingNames() throws Exception {
JavaImplementation type = javaImplementationFactory.createJavaImplementation();
Constructor<BadFoo> ctor = BadFoo.class.getConstructor(List.class, List.class);
@@ -100,11 +111,6 @@
}
}
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- }
-
// public void testMultiplicityRequired() throws Exception {
// TODO multiplicity
// }
Modified: tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConstructorResourceTestCase.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConstructorResourceTestCase.java?rev=722852&r1=722851&r2=722852&view=diff
==============================================================================
--- tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConstructorResourceTestCase.java (original)
+++ tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConstructorResourceTestCase.java Wed Dec 3 04:09:11 2008
@@ -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 @@
private JavaImplementationFactory javaImplementationFactory = new DefaultJavaImplementationFactory();
+ @Test
public void testResource() throws Exception {
JavaImplementation type = javaImplementationFactory.createJavaImplementation();
Constructor<Foo> ctor = Foo.class.getConstructor(String.class);
@@ -40,6 +46,7 @@
assertFalse(resource.isOptional());
}
+ @Test
public void testTwoResourcesSameType() throws Exception {
JavaImplementation type = javaImplementationFactory.createJavaImplementation();
Constructor<Foo> ctor = Foo.class.getConstructor(String.class, String.class);
@@ -48,6 +55,7 @@
assertNotNull(type.getResources().get("myResource2"));
}
+ @Test
public void testDuplicateResource() throws Exception {
JavaImplementation type = javaImplementationFactory.createJavaImplementation();
Constructor<BadFoo> ctor = BadFoo.class.getConstructor(String.class, String.class);
@@ -59,6 +67,7 @@
}
}
+ @Test
public void testNoName() throws Exception {
JavaImplementation type = javaImplementationFactory.createJavaImplementation();
Constructor<ConstructorResourceTestCase.BadFoo> ctor =
@@ -71,6 +80,7 @@
}
}
+ @Test
public void testNamesOnConstructor() throws Exception {
JavaImplementation type = javaImplementationFactory.createJavaImplementation();
Constructor<Foo> ctor = Foo.class.getConstructor(Integer.class);
@@ -78,6 +88,7 @@
assertNotNull(type.getResources().get("myResource"));
}
+ @Test
public void testInvalidNumberOfNames() throws Exception {
JavaImplementation type = javaImplementationFactory.createJavaImplementation();
Constructor<ConstructorResourceTestCase.BadFoo> ctor =
@@ -90,6 +101,7 @@
}
}
+ @Test
public void testNoMatchingNames() throws Exception {
JavaImplementation type = javaImplementationFactory.createJavaImplementation();
Constructor<ConstructorResourceTestCase.BadFoo> ctor =
Modified: tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ContextProcessorTestCase.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ContextProcessorTestCase.java?rev=722852&r1=722851&r2=722852&view=diff
==============================================================================
--- tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ContextProcessorTestCase.java (original)
+++ tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ContextProcessorTestCase.java Wed Dec 3 04:09:11 2008
@@ -20,6 +20,12 @@
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.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 @@
/**
* @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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
}
}
+ @Test
public void testInvalidParamTypeField() throws Exception {
Field field = Foo.class.getDeclaredField("badContext");
JavaImplementation type = javaImplementationFactory.createJavaImplementation();
@@ -105,6 +121,7 @@
}
+ @Test
public void testInvalidParamNum() throws Exception {
Method method = Foo.class.getMethod("setContext", ComponentContext.class, String.class);
JavaImplementation type = javaImplementationFactory.createJavaImplementation();
@@ -116,6 +133,7 @@
}
}
+ @Test
public void testInvalidNoParams() throws Exception {
Method method = Foo.class.getMethod("setContext");
JavaImplementation type = javaImplementationFactory.createJavaImplementation();
@@ -127,6 +145,7 @@
}
}
+ @Test
public void testNoContext() throws Exception {
Method method = Foo.class.getMethod("noContext", ComponentContext.class);
JavaImplementation type = javaImplementationFactory.createJavaImplementation();
@@ -134,6 +153,7 @@
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 @@
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());
Modified: tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConversationIDProcessorTestCase.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConversationIDProcessorTestCase.java?rev=722852&r1=722851&r2=722852&view=diff
==============================================================================
--- tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConversationIDProcessorTestCase.java (original)
+++ tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConversationIDProcessorTestCase.java Wed Dec 3 04:09:11 2008
@@ -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 @@
*
* @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 @@
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 @@
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 @@
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 @@
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());
}
Modified: tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConversationProcessorTestCase.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConversationProcessorTestCase.java?rev=722852&r1=722851&r2=722852&view=diff
==============================================================================
--- tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConversationProcessorTestCase.java (original)
+++ tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConversationProcessorTestCase.java Wed Dec 3 04:09:11 2008
@@ -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 @@
/**
* @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 @@
assertEquals(-1, type.getMaxAge());
}
+ @Test
public void testMaxAge() throws Exception {
JavaImplementation type = javaImplementationFactory.createJavaImplementation();
processor.visitClass(FooMaxAge.class, type);
@@ -52,6 +56,7 @@
assertEquals(-1, type.getMaxIdleTime());
}
+ @Test
public void testImplicitScope() throws Exception {
JavaImplementation type = javaImplementationFactory.createJavaImplementation();
processor.visitClass(ImplicitFooScope.class, type);
@@ -70,6 +75,7 @@
}
*/
+ @Test
public void testBadFooBoth() throws Exception {
JavaImplementation type = javaImplementationFactory.createJavaImplementation();
processor.visitClass(BadFooBoth.class, type);
@@ -77,6 +83,7 @@
assertEquals(10000L, type.getMaxIdleTime());
}
+ @Test
public void testJustConversation() throws Exception {
// TODO do we want these semantics
JavaImplementation type = javaImplementationFactory.createJavaImplementation();
@@ -86,6 +93,7 @@
assertEquals(-1, type.getMaxIdleTime());
}
+ @Test
public void testSetConversationIDField() throws Exception {
JavaImplementation type = javaImplementationFactory.createJavaImplementation();
Field field = FooWithConversationIDField.class.getDeclaredField("conversationID");
@@ -94,6 +102,7 @@
assertEquals(field, type.getConversationIDMembers().get(0));
}
+ @Test
public void testSetConversationIDMethod() throws Exception {
JavaImplementation type = javaImplementationFactory.createJavaImplementation();
Method method = FooWithConversationIDMethod.class.getDeclaredMethods()[0];
Modified: tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConvertTimeMillisTestCase.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConvertTimeMillisTestCase.java?rev=722852&r1=722851&r2=722852&view=diff
==============================================================================
--- tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConvertTimeMillisTestCase.java (original)
+++ tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConvertTimeMillisTestCase.java Wed Dec 3 04:09:11 2008
@@ -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 @@
}
}
+ @Test
public void testConvertMinutes() throws Exception {
assertEquals(600000L, registy.convertTimeMillis("10 minutes"));
assertEquals(600000L, registy.convertTimeMillis("10 MINUTES"));
@@ -50,6 +55,7 @@
}
}
+ @Test
public void testConvertHours() throws Exception {
assertEquals(36000000L, registy.convertTimeMillis("10 hours"));
assertEquals(36000000L, registy.convertTimeMillis("10 HOURS"));
@@ -61,6 +67,7 @@
}
}
+ @Test
public void testConvertDays() throws Exception {
assertEquals(864000000L, registy.convertTimeMillis("10 days"));
assertEquals(864000000L, registy.convertTimeMillis("10 DAYS"));
@@ -72,6 +79,7 @@
}
}
+ @Test
public void testConvertYears() throws Exception {
assertEquals(315569260000L, registy.convertTimeMillis("10 years"));
assertEquals(315569260000L, registy.convertTimeMillis("10 YEARS"));
@@ -83,11 +91,13 @@
}
}
+ @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 @@
}
}
- @Override
- protected void setUp() throws Exception {
- super.setUp();
+ @Before
+ public void setUp() throws Exception {
registy = new MockProcessor();
}
Modified: tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DestroyProcessorTestCase.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DestroyProcessorTestCase.java?rev=722852&r1=722851&r2=722852&view=diff
==============================================================================
--- tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DestroyProcessorTestCase.java (original)
+++ tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DestroyProcessorTestCase.java Wed Dec 3 04:09:11 2008
@@ -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 @@
assertNotNull(type.getDestroyMethod());
}
+ @Test
public void testBadDestroy() throws Exception {
DestroyProcessor processor = new DestroyProcessor(assemblyFactory);
JavaImplementation type = javaImplementationFactory.createJavaImplementation();
@@ -57,6 +61,7 @@
}
}
+ @Test
public void testTwoDestroy() throws Exception {
DestroyProcessor processor = new DestroyProcessor(assemblyFactory);
JavaImplementation type = javaImplementationFactory.createJavaImplementation();
@@ -71,6 +76,7 @@
}
}
+ @Test
public void testProtectedDestroy() throws Exception {
DestroyProcessor processor = new DestroyProcessor(assemblyFactory);
JavaImplementation type = javaImplementationFactory.createJavaImplementation();
@@ -83,6 +89,7 @@
}
}
+ @Test
public void testPrivateDestroy() throws Exception {
DestroyProcessor processor = new DestroyProcessor(assemblyFactory);
JavaImplementation type = javaImplementationFactory.createJavaImplementation();
Modified: tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/EagerInitProcessorTestCase.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/EagerInitProcessorTestCase.java?rev=722852&r1=722851&r2=722852&view=diff
==============================================================================
--- tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/EagerInitProcessorTestCase.java (original)
+++ tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/EagerInitProcessorTestCase.java Wed Dec 3 04:09:11 2008
@@ -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();
Modified: tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/HeuristicAndPropertyTestCase.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/HeuristicAndPropertyTestCase.java?rev=722852&r1=722851&r2=722852&view=diff
==============================================================================
--- tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/HeuristicAndPropertyTestCase.java (original)
+++ tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/HeuristicAndPropertyTestCase.java Wed Dec 3 04:09:11 2008
@@ -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.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 @@
* 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 @@
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());
}
Modified: tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/HeuristicConstructorTestCase.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/HeuristicConstructorTestCase.java?rev=722852&r1=722851&r2=722852&view=diff
==============================================================================
--- tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/HeuristicConstructorTestCase.java (original)
+++ tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/HeuristicConstructorTestCase.java Wed Dec 3 04:09:11 2008
@@ -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.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 @@
/**
* 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 @@
/**
* 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 @@
* 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 @@
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 @@
}
}
+ @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 @@
/**
* 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 @@
assertNotNull(getProperty(type, "prop1"));
}
+ @Test
public void testPrivateConstructor() throws Exception {
JavaImplementation type = javaImplementationFactory.createJavaImplementation();
try {
@@ -185,6 +202,7 @@
}
}
+ @Test
public void testMultipleConstructors() throws Exception {
// throw new UnsupportedOperationException("Finish heuristic multiple
// constructors - Foo10");
Modified: tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/HeuristicPojoProcessorTestCase.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/HeuristicPojoProcessorTestCase.java?rev=722852&r1=722851&r2=722852&view=diff
==============================================================================
--- tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/HeuristicPojoProcessorTestCase.java (original)
+++ tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/HeuristicPojoProcessorTestCase.java Wed Dec 3 04:09:11 2008
@@ -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.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 @@
* Verifies a single service interface is computed when only one interface
* is implemented
*/
+ @Test
public void testSingleInterface() throws Exception {
JavaImplementation type = javaImplementationFactory.createJavaImplementation();
Constructor<SingleInterfaceImpl> ctor = SingleInterfaceImpl.class.getConstructor();
@@ -81,6 +87,7 @@
/**
* Verifies property and reference setters are computed
*/
+ @Test
public void testPropertyReference() throws Exception {
JavaImplementation type = javaImplementationFactory.createJavaImplementation();
Constructor<SingleInterfaceWithPropertyReferenceImpl> ctor = SingleInterfaceWithPropertyReferenceImpl.class
@@ -102,6 +109,7 @@
* 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<SingleInterfaceImpl> ctor = SingleInterfaceImpl.class.getConstructor();
@@ -114,6 +122,7 @@
* 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<RefInterfaceImpl> ctor = RefInterfaceImpl.class.getConstructor();
@@ -126,6 +135,7 @@
* 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<ReferenceCollectionImpl> ctor = ReferenceCollectionImpl.class.getConstructor();
@@ -139,6 +149,7 @@
* 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<PropertyCollectionImpl> ctor = PropertyCollectionImpl.class.getConstructor();
@@ -153,6 +164,7 @@
*
* @Remotable
*/
+ @Test
public void testRemotableRef() throws Exception {
JavaImplementation type = javaImplementationFactory.createJavaImplementation();
Constructor<RemotableRefImpl> ctor = RemotableRefImpl.class.getConstructor();
@@ -162,6 +174,7 @@
assertEquals(0, type.getProperties().size());
}
+ @Test
public void testParentInterface() throws IntrospectionException, NoSuchMethodException {
JavaImplementation type = javaImplementationFactory.createJavaImplementation();
Constructor<Child> ctor = Child.class.getConstructor();
@@ -174,6 +187,7 @@
* 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 @@
assertEquals(1, type.getServices().size());
}
+ @Test
public void testProtectedRemotableRefField() throws IntrospectionException, NoSuchMethodException {
JavaImplementation type = javaImplementationFactory.createJavaImplementation();
Constructor<ProtectedRemotableRefFieldImpl> ctor = ProtectedRemotableRefFieldImpl.class.getConstructor();
@@ -204,6 +219,7 @@
assertNotNull(ModelHelper.getReference(type, "otherRef"));
}
+ @Test
public void testProtectedRemotableRefMethod() throws IntrospectionException, NoSuchMethodException {
JavaImplementation type = javaImplementationFactory.createJavaImplementation();
Constructor<ProtectedRemotableRefMethodImpl> ctor = ProtectedRemotableRefMethodImpl.class.getConstructor();
@@ -212,6 +228,7 @@
assertNotNull(ModelHelper.getReference(type, "otherRef"));
}
+ @Test
public void testSetDataTypes() throws Exception {
JavaImplementation type = javaImplementationFactory.createJavaImplementation();
Constructor<PropertyIntTypeOnConstructor> ctor = PropertyIntTypeOnConstructor.class.getConstructor();
@@ -228,6 +245,7 @@
* 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 @@
* 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);
Modified: tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/HeutisticExtensibleConstructorTestCase.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/HeutisticExtensibleConstructorTestCase.java?rev=722852&r1=722851&r2=722852&view=diff
==============================================================================
--- tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/HeutisticExtensibleConstructorTestCase.java (original)
+++ tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/HeutisticExtensibleConstructorTestCase.java Wed Dec 3 04:09:11 2008
@@ -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.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 @@
* 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<Foo> ctor = Foo.class.getConstructor(String.class, String.class);
@@ -84,6 +88,7 @@
* @Bar
* @throws Exception
*/
+ @Test
public void testBarAnnotationProcessedLast() throws Exception {
JavaImplementation type = javaImplementationFactory.createJavaImplementation();
visitEnd(Foo.class, type);
@@ -105,6 +110,7 @@
* 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<Foo2> ctor = Foo2.class.getConstructor(String.class, String.class, String.class);
Modified: tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InitProcessorTestCase.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InitProcessorTestCase.java?rev=722852&r1=722851&r2=722852&view=diff
==============================================================================
--- tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InitProcessorTestCase.java (original)
+++ tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InitProcessorTestCase.java Wed Dec 3 04:09:11 2008
@@ -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.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 @@
javaImplementationFactory = new DefaultJavaImplementationFactory();
}
+ @Test
public void testInit() throws Exception {
InitProcessor processor = new InitProcessor(new DefaultAssemblyFactory());
JavaImplementation type = javaImplementationFactory.createJavaImplementation();
@@ -47,6 +55,7 @@
assertNotNull(type.getInitMethod());
}
+ @Test
public void testBadInit() throws Exception {
InitProcessor processor = new InitProcessor(new DefaultAssemblyFactory());
JavaImplementation type = javaImplementationFactory.createJavaImplementation();
@@ -59,6 +68,7 @@
}
}
+ @Test
public void testTwoInit() throws Exception {
InitProcessor processor = new InitProcessor(new DefaultAssemblyFactory());
JavaImplementation type = javaImplementationFactory.createJavaImplementation();
@@ -73,6 +83,7 @@
}
}
+ @Test
public void testProtectedInit() throws Exception {
InitProcessor processor = new InitProcessor(new DefaultAssemblyFactory());
JavaImplementation type = javaImplementationFactory.createJavaImplementation();
@@ -85,6 +96,7 @@
}
}
+ @Test
public void testPrivateInit() throws Exception {
InitProcessor processor = new InitProcessor(new DefaultAssemblyFactory());
JavaImplementation type = javaImplementationFactory.createJavaImplementation();
@@ -97,6 +109,7 @@
}
}
+ @Test
public void testBadInit2() throws Exception {
InitProcessor processor = new InitProcessor(new DefaultAssemblyFactory());
JavaImplementation type = javaImplementationFactory.createJavaImplementation();
Modified: tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/PolicyProcessorTestCase.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/PolicyProcessorTestCase.java?rev=722852&r1=722851&r2=722852&view=diff
==============================================================================
--- tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/PolicyProcessorTestCase.java (original)
+++ tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/PolicyProcessorTestCase.java Wed Dec 3 04:09:11 2008
@@ -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.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 @@
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 @@
}
}
- @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());
Modified: tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/PropertyProcessorTestCase.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/PropertyProcessorTestCase.java?rev=722852&r1=722851&r2=722852&view=diff
==============================================================================
--- tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/PropertyProcessorTestCase.java (original)
+++ tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/PropertyProcessorTestCase.java Wed Dec 3 04:09:11 2008
@@ -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 @@
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 @@
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 @@
}
}
+ @Test
public void testDuplicateMethods() throws Exception {
processor.visitMethod(Bar.class.getMethod("setDupMethod", String.class), type);
try {
@@ -95,6 +107,7 @@
}
}
+ @Test
public void testInvalidProperty() throws Exception {
try {
processor.visitMethod(Bar.class.getMethod("badMethod"), type);
@@ -104,9 +117,8 @@
}
}
- @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 @@
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 @@
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 @@
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 @@
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");
Modified: tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ReferenceProcessorTestCase.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ReferenceProcessorTestCase.java?rev=722852&r1=722851&r2=722852&view=diff
==============================================================================
--- tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ReferenceProcessorTestCase.java (original)
+++ tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ReferenceProcessorTestCase.java Wed Dec 3 04:09:11 2008
@@ -22,6 +22,13 @@
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.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 @@
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 @@
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 @@
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 @@
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 @@
}
}
+ @Test
public void testDuplicateMethods() throws Exception {
processor.visitMethod(ReferenceProcessorTestCase.Bar.class.getMethod("setDupMethod", Ref.class), type);
try {
@@ -100,6 +117,7 @@
}
}
+ @Test
public void testInvalidProperty() throws Exception {
try {
processor.visitMethod(ReferenceProcessorTestCase.Bar.class.getMethod("badMethod"), type);
@@ -109,9 +127,8 @@
}
}
- @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 @@
}
+ @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 @@
// 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 @@
// 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 @@
// 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");
Modified: tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ResourceProcessorTestCase.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ResourceProcessorTestCase.java?rev=722852&r1=722851&r2=722852&view=diff
==============================================================================
--- tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ResourceProcessorTestCase.java (original)
+++ tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ResourceProcessorTestCase.java Wed Dec 3 04:09:11 2008
@@ -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 @@
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 @@
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 @@
assertEquals("mapped", resource.getMappedName());
}
+ @Test
public void testVisitBadMethod() throws Exception {
Method method = Foo.class.getMethod("setBad");
try {
@@ -73,6 +82,7 @@
}
}
+ @Test
public void testDuplicateResources() throws Exception {
Field field = Foo.class.getDeclaredField("bar");
processor.visitField(field, type);
@@ -84,9 +94,8 @@
}
}
- @Override
- protected void setUp() throws Exception {
- super.setUp();
+ @Before
+ public void setUp() throws Exception {
JavaImplementationFactory javaImplementationFactory = new DefaultJavaImplementationFactory();
type = javaImplementationFactory.createJavaImplementation();
}