]> source.dussan.org Git - aspectj.git/commitdiff
more tests for @DeclareParents - building it in pieces.
authoraclement <aclement>
Wed, 29 Mar 2006 12:06:04 +0000 (12:06 +0000)
committeraclement <aclement>
Wed, 29 Mar 2006 12:06:04 +0000 (12:06 +0000)
tests/bugs151/atDecp/case3/MainClass.java [new file with mode: 0644]
tests/bugs151/atDecp/case3/Mood.java [new file with mode: 0644]
tests/bugs151/atDecp/case3/Moody.java [new file with mode: 0644]
tests/bugs151/atDecp/case4/AnnotationMoodImplementor.java [new file with mode: 0644]
tests/bugs151/atDecp/case4/MainClass.java [new file with mode: 0644]
tests/bugs151/atDecp/case4/Mood.java [new file with mode: 0644]
tests/bugs151/atDecp/case4/Moody.java [new file with mode: 0644]
tests/bugs151/atDecp/case4/MoodyImpl.java [new file with mode: 0644]
tests/bugs151/atDecp/case4/TheAspect.java [new file with mode: 0644]
tests/src/org/aspectj/systemtest/ajc151/Ajc151Tests.java
tests/src/org/aspectj/systemtest/ajc151/ajc151.xml

diff --git a/tests/bugs151/atDecp/case3/MainClass.java b/tests/bugs151/atDecp/case3/MainClass.java
new file mode 100644 (file)
index 0000000..f4212e9
--- /dev/null
@@ -0,0 +1,37 @@
+package theapp;
+
+import org.aspectj.lang.annotation.Aspect;
+import org.aspectj.lang.annotation.DeclareParents;
+
+import moody.*;
+
+class AnnotationMoodImplementor { }
+
+@Aspect
+class AnnotationMoodIndicator {
+
+   public static class MoodyImpl implements Moody {
+      private Mood mood = Mood.HAPPY;
+
+      public Mood getMood() { return mood; }
+      public void setMood(Mood mood) { this.mood = mood; }
+   }
+
+   @DeclareParents(value="theapp.AnnotationMoodImplementor",defaultImpl=MoodyImpl.class)
+   private Moody implementedInterface;
+}
+
+
+
+public class MainClass {
+  public static void main(String[] args) {
+    AnnotationMoodImplementor ami0 = new AnnotationMoodImplementor();
+    AnnotationMoodImplementor ami1 = new AnnotationMoodImplementor();
+
+    System.err.println("ami0's mood is " + ((Moody) ami0).getMood());
+    ((Moody) ami1).setMood(Mood.JOLLY);
+    System.err.println("ami1's mood is now " + ((Moody) ami1).getMood());
+    System.err.println("ami0's mood is still " + ((Moody) ami0).getMood());
+  }
+}
+
diff --git a/tests/bugs151/atDecp/case3/Mood.java b/tests/bugs151/atDecp/case3/Mood.java
new file mode 100644 (file)
index 0000000..9d0591b
--- /dev/null
@@ -0,0 +1,3 @@
+package moody;
+
+public enum Mood { HAPPY, SAD, JOLLY, GRUMPY }
diff --git a/tests/bugs151/atDecp/case3/Moody.java b/tests/bugs151/atDecp/case3/Moody.java
new file mode 100644 (file)
index 0000000..13353c7
--- /dev/null
@@ -0,0 +1,6 @@
+package moody;
+
+public interface Moody {
+  Mood getMood();
+  void setMood(Mood mood);
+}
diff --git a/tests/bugs151/atDecp/case4/AnnotationMoodImplementor.java b/tests/bugs151/atDecp/case4/AnnotationMoodImplementor.java
new file mode 100644 (file)
index 0000000..548b1fa
--- /dev/null
@@ -0,0 +1,3 @@
+package theapp;
+
+public class AnnotationMoodImplementor {}
diff --git a/tests/bugs151/atDecp/case4/MainClass.java b/tests/bugs151/atDecp/case4/MainClass.java
new file mode 100644 (file)
index 0000000..40a5456
--- /dev/null
@@ -0,0 +1,19 @@
+package theapp;
+
+import org.aspectj.lang.annotation.Aspect;
+import org.aspectj.lang.annotation.DeclareParents;
+
+import moody.*;
+
+public class MainClass {
+  public static void main(String[] args) {
+    AnnotationMoodImplementor ami0 = new AnnotationMoodImplementor();
+    AnnotationMoodImplementor ami1 = new AnnotationMoodImplementor();
+
+    System.err.println("ami0's mood is " + ((Moody) ami0).getMood());
+    ((Moody) ami1).setMood(Mood.JOLLY);
+    System.err.println("ami1's mood is now " + ((Moody) ami1).getMood());
+    System.err.println("ami0's mood is still " + ((Moody) ami0).getMood());
+  }
+}
+
diff --git a/tests/bugs151/atDecp/case4/Mood.java b/tests/bugs151/atDecp/case4/Mood.java
new file mode 100644 (file)
index 0000000..9d0591b
--- /dev/null
@@ -0,0 +1,3 @@
+package moody;
+
+public enum Mood { HAPPY, SAD, JOLLY, GRUMPY }
diff --git a/tests/bugs151/atDecp/case4/Moody.java b/tests/bugs151/atDecp/case4/Moody.java
new file mode 100644 (file)
index 0000000..13353c7
--- /dev/null
@@ -0,0 +1,6 @@
+package moody;
+
+public interface Moody {
+  Mood getMood();
+  void setMood(Mood mood);
+}
diff --git a/tests/bugs151/atDecp/case4/MoodyImpl.java b/tests/bugs151/atDecp/case4/MoodyImpl.java
new file mode 100644 (file)
index 0000000..01d926d
--- /dev/null
@@ -0,0 +1,10 @@
+package theapp;
+
+import moody.*;
+
+public class MoodyImpl implements Moody {
+  private Mood mood = Mood.HAPPY;
+
+  public Mood getMood() { return mood; }
+  public void setMood(Mood mood) { this.mood = mood; }
+}
diff --git a/tests/bugs151/atDecp/case4/TheAspect.java b/tests/bugs151/atDecp/case4/TheAspect.java
new file mode 100644 (file)
index 0000000..daeb0e1
--- /dev/null
@@ -0,0 +1,13 @@
+package theapp;
+
+import org.aspectj.lang.annotation.Aspect;
+import org.aspectj.lang.annotation.DeclareParents;
+
+import moody.Moody;
+
+@Aspect
+class AnnotationMoodIndicator {
+   @DeclareParents(value="theapp.AnnotationMoodImplementor",defaultImpl=MoodyImpl.class)
+   private Moody implementedInterface;
+}
+
index a5447eaabd10e981208d3e81c994484127624029..9604bab50dfb6e01ac782ca7a9920bb7e9c5460b 100644 (file)
@@ -29,6 +29,8 @@ public class Ajc151Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
   // Some @DeclareParents testing
   public void testAtDecp_1() { runTest("atDecp - simple");}
   public void testAtDecp_2() { runTest("atDecp - annotation");}
