Author: kwilliams
Date: Sat Mar 29 15:47:17 2008
New Revision: 642635

URL: http://svn.apache.org/viewvc?rev=642635&view=rev
Log:
Added more @Reference vTest cases

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=642635&r1=642634&r2=642635&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
 Sat Mar 29 15:47:17 2008
@@ -28,5 +28,11 @@
     public String getB1Name();
     public String getB2Name();
     public String getB3Name();
+    public String getB4Name();
+    public String getB5Name();
+    public String getB6Name();
+    public String getB7Name();
 
+    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=642635&r1=642634&r2=642635&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
 Sat Mar 29 15:47:17 2008
@@ -29,19 +29,42 @@
 
     @Reference
     protected BService b1; // field injection
-    
+
     protected BService b2; // injected via constructor parameter
-   
-    protected BService b3; // injected via setter
 
-    public AServiceImpl(@Reference(name = "b2") BService b2) {
+    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)
+
+    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;
+        this.b3 = b3;
+    }
+
+    public void setB6(BService b6) {
+        this.b6 = b6;
+    }
+
+    @Reference
+    public void setB7(BService b7) {
+        b7SetterCalled = true;
+        this.b7 = b7;
     }
 
     public String getName() {
@@ -51,13 +74,32 @@
     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 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=642635&r1=642634&r2=642635&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 
Sat Mar 29 15:47:17 2008
@@ -26,7 +26,11 @@
         <reference name="b1" target="BComponent"/>             
         <reference name="b2" target="BComponent"/>             
         <reference name="b3" target="BComponent"/>
-    </component>   
+        <reference name="b4" target="BComponent"/>
+        <reference name="b5" target="BComponent"/>
+        <reference name="b6" target="BComponent"/>
+        <reference name="b7" target="BComponent"/>
+     </component>   
     
     <component name="BComponent">
         <implementation.java 
class="org.apache.tuscany.sca.vtest.javaapi.impl.BServiceImpl"/>

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=642635&r1=642634&r2=642635&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
 Sat Mar 29 15:47:17 2008
@@ -29,13 +29,14 @@
 import org.junit.Test;
 
 /**
- * 
+ * This test class tests the "@Reference" annotation described in section
+ * 1.8.1.4
  */
 public class ReferenceAnnotationTestCase {
 
     protected static SCADomain domain;
-    protected static AService a;
     protected static String compositeName = "ab.composite";
+    protected static AService a;
 
     @BeforeClass
     public static void init() throws Exception {
@@ -43,6 +44,7 @@
             System.out.println("Setting up");
             domain = SCADomain.newInstance(compositeName);
             a = domain.getService(AService.class, "AComponent");
+
         } catch (Exception ex) {
             ex.printStackTrace();
         }
@@ -57,11 +59,12 @@
 
     }
 
-
+    /**
+     * Temporary test unrelated to spec test effort. Remove after resolution of
+     */
     @Test
     @Ignore
-    //Temporary test unrelated to spec test effort.  Remove after resolution 
of 
-    //JIRA T-2145
+    // JIRA T-2145
     public void bogusComponentName() throws Exception {
         SCADomain tempDomain = SCADomain.newInstance(compositeName);
         try {
@@ -77,20 +80,65 @@
 
     }
 
-
     /**
-     * This tests the use of the three usages of the @Reference annotation
-     * B1 is injected via field injection
-     * B2 is injected via constructor parameter
+     * 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 atReference() throws Exception {
-        
+    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
+    @Ignore
+    // (Jira Tuscany-2165)
+    public void atReference2() throws Exception {
+
+        Assert.assertEquals("BService", a.getB4Name());
+        try {
+            a.getB5Name();
+            fail("getB5Name expected to fail with NPE");
+        } catch (NullPointerException e) {
+        }
+        Assert.assertEquals("BService", a.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());
+    }
 }



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

Reply via email to