diff options
author | kelvingoodson <kelvingoodson@13f79535-47bb-0310-9956-ffa450edef68> | 2009-07-09 09:13:52 +0000 |
---|---|---|
committer | kelvingoodson <kelvingoodson@13f79535-47bb-0310-9956-ffa450edef68> | 2009-07-09 09:13:52 +0000 |
commit | 3a6b8b52c846c239e5d99559fe889ddd4a8a2efa (patch) | |
tree | c8471fbc2222dd78f821fcce4a2c4d7fa10159cc /java/sca/modules/implementation-java/src/test | |
parent | 9059026361e282b7f867817bcf8fd721030c8f8d (diff) |
TUSCANY-3130 ReferenceProcessor's visitMethod method now checks that args are not annotated as references
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@792466 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/sca/modules/implementation-java/src/test')
2 files changed, 42 insertions, 2 deletions
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 842897606c..478c5d4be0 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 @@ -19,6 +19,7 @@ package org.apache.tuscany.sca.implementation.java.introspect.impl; import java.lang.reflect.Constructor; +import java.lang.reflect.Method; import org.apache.tuscany.sca.assembly.AssemblyFactory; import org.apache.tuscany.sca.assembly.DefaultAssemblyFactory; @@ -39,8 +40,8 @@ public abstract class AbstractProcessorTest { protected AssemblyFactory factory; protected JavaInterfaceFactory javaFactory; protected ConstructorProcessor constructorProcessor; - private ReferenceProcessor referenceProcessor; - private PropertyProcessor propertyProcessor; + protected ReferenceProcessor referenceProcessor; + protected PropertyProcessor propertyProcessor; private ResourceProcessor resourceProcessor; @@ -63,6 +64,7 @@ public abstract class AbstractProcessorTest { definition = new JavaConstructorImpl<T>(constructor); type.getConstructors().put(constructor, definition); } + JavaParameterImpl[] parameters = definition.getParameters(); for (int i = 0; i < parameters.length; i++) { referenceProcessor.visitConstructorParameter(parameters[i], type); @@ -71,4 +73,6 @@ public abstract class AbstractProcessorTest { // monitorProcessor.visitConstructorParameter(parameters[i], type); } } + + } 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 decdc34386..2aac962730 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 @@ -24,15 +24,22 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.fail; import java.lang.reflect.Constructor; +import java.lang.reflect.Method; import java.util.List; import org.apache.tuscany.sca.assembly.Multiplicity; import org.apache.tuscany.sca.implementation.java.DefaultJavaImplementationFactory; +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.implementation.java.JavaParameterImpl; +import org.junit.Ignore; import org.junit.Test; +import org.oasisopen.sca.annotation.Property; import org.oasisopen.sca.annotation.Reference; +import com.sun.xml.internal.ws.model.JavaMethodImpl; + /** * @version $Rev$ $Date$ */ @@ -110,6 +117,21 @@ public class ConstructorReferenceTestCase extends AbstractProcessorTest { // expected } } + + @Test + public void testClassWithBadMethodArgReference() throws Exception { + JavaImplementation type = javaImplementationFactory.createJavaImplementation(); + Method meth = BadFoo2.class.getMethod("BadFoo2Method", String.class); + + try { + referenceProcessor.visitMethod(meth, type); + + fail(); + } catch (IllegalReferenceException e) { + e.printStackTrace(); + System.out.println("Exception successfully received"); + } + } // public void testMultiplicityRequired() throws Exception { // TODO multiplicity @@ -169,5 +191,19 @@ public class ConstructorReferenceTestCase extends AbstractProcessorTest { } } + + private static class BadFoo2 { + + @org.oasisopen.sca.annotation.Constructor() + public BadFoo2(@Property(name = "myProp", required = true)String prop) { + + } + + /** Java can't tell that the @reference argument is disallowed by SCA, but the run time must reject it*/ + public void BadFoo2Method(@Reference(name = "badMethodArgRef")String methArg) + {} + + + } } |