+  public void testAtDecp_3() { runTest("atDecp - binary interface");}
+  public void testAtDecp_4() { runTest("atDecp - binary interface - 2");}
 
   public void testAnnotationsAndItds_pr98901() { runTest("annotations and itds");}
   public void testAnnotationsAndItds_pr98901_2() { runTest("annotations and itds - 2");}
index a9ec5f59bb3f3201ef90a32f8a26cb60c71e3625..43fb2813d01f23a782b38e8d59348db1879f1964 100644 (file)
       </run>
     </ajc-test>
     
+    <!-- when interface is binary -->
+    <ajc-test dir="bugs151/atDecp/case3" title="atDecp - binary interface">
+      <compile files="Mood.java,Moody.java" outjar="moody.jar" options="-1.5"/>
+      <compile files="MainClass.java" classpath="moody.jar" options="-1.5 -showWeaveInfo">
+        <message kind="weave" text="Extending interface set for type 'theapp.AnnotationMoodImplementor' (MainClass.java) to include 'moody.Moody' (MainClass.java)"/>
+        <message kind="weave" text="Type 'theapp.AnnotationMoodImplementor' (MainClass.java) has intertyped method from 'theapp.AnnotationMoodIndicator' (MainClass.java:'moody.Mood moody.Moody.getMood()')"/>
+        <message kind="weave" text="Type 'theapp.AnnotationMoodImplementor' (MainClass.java) has intertyped method from 'theapp.AnnotationMoodIndicator' (MainClass.java:'void moody.Moody.setMood(moody.Mood)')"/>
+      </compile>
+      <run class="theapp.MainClass">
+         <stderr>
+           <line text="ami0's mood is HAPPY"/>
+           <line text="ami1's mood is now JOLLY"/>
+           <line text="ami0's mood is still HAPPY"/>
+         </stderr>
+      </run>
+    </ajc-test>
+    
+    <!-- when interface is binary and implementation is not an inner  -->
+    <ajc-test dir="bugs151/atDecp/case4" title="atDecp - binary interface - 2">
+      <compile files="Mood.java,Moody.java" outjar="moody.jar" options="-1.5"/>
+      <compile files="MainClass.java,AnnotationMoodImplementor.java,TheAspect.java,MoodyImpl.java" classpath="moody.jar" options="-1.5 -showWeaveInfo">
+        <message kind="weave" text="Extending interface set for type 'theapp.AnnotationMoodImplementor' (AnnotationMoodImplementor.java) to include 'moody.Moody' (TheAspect.java)"/>
+        <message kind="weave" text="Type 'theapp.AnnotationMoodImplementor' (AnnotationMoodImplementor.java) has intertyped method from 'theapp.AnnotationMoodIndicator' (TheAspect.java:'moody.Mood moody.Moody.getMood()')"/>
+        <message kind="weave" text="Type 'theapp.AnnotationMoodImplementor' (AnnotationMoodImplementor.java) has intertyped method from 'theapp.AnnotationMoodIndicator' (TheAspect.java:'void moody.Moody.setMood(moody.Mood)')"/>
+      </compile>
+      <run class="theapp.MainClass">
+         <stderr>
+           <line text="ami0's mood is HAPPY"/>
+           <line text="ami1's mood is now JOLLY"/>
+           <line text="ami0's mood is still HAPPY"/>
+         </stderr>
+      </run>
+    </ajc-test>
     
     <!-- atDecp end -->