diff options
author | aclement <aclement> | 2005-10-27 10:27:16 +0000 |
---|---|---|
committer | aclement <aclement> | 2005-10-27 10:27:16 +0000 |
commit | 81f8e0326c6db86ea236e281e8a58ac62d21a702 (patch) | |
tree | e7c86ab4101709ee22a31384a289101065dbff0c | |
parent | 29bcce87bdacd80a3609410f3e1bfe198c11d050 (diff) | |
download | aspectj-81f8e0326c6db86ea236e281e8a58ac62d21a702.tar.gz aspectj-81f8e0326c6db86ea236e281e8a58ac62d21a702.zip |
pr113630: testcode
-rw-r--r-- | tests/bugs150/pr113630/Bean.java | 17 | ||||
-rw-r--r-- | tests/bugs150/pr113630/BeanSupportAspectj.aj | 10 | ||||
-rw-r--r-- | tests/bugs150/pr113630/BeanTestCase.java | 34 | ||||
-rw-r--r-- | tests/bugs150/pr113630/PropertySupportAspect5.aj | 90 | ||||
-rw-r--r-- | tests/bugs150/pr113630/case1/Bean.java | 17 | ||||
-rw-r--r-- | tests/bugs150/pr113630/case1/BeanTestCase.java | 24 | ||||
-rw-r--r-- | tests/bugs150/pr113630/case1/PropertySupportAspect5.aj | 24 | ||||
-rw-r--r-- | tests/bugs150/pr113630/case1/javaBean.java (renamed from tests/bugs150/pr113630/javaBean.java) | 1 | ||||
-rw-r--r-- | tests/bugs150/pr113630/case1/propertyChanger.java (renamed from tests/bugs150/pr113630/propertyChanger.java) | 1 | ||||
-rw-r--r-- | tests/bugs150/pr113630/case2/Bean.java | 17 | ||||
-rw-r--r-- | tests/bugs150/pr113630/case2/BeanTestCase.java | 24 | ||||
-rw-r--r-- | tests/bugs150/pr113630/case2/PropertySupportAspect5.aj | 24 | ||||
-rw-r--r-- | tests/bugs150/pr113630/case2/javaBean.java | 8 | ||||
-rw-r--r-- | tests/bugs150/pr113630/case2/propertyChanger.java | 9 |
14 files changed, 147 insertions, 153 deletions
diff --git a/tests/bugs150/pr113630/Bean.java b/tests/bugs150/pr113630/Bean.java deleted file mode 100644 index fafad796c..000000000 --- a/tests/bugs150/pr113630/Bean.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.blueprint.util.aspectj5.test; - -import java.io.Serializable; - -@javaBean() -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/pr113630/BeanSupportAspectj.aj b/tests/bugs150/pr113630/BeanSupportAspectj.aj deleted file mode 100644 index 8262ad6bf..000000000 --- a/tests/bugs150/pr113630/BeanSupportAspectj.aj +++ /dev/null @@ -1,10 +0,0 @@ -/** - * - */ -package com.blueprint.util.aspectj5.test; - -import com.blueprint.util.aspectj5.test.PropertySupportAspect5.PropertySupport; - -public aspect BeanSupportAspectj { - declare parents: @javaBean * implements PropertySupport; -} diff --git a/tests/bugs150/pr113630/BeanTestCase.java b/tests/bugs150/pr113630/BeanTestCase.java deleted file mode 100644 index 0df22721a..000000000 --- a/tests/bugs150/pr113630/BeanTestCase.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.blueprint.util.aspectj5.test; - -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; - -import junit.framework.TestCase; - -public class BeanTestCase extends TestCase implements PropertyChangeListener{ - - public void setUp() throws Exception{ - super.setUp(); - } - - public void TearDown() throws Exception{ - super.setUp(); - } - - public void propertyChange(PropertyChangeEvent e){ - System.out.println("Property [" + e.getPropertyName() + "[ changed from " + - e.getOldValue() + " to " + e.getNewValue() ); - } - - public static void main(String [] argv) { - new BeanTestCase().testPropertyChange(); - } - public void testPropertyChange(){ - Bean b = new Bean(); - b.addPropertyChangeListener( "name", this ); - b.setName( "Test" ); - assertEquals( b.getName() , "Test" ); - b.setName( "Test1" ); - assertEquals( b.getName() , "Test1" ); - } -} diff --git a/tests/bugs150/pr113630/PropertySupportAspect5.aj b/tests/bugs150/pr113630/PropertySupportAspect5.aj deleted file mode 100644 index 10e4388c5..000000000 --- a/tests/bugs150/pr113630/PropertySupportAspect5.aj +++ /dev/null @@ -1,90 +0,0 @@ -package com.blueprint.util.aspectj5.test; - -import java.beans.PropertyChangeListener; -import java.beans.PropertyChangeSupport; -import java.lang.reflect.Field; -import org.aspectj.lang.Signature; - -public aspect PropertySupportAspect5 { - - PropertyChangeSupport PropertySupport.support = new PropertyChangeSupport(this); - - public interface PropertySupport{ - public void addPropertyChangeListener( PropertyChangeListener listener ); - public void addPropertyChangeListener( String propertyName, - PropertyChangeListener listener ); - public void removePropertyChangeListener( String propertyName, - PropertyChangeListener listener ); - public void removePropertyChangeListener( PropertyChangeListener listener ); - public void hasListeners( String propertyName ); - public void firePropertyChange( Bean b, - String property, - String oldval, - String newval ); - } - - public void PropertySupport.addPropertyChangeListener(PropertyChangeListener listener){ - support.addPropertyChangeListener(listener); - } - - public void PropertySupport.addPropertyChangeListener( String propertyName, - PropertyChangeListener listener){ - - support.addPropertyChangeListener(propertyName, listener); - } - - public void PropertySupport.removePropertyChangeListener( String propertyName, - PropertyChangeListener listener) { - support.removePropertyChangeListener(propertyName, listener); - } - - public void PropertySupport.removePropertyChangeListener(PropertyChangeListener listener) { - support.removePropertyChangeListener(listener); - } - - public void PropertySupport.hasListeners(String propertyName) { - support.hasListeners(propertyName); - } - - pointcut callSetter( Bean b ) - : call( @propertyChanger * *(..) ) && target( b ); - - void around( Bean b ) : callSetter( b ) { - String propertyName = getField( thisJoinPointStaticPart.getSignature() ). - getName(); - System.out.println( "The property is [" + propertyName + "]" ); - String oldValue = b.getName(); - proceed( b ); - b.firePropertyChange( b, propertyName, oldValue, b.getName()); - } - - private Field getField( Signature signature ){ - Field field = null; - System.out.println( "Getting the field name of [" +signature.getName() + "]" ); - - try{ - String methodName = signature.getName(); - field = signature.getDeclaringType(). - getDeclaredField( methodName. - substring( 3, - methodName.length() ). - toLowerCase()); - field.setAccessible(true); - }catch( NoSuchFieldException nsfe ){ - nsfe.printStackTrace(); - } - return field; - } - - public void PropertySupport.firePropertyChange( Bean b, - String property, - String oldval, - String newval) { - System.out.println( "The property is [" + property + "]"); - System.out.println( "The old value is [" + oldval + "]"); - System.out.println( "The new value is [" + newval + "]"); - b.support.firePropertyChange( property, - ( oldval == null ) ? oldval : new String(oldval), - new String(newval)); - } -}
\ No newline at end of file diff --git a/tests/bugs150/pr113630/case1/Bean.java b/tests/bugs150/pr113630/case1/Bean.java new file mode 100644 index 000000000..a0fee44fd --- /dev/null +++ b/tests/bugs150/pr113630/case1/Bean.java @@ -0,0 +1,17 @@ + +import java.io.Serializable; + +@javaBean() +public class Bean implements Serializable{ + + private String name; + + public String getName() { + return name; + } + + @propertyChanger() + public void setName( String n ) { + name = n; + } +} diff --git a/tests/bugs150/pr113630/case1/BeanTestCase.java b/tests/bugs150/pr113630/case1/BeanTestCase.java new file mode 100644 index 000000000..3f41ba44a --- /dev/null +++ b/tests/bugs150/pr113630/case1/BeanTestCase.java @@ -0,0 +1,24 @@ + +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; + +public class BeanTestCase implements PropertyChangeListener{ + + public void propertyChange(PropertyChangeEvent e){ + System.out.println("Property [" + e.getPropertyName() + "[ changed from " + + e.getOldValue() + " to " + e.getNewValue() ); + } + + public static void main(String [] argv) { + new BeanTestCase().testPropertyChange(); + } + + public void testPropertyChange(){ + Bean b = new Bean(); + b.addPropertyChangeListener( "name", this ); + b.setName( "Test" ); + if (!b.getName().equals("Test")) throw new RuntimeException(""); + b.setName( "Test1" ); + if (!b.getName().equals("Test1")) throw new RuntimeException(""); + } +} diff --git a/tests/bugs150/pr113630/case1/PropertySupportAspect5.aj b/tests/bugs150/pr113630/case1/PropertySupportAspect5.aj new file mode 100644 index 000000000..0e68af206 --- /dev/null +++ b/tests/bugs150/pr113630/case1/PropertySupportAspect5.aj @@ -0,0 +1,24 @@ + +import java.beans.PropertyChangeListener; +import java.beans.PropertyChangeSupport; +import java.lang.reflect.Field; +import org.aspectj.lang.Signature; + +public aspect PropertySupportAspect5 { + + declare parents: @javaBean * implements PropertySupport; + + public interface PropertySupport{ } + + public void PropertySupport.addPropertyChangeListener(PropertyChangeListener listener){ } + + public void PropertySupport.addPropertyChangeListener( String propertyName,PropertyChangeListener listener){ } + + public void PropertySupport.removePropertyChangeListener( String propertyName, PropertyChangeListener listener) { } + + public void PropertySupport.removePropertyChangeListener(PropertyChangeListener listener) { } + + public void PropertySupport.hasListeners(String propertyName) { } + + public void PropertySupport.firePropertyChange( Bean b, String property, String oldval, String newval) { } +} diff --git a/tests/bugs150/pr113630/javaBean.java b/tests/bugs150/pr113630/case1/javaBean.java index ae2663ecc..5f73881eb 100644 --- a/tests/bugs150/pr113630/javaBean.java +++ b/tests/bugs150/pr113630/case1/javaBean.java @@ -1,4 +1,3 @@ -package com.blueprint.util.aspectj5.test; import java.lang.annotation.*; import java.lang.*; diff --git a/tests/bugs150/pr113630/propertyChanger.java b/tests/bugs150/pr113630/case1/propertyChanger.java index 9fb87b5b6..2f334c8de 100644 --- a/tests/bugs150/pr113630/propertyChanger.java +++ b/tests/bugs150/pr113630/case1/propertyChanger.java @@ -1,4 +1,3 @@ -package com.blueprint.util.aspectj5.test; import java.lang.annotation.*; import java.lang.*; diff --git a/tests/bugs150/pr113630/case2/Bean.java b/tests/bugs150/pr113630/case2/Bean.java new file mode 100644 index 000000000..a0fee44fd --- /dev/null +++ b/tests/bugs150/pr113630/case2/Bean.java @@ -0,0 +1,17 @@ + +import java.io.Serializable; + +@javaBean() +public class Bean implements Serializable{ + + private String name; + + public String getName() { + return name; + } + + @propertyChanger() + public void setName( String n ) { + name = n; + } +} diff --git a/tests/bugs150/pr113630/case2/BeanTestCase.java b/tests/bugs150/pr113630/case2/BeanTestCase.java new file mode 100644 index 000000000..3f41ba44a --- /dev/null +++ b/tests/bugs150/pr113630/case2/BeanTestCase.java @@ -0,0 +1,24 @@ + +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; + +public class BeanTestCase implements PropertyChangeListener{ + + public void propertyChange(PropertyChangeEvent e){ + System.out.println("Property [" + e.getPropertyName() + "[ changed from " + + e.getOldValue() + " to " + e.getNewValue() ); + } + + public static void main(String [] argv) { + new BeanTestCase().testPropertyChange(); + } + + public void testPropertyChange(){ + Bean b = new Bean(); + b.addPropertyChangeListener( "name", this ); + b.setName( "Test" ); + if (!b.getName().equals("Test")) throw new RuntimeException(""); + b.setName( "Test1" ); + if (!b.getName().equals("Test1")) throw new RuntimeException(""); + } +} diff --git a/tests/bugs150/pr113630/case2/PropertySupportAspect5.aj b/tests/bugs150/pr113630/case2/PropertySupportAspect5.aj new file mode 100644 index 000000000..0e68af206 --- /dev/null +++ b/tests/bugs150/pr113630/case2/PropertySupportAspect5.aj @@ -0,0 +1,24 @@ + +import java.beans.PropertyChangeListener; +import java.beans.PropertyChangeSupport; +import java.lang.reflect.Field; +import org.aspectj.lang.Signature; + +public aspect PropertySupportAspect5 { + + declare parents: @javaBean * implements PropertySupport; + + public interface PropertySupport{ } + + public void PropertySupport.addPropertyChangeListener(PropertyChangeListener listener){ } + + public void PropertySupport.addPropertyChangeListener( String propertyName,PropertyChangeListener listener){ } + + public void PropertySupport.removePropertyChangeListener( String propertyName, PropertyChangeListener listener) { } + + public void PropertySupport.removePropertyChangeListener(PropertyChangeListener listener) { } + + public void PropertySupport.hasListeners(String propertyName) { } + + public void PropertySupport.firePropertyChange( Bean b, String property, String oldval, String newval) { } +} diff --git a/tests/bugs150/pr113630/case2/javaBean.java b/tests/bugs150/pr113630/case2/javaBean.java new file mode 100644 index 000000000..c7c83fd79 --- /dev/null +++ b/tests/bugs150/pr113630/case2/javaBean.java @@ -0,0 +1,8 @@ + +import java.lang.annotation.*; +import java.lang.*; + +@Retention(RetentionPolicy.CLASS) +@Target({ ElementType.TYPE }) +public @interface javaBean { +} diff --git a/tests/bugs150/pr113630/case2/propertyChanger.java b/tests/bugs150/pr113630/case2/propertyChanger.java new file mode 100644 index 000000000..2f334c8de --- /dev/null +++ b/tests/bugs150/pr113630/case2/propertyChanger.java @@ -0,0 +1,9 @@ + +import java.lang.annotation.*; +import java.lang.*; + +@Retention( RetentionPolicy.RUNTIME ) +@Target({ ElementType.METHOD }) +public @interface propertyChanger { +} + |