summaryrefslogtreecommitdiffstats
path: root/java/sca/modules/implementation-java/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'java/sca/modules/implementation-java/src/test')
-rw-r--r--java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AbstractProcessorTest.java8
-rw-r--r--java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConstructorReferenceTestCase.java36
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)
+ {}
+
+
+ }
}