]> source.dussan.org Git - aspectj.git/commitdiff
declaremixin: testcode
authoraclement <aclement>
Wed, 4 Mar 2009 00:54:28 +0000 (00:54 +0000)
committeraclement <aclement>
Wed, 4 Mar 2009 00:54:28 +0000 (00:54 +0000)
tests/src/org/aspectj/systemtest/ajc164/DeclareMixinTests.java
tests/src/org/aspectj/systemtest/ajc164/declareMixin.xml

index af40353c3cf927f09a0a65b19062df32399a8a6d..c7e26efa3d3be1f20e7078346fae8888bddcd94c 100644 (file)
@@ -25,14 +25,62 @@ import org.aspectj.testing.XMLBasedAjcTestCase;
  * <ul>
  * <li>model relationships
  * <li>incremental compilation
+ * <li>ltw
+ * <li>generic factory methods
+ * <li>showWeaveInfo
+ * <li>Clashing with existing methods
+ * <li>varying parameter type on the factory method
+ * <li>See CaseF - what if mixin target is not assignable to the parameter type? create cast?
  * </ul>
  * 
  * @author Andy Clement
  */
 public class DeclareMixinTests extends org.aspectj.testing.XMLBasedAjcTestCase {
 
-       public void testSimpleCase() {
-       //      runTest("simple case");
+       // Very basics with a simple static factory method
+       public void testCaseA() {
+               runTest("casea");
+       }
+
+       // non static factory method, will need aspectOf() calling on
+       // the aspect before the factory is called
+       public void testCaseB() {
+               runTest("caseb");
+       }
+
+       // factory method takes the object for which the delegate exists
+       public void testCaseC() {
+               runTest("casec");
+       }
+
+       // factory method is non static and takes the object for which the delegate is being created
+       public void testCaseD() {
+               runTest("cased");
+       }
+
+       // multiple instances causing factory invocation multiple times (but is cached)
+       public void testCaseE() {
+               runTest("casee");
+       }
+
+       // Factory method directly takes the type specified in the Mixin target (strongly typed)
+       public void testCaseF() {
+               runTest("casef");
+       }
+
+       // targeting multiple types from the Mixin
+       public void testCaseG() {
+               runTest("caseg");
+       }
+
+       // Null value for mixin target pattern
+       public void testCaseH() {
+               runTest("caseh");
+       }
+
+       // Invalid interfaces annotation value entries
+       public void testCaseI() {
+               runTest("casei");
        }
 
        // --
index 67148f9082daed4ad082d14e8cc635596f408c85..a9ed438ba7df5b05088901f659f1677c668948a2 100644 (file)
@@ -2,9 +2,92 @@
 
 <suite>
    
-   <ajc-test dir="features164/declareMixin" title="simple scenario">
+   <ajc-test dir="features164/declareMixin" title="casea">
      <compile files="CaseA.java" options="-1.5"/>
-     <run class="CaseA"/>
+     <run class="CaseA">
+       <stdout>
+         <line text="Delegate factory invoked"/>
+         <line text="methodOne running"/>
+       </stdout>
+     </run>
+   </ajc-test>
+   
+   <ajc-test dir="features164/declareMixin" title="caseb">
+     <compile files="CaseB.java" options="-1.5"/>
+     <run class="CaseB">
+       <stdout>
+         <line text="Delegate factory invoked"/>
+         <line text="methodOne running"/>
+       </stdout>
+     </run>
+   </ajc-test>
+   
+   <ajc-test dir="features164/declareMixin" title="casec">
+     <compile files="CaseC.java" options="-1.5"/>
+     <run class="CaseC">
+       <stdout>
+         <line text="Delegate factory invoked for CaseC instance"/>
+         <line text="methodOne running"/>
+       </stdout>
+     </run>
+   </ajc-test>
+   
+   <ajc-test dir="features164/declareMixin" title="cased">
+     <compile files="CaseD.java" options="-1.5"/>
+     <run class="CaseD">
+       <stdout>
+         <line text="Delegate factory invoked for CaseD instance"/>
+         <line text="methodOne running"/>
+       </stdout>
+     </run>
+   </ajc-test>
+   
+   <ajc-test dir="features164/declareMixin" title="casee">
+     <compile files="CaseE.java" options="-1.5"/>
+     <run class="CaseE">
+       <stdout>
+         <line text="Delegate factory invoked for CaseE instance: a"/>
+         <line text="methodOne running on CaseE instance: a"/>
+         <line text="Delegate factory invoked for CaseE instance: b"/>
+         <line text="methodTwo running on CaseE instance: b"/>
+         <line text="methodOne running on CaseE instance: a"/>
+         <line text="methodTwo running on CaseE instance: b"/>
+       </stdout>
+     </run>
+   </ajc-test>
+   
+   <ajc-test dir="features164/declareMixin" title="casef">
+     <compile files="CaseF.java" options="-1.5"/>
+     <run class="CaseF">
+       <stdout>
+         <line text="Delegate factory invoked for CaseF instance"/>
+         <line text="methodOne running"/>
+       </stdout>
+     </run>
+   </ajc-test>
+   
+   <ajc-test dir="features164/declareMixin" title="caseg">
+     <compile files="CaseG.java" options="-1.5"/>
+     <run class="CaseG">
+       <stdout>
+         <line text="Delegate factory invoked for instance of A"/>
+         <line text="run() executing on behalf of A"/>
+         <line text="Delegate factory invoked for instance of B"/>
+         <line text="run() executing on behalf of B"/>
+       </stdout>
+     </run>
+   </ajc-test>
+   
+   <ajc-test dir="features164/declareMixin" title="caseh">
+     <compile files="CaseH.java" options="-1.5">
+         <message kind="error" text="The value for annotation attribute DeclareMixin"/>
+     </compile>
+   </ajc-test>
+   
+   <ajc-test dir="features164/declareMixin" title="casei">
+     <compile files="CaseI.java" options="-1.5">
+         <message kind="error" text="Types listed in the 'interfaces'"/>
+     </compile>
    </ajc-test>
         
 </suite>
\ No newline at end of file