diff options
author | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2009-10-16 11:31:06 +0000 |
---|---|---|
committer | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2009-10-16 11:31:06 +0000 |
commit | 71271771379899a808f782b7c0394f74373743e3 (patch) | |
tree | 7fad90562e2400449b95558dc9f7d1fde60d8e45 /java/sca/modules/implementation-java | |
parent | f20f3c743d281e4d875469209a6821962b1016eb (diff) |
Fix JCA_10014 - @reference in a constructor must have a name attribte
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@825850 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/sca/modules/implementation-java')
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) { } } |