]> source.dussan.org Git - aspectj.git/commitdiff
tests for pr108425 and pr108104
authoracolyer <acolyer>
Tue, 30 Aug 2005 11:39:23 +0000 (11:39 +0000)
committeracolyer <acolyer>
Tue, 30 Aug 2005 11:39:23 +0000 (11:39 +0000)
tests/bugs150/ShapeCommandMap.java [new file with mode: 0644]
tests/bugs150/pr108245.aj [new file with mode: 0644]
tests/bugs150/pr108425/package1/Bean.java [new file with mode: 0644]
tests/bugs150/pr108425/package2/Bean.java [new file with mode: 0644]
tests/bugs150/pr108425/package2/propertyChanger.java [new file with mode: 0644]
tests/bugs150/pr108425/package3/pr108425.aj [new file with mode: 0644]
tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java
tests/src/org/aspectj/systemtest/ajc150/ajc150.xml

diff --git a/tests/bugs150/ShapeCommandMap.java b/tests/bugs150/ShapeCommandMap.java
new file mode 100644 (file)
index 0000000..38d8208
--- /dev/null
@@ -0,0 +1,73 @@
+/*
+ * Created on Jan 7, 2005
+ *
+ * @author Mohan Radhakrishnan
+ */
+//package com.blueprint.ui.util;
+
+import java.lang.ref.ReferenceQueue;
+import java.lang.ref.SoftReference;
+import java.util.AbstractMap;
+import java.util.HashMap;
+import java.util.LinkedHashSet;
+import java.util.Map;
+import java.util.Set;
+/*
+ * Undo/redo for each shape. This can be used to maintain
+ * a list of changes to rollback. Since the calls to the
+ * model tier are direct and the reverse calls to update the
+ * UI are Commands, this list is for the latter.
+ */
+
+public class ShapeCommandMap<K,V> extends AbstractMap<K,V> {
+       
+       private final Map<K, SoftReference<V>> internalMap = new HashMap<K, SoftReference<V>>();
+       
+       private final ReferenceQueue<V> queue = new ReferenceQueue<V>();
+       
+       public V put( K key, V value ){
+               //remove stale entries
+               SoftReference<V> ref = new SoftReference<V>( value, queue );
+               SoftReference<V> s = internalMap.put( key, ref );
+               return ( s != null ? s.get() : null );
+       }
+       
+       /*public V get( K key ){
+               //remove stale entries
+               SoftReference<V> value = internalMap.get( key );
+               return ( value != null ? value.get() : null );
+       }*/
+       
+       public Set<Entry<K,V>> entrySet(){
+               Set<Entry<K,V>> commands = new LinkedHashSet<Entry<K,V>>();
+               for( final Entry<K,SoftReference<V>> entry : internalMap.entrySet() ){
+                       final V value = entry.getValue().get();
+                       commands.add( new Entry<K,V>(){
+                                                       public K getKey(){
+                                                               return entry.getKey();
+                                                       }
+                                                       public V getValue(){
+                                                               return value;
+                                                       }
+                                                       public V setValue( V v ){
+                                                               entry.setValue( 
+                                                                               new SoftReference<V>( v, queue ) );
+                                                               return value;
+                                                       }
+                                               });
+               }
+               return commands;
+       }
+}
+
+aspect TriggerBug {
+       
+  public void foo() {
+       ShapeCommandMap<String,String> map = new ShapeCommandMap<String,String>();  
+       map.put("hi","there");
+  }
+  
+  before() : execution(* getValue(..)) {
+         System.out.println("a matching call");
+  }
+}
diff --git a/tests/bugs150/pr108245.aj b/tests/bugs150/pr108245.aj
new file mode 100644 (file)
index 0000000..8c19ca4
--- /dev/null
@@ -0,0 +1,40 @@
+import java.io.Serializable;
+import java.lang.annotation.*;
+import java.lang.*;
+
+class Bean implements Serializable{
+       
+       private String name;
+
+       public String getName() {
+               return name;
+       }
+       
+       @propertyChanger()
+       public void setName( String name ) {
+               this.name = name;
+       }
+}
+
+
+
+@Retention( RetentionPolicy.RUNTIME )
+@Target({ ElementType.METHOD })
+@interface propertyChanger {
+}
+
+aspect pr108245 {
+       
+       public static void main(String[] args) {
+               Bean b = new Bean();
+               b.setName("hasBean");
+       }
+       
+       pointcut callSetter( Bean b ) 
+       : call( @propertyChanger * *(..) ) && target( b );
+       
+       before(Bean b) : callSetter(b) {
+               System.out.println("before " + b);
+       }
+       
+}
\ No newline at end of file
diff --git a/tests/bugs150/pr108425/package1/Bean.java b/tests/bugs150/pr108425/package1/Bean.java
new file mode 100644 (file)
index 0000000..c5ded61
--- /dev/null
@@ -0,0 +1,16 @@
+package package1;
+
+import java.io.Serializable;
+
+public class Bean implements Serializable{
+       
+       private String name;
+
+       public String getName() {
+               return name;
+       }
+       
+       public void setName( String name ) {
+               this.name = name;
+       }
+}
\ No newline at end of file
diff --git a/tests/bugs150/pr108425/package2/Bean.java b/tests/bugs150/pr108425/package2/Bean.java
new file mode 100644 (file)
index 0000000..0e00d4d
--- /dev/null
@@ -0,0 +1,17 @@
+package package2;
+
+import java.io.Serializable;
+
+public class Bean implements Serializable{
+       
+       private String name;
+
+       public String getName() {
+               return name;
+       }
+       
+       @propertyChanger()
+       public void setName( String name ) {
+               this.name = name;
+       }
+}
\ No newline at end of file
diff --git a/tests/bugs150/pr108425/package2/propertyChanger.java b/tests/bugs150/pr108425/package2/propertyChanger.java
new file mode 100644 (file)
index 0000000..24cc0c5
--- /dev/null
@@ -0,0 +1,9 @@
+package package2;
+
+import java.lang.annotation.*;
+import java.lang.*;
+
+@Retention( RetentionPolicy.RUNTIME )
+@Target({ ElementType.METHOD })
+public @interface propertyChanger {
+}
\ No newline at end of file
diff --git a/tests/bugs150/pr108425/package3/pr108425.aj b/tests/bugs150/pr108425/package3/pr108425.aj
new file mode 100644 (file)
index 0000000..5530143
--- /dev/null
@@ -0,0 +1,18 @@
+package package3;
+import package2.*;
+
+public aspect pr108425 {
+       
+       public static void main(String[] args) {
+               Bean b = new Bean();
+               b.setName("hasBean");
+       }
+       
+       pointcut callSetter( Bean b ) 
+       : call( @propertyChanger * *(..) ) && target( b );
+       
+       before(Bean b) : callSetter(b) {
+               System.out.println("before " + b);
+       }
+       
+}
\ No newline at end of file
index c442b9724926e5c438ffb7d14bcff91abc973298..aba91b617a0bb111a055f9ef0bac424bff70c1ce 100644 (file)
@@ -289,6 +289,14 @@ public class Ajc150Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
   public void testSignatureMatchingInMultipleOverrideScenario() {
          runTest("signature matching in override scenario");
   }
+  public void testWildcardAnnotationMatching_pr108245() {
+         runTest("wildcard annotation matching - pr108245");
+  }
+  
+  public void testInnerTypesAndTypeVariables() {
+         runTest("inner types and type variables");
+  }
   
   // helper methods.....
   
index 3cebcd13d0602a74b9e1c0323064f98d7d815d3c..ca204a231d8588d9bc0892c0f5b6946e9a23987b 100644 (file)
             <message kind="warning" line = "21" text="servlet request"></message>
         </compile>
     </ajc-test>
+
+    <ajc-test dir="bugs150/pr108425" pr="108245" title="wildcard annotation matching - pr108245">
+        <compile files="package1/Bean.java,package2/Bean.java,package2/propertyChanger.java,package3/pr108425.aj" options="-1.5">
+        </compile>
+    </ajc-test>
+           
+    <ajc-test dir="bugs150/" pr="108104" title="inner types and type variables">
+        <compile files="ShapeCommandMap.java" options="-1.5">
+        </compile>
+    </ajc-test>
            
     <ajc-test dir="bugs150/pr106130" pr="106130" title="test weaving with > 256 locals">
         <compile files="AroundLotsOfVars.java LotsOfVars.java" options="-preserveAllLocals"/>