Author: kwilliams
Date: Sun Mar 30 14:02:02 2008
New Revision: 642818

URL: http://svn.apache.org/viewvc?rev=642818&view=rev
Log:
More @Reference tests

Modified:
    
incubator/tuscany/java/sca/vtest/java-api/src/main/java/org/apache/tuscany/sca/vtest/javaapi/AService.java
    
incubator/tuscany/java/sca/vtest/java-api/src/main/java/org/apache/tuscany/sca/vtest/javaapi/impl/AServiceImpl.java
    incubator/tuscany/java/sca/vtest/java-api/src/main/resources/ab.composite
    
incubator/tuscany/java/sca/vtest/java-api/src/test/java/org/apache/tuscany/sca/vtest/javaapi/ReferenceAnnotationTestCase.java

Modified: 
incubator/tuscany/java/sca/vtest/java-api/src/main/java/org/apache/tuscany/sca/vtest/javaapi/AService.java
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/vtest/java-api/src/main/java/org/apache/tuscany/sca/vtest/javaapi/AService.java?rev=642818&r1=642817&r2=642818&view=diff
==============================================================================
--- 
incubator/tuscany/java/sca/vtest/java-api/src/main/java/org/apache/tuscany/sca/vtest/javaapi/AService.java
 (original)
+++ 
incubator/tuscany/java/sca/vtest/java-api/src/main/java/org/apache/tuscany/sca/vtest/javaapi/AService.java
 Sun Mar 30 14:02:02 2008
@@ -32,6 +32,8 @@
     public String getB5Name();
     public String getB6Name();
     public String getB7Name();
+    public String getB8Name();
+    public String getB9Name();
 
     public boolean isB7SetterCalled();
     

Modified: 
incubator/tuscany/java/sca/vtest/java-api/src/main/java/org/apache/tuscany/sca/vtest/javaapi/impl/AServiceImpl.java
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/vtest/java-api/src/main/java/org/apache/tuscany/sca/vtest/javaapi/impl/AServiceImpl.java?rev=642818&r1=642817&r2=642818&view=diff
==============================================================================
--- 
incubator/tuscany/java/sca/vtest/java-api/src/main/java/org/apache/tuscany/sca/vtest/javaapi/impl/AServiceImpl.java
 (original)
+++ 
incubator/tuscany/java/sca/vtest/java-api/src/main/java/org/apache/tuscany/sca/vtest/javaapi/impl/AServiceImpl.java
 Sun Mar 30 14:02:02 2008
@@ -43,6 +43,11 @@
     @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)
+
     protected boolean b7SetterCalled;
 
     public AServiceImpl(@Reference(name = "b2")
@@ -67,6 +72,11 @@
         this.b7 = b7;
     }
 
+    @Reference(name="b9", required=false)
+    public void setB9(BService bNine) {
+        this.bNine = bNine;
+    }
+    
     public String getName() {
         return "AService";
     }
@@ -99,6 +109,14 @@
         return b7.getName();
     }
 
+    public String getB8Name() {
+        return bEight.getName();
+    }
+    
+    public String getB9Name() {
+        return bNine.getName();
+    }
+    
     public boolean isB7SetterCalled() {
         return b7SetterCalled;
     }

Modified: 
incubator/tuscany/java/sca/vtest/java-api/src/main/resources/ab.composite
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/vtest/java-api/src/main/resources/ab.composite?rev=642818&r1=642817&r2=642818&view=diff
==============================================================================
--- incubator/tuscany/java/sca/vtest/java-api/src/main/resources/ab.composite 
(original)
+++ incubator/tuscany/java/sca/vtest/java-api/src/main/resources/ab.composite 
Sun Mar 30 14:02:02 2008
@@ -30,6 +30,8 @@
         <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"/>
      </component>   
     
     <component name="BComponent">

Modified: 
incubator/tuscany/java/sca/vtest/java-api/src/test/java/org/apache/tuscany/sca/vtest/javaapi/ReferenceAnnotationTestCase.java
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/vtest/java-api/src/test/java/org/apache/tuscany/sca/vtest/javaapi/ReferenceAnnotationTestCase.java?rev=642818&r1=642817&r2=642818&view=diff
==============================================================================
--- 
incubator/tuscany/java/sca/vtest/java-api/src/test/java/org/apache/tuscany/sca/vtest/javaapi/ReferenceAnnotationTestCase.java
 (original)
+++ 
incubator/tuscany/java/sca/vtest/java-api/src/test/java/org/apache/tuscany/sca/vtest/javaapi/ReferenceAnnotationTestCase.java
 Sun Mar 30 14:02:02 2008
@@ -87,8 +87,7 @@
      * 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>
+     * 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
@@ -138,7 +137,26 @@
      */
     @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
+     * 
+     * @TODO - Would be best to explicitly test "required" attribute
+     */
+    @Test
+    public void atReference4() throws Exception {
+        Assert.assertEquals("BService", a.getB8Name());
+        Assert.assertEquals("BService", a.getB9Name());
     }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to