summaryrefslogtreecommitdiffstats
path: root/branches/sca-java-1.3.1/vtest/java-api/annotations/reference/src
diff options
context:
space:
mode:
Diffstat (limited to 'branches/sca-java-1.3.1/vtest/java-api/annotations/reference/src')
-rw-r--r--branches/sca-java-1.3.1/vtest/java-api/annotations/reference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/reference/AService.java51
-rw-r--r--branches/sca-java-1.3.1/vtest/java-api/annotations/reference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/reference/BService.java31
-rw-r--r--branches/sca-java-1.3.1/vtest/java-api/annotations/reference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/reference/impl/AServiceImpl.java204
-rw-r--r--branches/sca-java-1.3.1/vtest/java-api/annotations/reference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/reference/impl/AnotherAServiceImpl.java129
-rw-r--r--branches/sca-java-1.3.1/vtest/java-api/annotations/reference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/reference/impl/BServiceImpl.java32
-rw-r--r--branches/sca-java-1.3.1/vtest/java-api/annotations/reference/src/main/resources/ab.composite54
-rw-r--r--branches/sca-java-1.3.1/vtest/java-api/annotations/reference/src/test/java/org/apache/tuscany/sca/vtest/javaapi/annotations/reference/ReferenceAnnotationTestCase.java211
7 files changed, 712 insertions, 0 deletions
diff --git a/branches/sca-java-1.3.1/vtest/java-api/annotations/reference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/reference/AService.java b/branches/sca-java-1.3.1/vtest/java-api/annotations/reference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/reference/AService.java
new file mode 100644
index 0000000000..3322b542a9
--- /dev/null
+++ b/branches/sca-java-1.3.1/vtest/java-api/annotations/reference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/reference/AService.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.vtest.javaapi.annotations.reference;
+
+
+/**
+ * Simple Service that uses another Service
+ */
+public interface AService {
+
+ public String getName();
+ public String getB1Name();
+ public String getB2Name();
+ public String getB3Name();
+ public String getB4Name();
+ public String getB5Name();
+ public String getB6Name();
+ public String getB7Name();
+ public String getB8Name();
+ public String getB9Name();
+ public String getB10Name();
+ public String getB11Name();
+ public String getB12Name();
+ public String getB13Name(int i);
+ public String getB14Name(int i);
+ public String getB15Name(int i);
+
+ public int getB13Size();
+ public int getB14Size();
+ public int getB15Size();
+
+ public boolean isB7SetterCalled();
+ public boolean isB16Null();
+ public boolean isB17Null();
+}
diff --git a/branches/sca-java-1.3.1/vtest/java-api/annotations/reference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/reference/BService.java b/branches/sca-java-1.3.1/vtest/java-api/annotations/reference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/reference/BService.java
new file mode 100644
index 0000000000..53b376d369
--- /dev/null
+++ b/branches/sca-java-1.3.1/vtest/java-api/annotations/reference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/reference/BService.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.vtest.javaapi.annotations.reference;
+
+import org.osoa.sca.annotations.Remotable;
+
+/**
+ * Simple Service used by another service
+ */
+@Remotable
+public interface BService {
+
+ String getName();
+
+}
diff --git a/branches/sca-java-1.3.1/vtest/java-api/annotations/reference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/reference/impl/AServiceImpl.java b/branches/sca-java-1.3.1/vtest/java-api/annotations/reference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/reference/impl/AServiceImpl.java
new file mode 100644
index 0000000000..916ee25d7a
--- /dev/null
+++ b/branches/sca-java-1.3.1/vtest/java-api/annotations/reference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/reference/impl/AServiceImpl.java
@@ -0,0 +1,204 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.vtest.javaapi.annotations.reference.impl;
+
+import java.util.List;
+
+import org.apache.tuscany.sca.vtest.javaapi.annotations.reference.AService;
+import org.apache.tuscany.sca.vtest.javaapi.annotations.reference.BService;
+import org.osoa.sca.annotations.Reference;
+import org.osoa.sca.annotations.Service;
+
+@Service(AService.class)
+public class AServiceImpl implements AService {
+
+ @Reference
+ protected BService b1; // field injection
+
+ protected BService b2; // injected via constructor parameter
+
+ protected BService b3; // setter injection
+
+ public BService b4; // field injection (public, un-annotated)
+
+ protected BService b5; // field injection (non-public, un-annotated)
+
+ public BService b6; // setter injection (public, un-annotated)
+
+ @Reference
+ protected BService b7; // setter injection (field and setter annotated)
+
+ @Reference(name="b8", required=false)
+ protected BService bEight; // field injection (different reference and field name)
+
+ protected BService bNine; // setter injection (different reference and field name)
+
+ @Reference(required=false)
+ protected BService b10; // multiplicity="0..1" and required=false
+
+ @Reference(required=false)
+ protected BService b11; // multiplicity="1..1" and required=false
+
+ protected BService b12; // multiplicity="1..1" and required=true at setter
+
+ @Reference(required=false)
+ protected List<BService> b13; // multiplicity="0..n" and required=false
+
+ protected List<BService> b14; // multiplicity="1..n" and required=false at setter
+
+ @Reference(name="b15", required=true)
+ protected BService[] b15s; // multiplicity="1..n" and required=true
+
+ @Reference(required=false)
+ protected BService b16;
+
+ @Reference(required=false)
+ public BService b17;
+
+ protected boolean b7SetterCalled;
+
+ public AServiceImpl(@Reference(name = "b2")
+ BService b2) {
+ super();
+ this.b2 = b2;
+ b7SetterCalled = false;
+ }
+
+ @Reference
+ public void setB3(BService b3) {
+ this.b3 = b3;
+ }
+
+ public void setB6(BService b6) {
+ this.b6 = b6;
+ }
+
+ @Reference
+ public void setB7(BService b7) {
+ b7SetterCalled = true;
+ this.b7 = b7;
+ }
+
+ @Reference(name="b9", required=false)
+ public void setB9(BService bNine) {
+ this.bNine = bNine;
+ }
+
+ @Reference(required=true)
+ public void setB12(BService b12) {
+ this.b12 = b12;
+ }
+
+ @Reference(required=true)
+ public void setB14(List<BService> b14) {
+ this.b14 = b14;
+ }
+
+ public String getName() {
+ return "AService";
+ }
+
+ public String getB1Name() {
+ return b1.getName();
+ }
+
+ public String getB2Name() {
+ return b2.getName();
+ }
+
+ public String getB3Name() {
+ return b3.getName();
+ }
+
+ public String getB4Name() {
+ return b4.getName();
+ }
+
+ public String getB5Name() {
+ return b5.getName();
+ }
+
+ public String getB6Name() {
+ return b6.getName();
+ }
+
+ public String getB7Name() {
+ return b7.getName();
+ }
+
+ public String getB8Name() {
+ return bEight.getName();
+ }
+
+ public String getB9Name() {
+ return bNine.getName();
+ }
+
+ public String getB10Name() {
+ return b10.getName();
+ }
+
+ public String getB11Name() {
+ return b11.getName();
+ }
+
+ public String getB12Name() {
+ return b12.getName();
+ }
+
+ public String getB13Name(int i) {
+ BService b = (BService) b13.get(i);
+ return b.getName();
+ }
+
+ public String getB14Name(int i) {
+ BService b = (BService) b14.get(i);
+ return b.getName();
+ }
+
+ public String getB15Name(int i) {
+ return b15s[i].getName();
+ }
+
+ public int getB13Size() {
+ return b13.size();
+ }
+
+ public int getB14Size() {
+ return b14.size();
+ }
+
+ public int getB15Size() {
+ return b15s.length;
+ }
+
+ public boolean isB7SetterCalled() {
+ return b7SetterCalled;
+ }
+
+ public boolean isB16Null() {
+ return b16 == null;
+ }
+
+ public boolean isB17Null() {
+ return b17 == null;
+ }
+
+}
diff --git a/branches/sca-java-1.3.1/vtest/java-api/annotations/reference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/reference/impl/AnotherAServiceImpl.java b/branches/sca-java-1.3.1/vtest/java-api/annotations/reference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/reference/impl/AnotherAServiceImpl.java
new file mode 100644
index 0000000000..82cd8014cd
--- /dev/null
+++ b/branches/sca-java-1.3.1/vtest/java-api/annotations/reference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/reference/impl/AnotherAServiceImpl.java
@@ -0,0 +1,129 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.vtest.javaapi.annotations.reference.impl;
+
+import org.apache.tuscany.sca.vtest.javaapi.annotations.reference.AService;
+import org.apache.tuscany.sca.vtest.javaapi.annotations.reference.BService;
+import org.osoa.sca.annotations.Service;
+
+@Service(AService.class)
+public class AnotherAServiceImpl implements AService {
+
+ public BService b4; // field injection (public, un-annotated)
+
+ protected BService b5; // field injection (non-public, un-annotated)
+
+ public BService b6; // setter injection (public, un-annotated)
+
+ public AnotherAServiceImpl() {
+ }
+
+ public String getName() {
+ return "AService";
+ }
+
+ public String getB4Name() {
+ return b4.getName();
+ }
+
+ public String getB5Name() {
+ return b5.getName();
+ }
+
+ public void setB6(BService b6) {
+ this.b6 = b6;
+ }
+
+ public String getB6Name() {
+ return b6.getName();
+ }
+
+ public String getB1Name() {
+ return null;
+ }
+
+ public String getB2Name() {
+ return null;
+ }
+
+ public String getB3Name() {
+ return null;
+ }
+
+ public String getB7Name() {
+ return null;
+ }
+
+ public String getB8Name() {
+ return null;
+ }
+
+ public String getB9Name() {
+ return null;
+ }
+
+ public boolean isB7SetterCalled() {
+ return false;
+ }
+
+ public String getB10Name() {
+ return null;
+ }
+
+ public String getB11Name() {
+ return null;
+ }
+
+ public String getB12Name() {
+ return null;
+ }
+
+ public String getB13Name(int i) {
+ return null;
+ }
+
+ public int getB13Size() {
+ return 0;
+ }
+
+ public String getB14Name(int i) {
+ return null;
+ }
+
+ public int getB14Size() {
+ return 0;
+ }
+
+ public String getB15Name(int i) {
+ return null;
+ }
+
+ public int getB15Size() {
+ return 0;
+ }
+
+ public boolean isB16Null() {
+ return true;
+ }
+
+ public boolean isB17Null() {
+ return true;
+ }
+}
diff --git a/branches/sca-java-1.3.1/vtest/java-api/annotations/reference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/reference/impl/BServiceImpl.java b/branches/sca-java-1.3.1/vtest/java-api/annotations/reference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/reference/impl/BServiceImpl.java
new file mode 100644
index 0000000000..e8611d510f
--- /dev/null
+++ b/branches/sca-java-1.3.1/vtest/java-api/annotations/reference/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/reference/impl/BServiceImpl.java
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.vtest.javaapi.annotations.reference.impl;
+
+import org.apache.tuscany.sca.vtest.javaapi.annotations.reference.BService;
+import org.osoa.sca.annotations.Service;
+
+@Service(BService.class)
+public class BServiceImpl implements BService {
+
+ public String getName() {
+ return "BService";
+ }
+
+}
diff --git a/branches/sca-java-1.3.1/vtest/java-api/annotations/reference/src/main/resources/ab.composite b/branches/sca-java-1.3.1/vtest/java-api/annotations/reference/src/main/resources/ab.composite
new file mode 100644
index 0000000000..9937173894
--- /dev/null
+++ b/branches/sca-java-1.3.1/vtest/java-api/annotations/reference/src/main/resources/ab.composite
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ targetNamespace="http://java-api-tests"
+ name="AB-Composite">
+
+ <component name="AComponent">
+ <implementation.java class="org.apache.tuscany.sca.vtest.javaapi.annotations.reference.impl.AServiceImpl"/>
+ <reference name="b1" target="BComponent"/>
+ <reference name="b2" target="BComponent"/>
+ <reference name="b3" target="BComponent"/>
+ <reference name="b4" target="BComponent"/>
+ <reference name="b5" target="BComponent"/>
+ <reference name="b6" target="BComponent"/>
+ <reference name="b7" target="BComponent"/>
+ <reference name="b8" target="BComponent"/>
+ <reference name="b9" target="BComponent"/>
+ <reference name="b10" multiplicity="0..1" target="BComponent"/>
+ <reference name="b11" multiplicity="1..1" target="BComponent"/>
+ <reference name="b12" multiplicity="1..1" target="BComponent"/>
+ <reference name="b13" multiplicity="0..n" target=""/>
+ <reference name="b14" multiplicity="1..n" target="BComponent"/>
+ <reference name="b15" multiplicity="1..n" target="BComponent BComponent"/>
+ </component>
+
+ <component name="AnotherAComponent">
+ <implementation.java class="org.apache.tuscany.sca.vtest.javaapi.annotations.reference.impl.AnotherAServiceImpl"/>
+ <reference name="b4" target="BComponent"/>
+ <reference name="b5" target="BComponent"/>
+ <reference name="b6" target="BComponent"/>
+ </component>
+
+ <component name="BComponent">
+ <implementation.java class="org.apache.tuscany.sca.vtest.javaapi.annotations.reference.impl.BServiceImpl"/>
+ </component>
+
+</composite>
diff --git a/branches/sca-java-1.3.1/vtest/java-api/annotations/reference/src/test/java/org/apache/tuscany/sca/vtest/javaapi/annotations/reference/ReferenceAnnotationTestCase.java b/branches/sca-java-1.3.1/vtest/java-api/annotations/reference/src/test/java/org/apache/tuscany/sca/vtest/javaapi/annotations/reference/ReferenceAnnotationTestCase.java
new file mode 100644
index 0000000000..a399d892cb
--- /dev/null
+++ b/branches/sca-java-1.3.1/vtest/java-api/annotations/reference/src/test/java/org/apache/tuscany/sca/vtest/javaapi/annotations/reference/ReferenceAnnotationTestCase.java
@@ -0,0 +1,211 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.vtest.javaapi.annotations.reference;
+
+import static org.junit.Assert.fail;
+import junit.framework.Assert;
+
+import org.apache.tuscany.sca.vtest.utilities.ServiceFinder;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Ignore;
+import org.junit.Test;
+
+/**
+ * This test class tests the "@Reference" annotation described in section 1.8.14
+ */
+public class ReferenceAnnotationTestCase {
+
+ protected static String compositeName = "ab.composite";
+ protected static AService a;
+
+ @BeforeClass
+ public static void init() throws Exception {
+ try {
+ System.out.println("Setting up");
+ ServiceFinder.init(compositeName);
+ a = ServiceFinder.getService(AService.class, "AComponent");
+
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ }
+
+ @AfterClass
+ public static void destroy() throws Exception {
+
+ System.out.println("Cleaning up");
+ ServiceFinder.cleanup();
+ }
+
+ /**
+ * Temporary test unrelated to spec test effort. Remove after resolution of
+ */
+ @Test
+ @Ignore
+ // JIRA T-2145
+ public void bogusComponentName() throws Exception {
+ ServiceFinder.init(compositeName);
+ try {
+ AService a = ServiceFinder.getService(AService.class, "AReallyBogusComponentName");
+ if (a == null)
+ fail("Should have thrown an exception rather than return null");
+ else
+ fail("Should have thrown an exception rather than return a proxy");
+ } finally {
+ ServiceFinder.cleanup();
+ }
+
+ }
+
+ /**
+ * Lines 1404, 1405, 1406 <br>
+ * The "@Reference" annotation type is used to annotate a Java class field
+ * or a setter method that is used to inject a service that resolves the
+ * reference. The interface of the service injected is defined by the type
+ * of the Java class field or the type of the setter method input argument.
+ * <p>
+ * This tests the use of the three usages of the "@Reference" annotation<br>
+ * B1 is injected via field injection <br>
+ * B2 is injected via constructor parameter <br>
+ * B3 is injected via setter method
+ */
+ @Test
+ public void atReference1() throws Exception {
+
+ Assert.assertEquals("BService", a.getB1Name());
+ Assert.assertEquals("BService", a.getB2Name());
+ Assert.assertEquals("BService", a.getB3Name());
+
+ }
+
+ /**
+ * Lines 1407, 1408, 1409, 1410 <br>
+ * References may also be injected via public setter methods even when the
+ * "@Reference" annotation is not present. However, the "@Reference"
+ * annotation must be used in order to inject a reference onto a non public
+ * field. In the case where there is no "@Reference" annotation, the name of
+ * the reference is the same as the name of the field or setter.
+ * <p>
+ * B4 is injected via field injection. Public, Non-annotated <br>
+ * B5 is expected to fail field injection. Non-Public, Non-Annotated <br>
+ * B6 is injected via setter injection. Public, Non-Annotated
+ */
+ @Test
+ public void atReference2() throws Exception {
+ AService anotherA = ServiceFinder.getService(AService.class, "AnotherAComponent");
+ Assert.assertEquals("BService", anotherA.getB4Name());
+ try {
+ anotherA.getB5Name();
+ fail("getB5Name expected to fail with NPE");
+ } catch (NullPointerException e) {
+ }
+ Assert.assertEquals("BService", anotherA.getB6Name());
+
+ }
+
+ /**
+ * Lines 1411 <br>
+ * Where there is both a setter method and a field for a reference, the
+ * setter method is used.
+ * <p>
+ * B7 has both field and setter annotated. The setter must be called
+ */
+ @Test
+ public void atReference3() throws Exception {
+ Assert.assertTrue(a.isB7SetterCalled());
+ }
+
+ /**
+ * Lines 1413, 1414, 1415 <br>
+ * The "@Reference" annotation has the following attributes: <br> • name
+ * (optional) – the name of the reference, defaults to the name of the field
+ * of the Java class <br>
+ * required (optional) – whether injection of service or services is
+ * required. Defaults to true.
+ * <p>
+ * Reference and field have different names<br>
+ * B8 is field injected<br>
+ * B9 is setter injected
+ */
+ @Test
+ public void atReference4() throws Exception {
+ Assert.assertEquals("BService", a.getB8Name());
+ Assert.assertEquals("BService", a.getB9Name());
+ }
+
+ /**
+ * Lines 1457 to 1459<br>
+ * If the reference is not an array or collection, then the implied
+ * component type has a reference with a multiplicity of either 0..1 or 1..1
+ * depending on the value of the
+ *
+ * @Reference required attribute – 1..1 applies if required=true.<br>
+ * <p>
+ * B10 is field injected, required=false, and multiplicity="0..1"<br>
+ * B11 is field injected, required=false, and multiplicity="1..1"<br>
+ * B12 is setter injected, required=true, and multiplicity="1..1"
+ */
+ @Test
+ public void atReference5() throws Exception {
+ Assert.assertEquals("BService", a.getB10Name());
+ Assert.assertEquals("BService", a.getB11Name());
+ Assert.assertEquals("BService", a.getB12Name());
+ }
+
+ /**
+ * Lines 1461 to 1463<br>
+ * If the reference is defined as an array or as a java.util.Collection,
+ * then the implied component type has a reference with a multiplicity of
+ * either 1..n or 0..n, depending on whether the required attribute of the
+ * "@Reference" annotation is set to true or false – 1..n applies if
+ * required=true.<br>
+ * <p>
+ * B13 is a java.util.List, field injected, required=false,
+ * multiplicity="0..n", and no target<br>
+ * B14 is a java.util.List, setter injected, required=true,
+ * multiplicity="1..n", and one target<br>
+ * B15 is an array, field injected, required=true, multiplicity="1..n", and
+ * two targets
+ */
+ @Test
+ public void atReference6() throws Exception {
+ Assert.assertEquals(0, a.getB13Size());
+ Assert.assertEquals("BService", a.getB14Name(0));
+ Assert.assertEquals(1, a.getB14Size());
+ Assert.assertEquals("BService", a.getB15Name(0));
+ Assert.assertEquals("BService", a.getB15Name(1));
+ Assert.assertEquals(2, a.getB15Size());
+ }
+
+ /**
+ * Lines 1415 <br>
+ * required (optional) - whether injection of service or services is
+ * required. Defaults to true.
+ * <p>
+ * b16 and b17 is defined as "@Reference(required=false)" and AComponent
+ * does not define reference for them
+ */
+ @Test
+ public void atReference7() throws Exception {
+ Assert.assertTrue(a.isB16Null());
+ Assert.assertTrue(a.isB17Null());
+ }
+}