summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ReferenceProcessor.java4
-rw-r--r--java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConstructorProcessorTestCase.java4
-rw-r--r--java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConstructorReferenceTestCase.java18
3 files changed, 17 insertions, 9 deletions
diff --git a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ReferenceProcessor.java b/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ReferenceProcessor.java
index 737bfc9ba8..0733f0084c 100644
--- a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ReferenceProcessor.java
+++ b/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ReferenceProcessor.java
@@ -142,6 +142,10 @@ public class ReferenceProcessor extends BaseJavaClassVisitor {
throw new InvalidReferenceException("JCA90016 Constructor has @Reference with required=false: " + type.getName());
}
+ if (refAnnotation.name() == null || refAnnotation.name().length() < 1) {
+ throw new InvalidReferenceException("JCA90018 @Reference in a Constructor must have a name attribute" + type.getName());
+ }
+
String paramName = parameter.getName();
String name = getReferenceName(paramName, parameter.getIndex(), refAnnotation.name());
JavaElementImpl ref = type.getReferenceMembers().get(name);
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 3674d01e24..cc0c0888b8 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
@@ -145,7 +145,7 @@ public class ConstructorProcessorTestCase {
public static final class Mixed {
@org.oasisopen.sca.annotation.Constructor
- public Mixed(@Reference
+ public Mixed(@Reference(name="_ref0")
String param1, @Property(name = "foo")
String param2, @Reference(name = "bar")
String param3) {
@@ -154,7 +154,7 @@ public class ConstructorProcessorTestCase {
public static final class Multiple {
@org.oasisopen.sca.annotation.Constructor
- public Multiple(@Reference
+ public Multiple(@Reference(name="_ref0")
Collection<String> param1, @Property(name = "foo")
String[] param2, @Reference(name = "bar", required = true)
List<String> param3, @Property(name = "abc")
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 14a6e010b1..eeeee851e4 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
@@ -82,8 +82,12 @@ public class ConstructorReferenceTestCase extends AbstractProcessorTest {
public void testNoName() throws Exception {
JavaImplementation type = javaImplementationFactory.createJavaImplementation();
Constructor<NoNameFoo> ctor = NoNameFoo.class.getConstructor(String.class);
- visitConstructor(ctor, type);
- assertNotNull(getReference(type, "_ref0"));
+ try {
+ visitConstructor(ctor, type);
+ fail();
+ } catch (InvalidReferenceException e) {
+ //expected
+ }
}
@Test
@@ -91,7 +95,7 @@ public class ConstructorReferenceTestCase extends AbstractProcessorTest {
JavaImplementation type = javaImplementationFactory.createJavaImplementation();
Constructor<Foo> ctor = Foo.class.getConstructor(Integer.class);
visitConstructor(ctor, type);
- assertNotNull(getReference(type, "myRef"));
+ assertNotNull(getReference(type, "myRef2"));
}
@Test
@@ -113,7 +117,7 @@ public class ConstructorReferenceTestCase extends AbstractProcessorTest {
try {
visitConstructor(ctor, type);
fail();
- } catch (InvalidConstructorException e) {
+ } catch (InvalidReferenceException e) {
// expected
}
}
@@ -135,13 +139,13 @@ public class ConstructorReferenceTestCase extends AbstractProcessorTest {
}
- @org.oasisopen.sca.annotation.Constructor("myRef")
- public Foo(@Reference Integer prop) {
+ @org.oasisopen.sca.annotation.Constructor("myRef2")
+ public Foo(@Reference(name = "myRef2") Integer prop) {
}
@org.oasisopen.sca.annotation.Constructor()
- public Foo(@Reference List prop) {
+ public Foo(@Reference(name = "myRef3") List prop) {
}
}