]> source.dussan.org Git - aspectj.git/commitdiff
testcode for 157054 - random matching (!!) with pointcuts matching on get of annotate...
authoraclement <aclement>
Thu, 14 Sep 2006 13:48:06 +0000 (13:48 +0000)
committeraclement <aclement>
Thu, 14 Sep 2006 13:48:06 +0000 (13:48 +0000)
tests/multiIncremental/PR157054/base/dash/obtain/Obtain.java [new file with mode: 0644]
tests/multiIncremental/PR157054/base/dash/obtain/ObtainStaticAspect.aj [new file with mode: 0644]
tests/multiIncremental/PR157054/base/dash/obtain/ObtainStaticTest.java [new file with mode: 0644]
tests/multiIncremental/PR157054/base/dash/obtain/ObtainStaticTestClass.java [new file with mode: 0644]
tests/multiIncremental/PR157054/inc1/dash/obtain/ObtainStaticTest.java [new file with mode: 0644]

diff --git a/tests/multiIncremental/PR157054/base/dash/obtain/Obtain.java b/tests/multiIncremental/PR157054/base/dash/obtain/Obtain.java
new file mode 100644 (file)
index 0000000..64e3b79
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+* Copyright (C) 2005  John D. Heintz
+* 
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU Library General Public License
+* as published by the Free Software Foundation; either version 2.1
+* of the License.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+* GNU Library General Public License for more details.
+*
+* John D. Heintz can be reached at: jheintz@pobox.com 
+*/
+package dash.obtain;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+/**
+ * The @Obtain annotation provides a marker for fields that will be "obtain"-ed at 
+ * runtime based on lookups to the ProviderService service. See the ObtainLookup class 
+ * for documentation of the details about the annotated field that is provided to the 
+ * Provider service.  
+ * 
+ * <p>An AspectJ Aspect is used to control the interception of field accesses and 
+ * provide the binding behavior into the ProviderService service. The AspectJ pointcut
+ * used is:
+ * <pre>pointcut obtain_get(): get(@Obtain * *);</pre>
+ * 
+ * <p>If the ProviderService service fails to correctly Obtain a target object 
+ * a NullPointerException will be thrown into the code accessing the field.
+ * 
+ * <p>A single field will be obtained once per instance.
+ * 
+ * @see dash.obtain.provider.ProviderService
+ * @see dash.obtain.provider.ObtainLookup
+ * @throws java.lang.NullPointerException
+ * @author jheintz
+ *
+ */
+@Retention(RetentionPolicy.RUNTIME)
+public @interface Obtain {
+       public String value() default "";
+}
diff --git a/tests/multiIncremental/PR157054/base/dash/obtain/ObtainStaticAspect.aj b/tests/multiIncremental/PR157054/base/dash/obtain/ObtainStaticAspect.aj
new file mode 100644 (file)
index 0000000..eff8dfc
--- /dev/null
@@ -0,0 +1,16 @@
+package dash.obtain;
+
+
+public aspect ObtainStaticAspect  {
+
+       pointcut obtain_get(): get(@Obtain static * *);
+
+       Object around(): obtain_get() {
+               return proceed();
+       }
+       
+       public void foo() {
+               //System.out.println("foo: "+ObtainStaticTestClass.foo);
+       }
+
+}
diff --git a/tests/multiIncremental/PR157054/base/dash/obtain/ObtainStaticTest.java b/tests/multiIncremental/PR157054/base/dash/obtain/ObtainStaticTest.java
new file mode 100644 (file)
index 0000000..d257c2f
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+* Copyright (C) 2005  John D. Heintz
+* 
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU Library General Public License
+* as published by the Free Software Foundation; either version 2.1
+* of the License.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+* GNU Library General Public License for more details.
+*
+* John D. Heintz can be reached at: jheintz@pobox.com 
+*/
+package dash.obtain;
+
+
+public class ObtainStaticTest {
+       
+       @Obtain static String bar2;
+       
+       public void testRegularFieldNull() throws Exception {
+               try {
+                       ObtainStaticTestClass.baz.length();
+                       fail("should have null pointered");
+               } catch (NullPointerException ex) {
+                       ;// noop
+               }
+       }
+
+ public void fail(String s) {}
+
+       /**
+        * 
+        * @throws Exception
+        */
+       public void testNullPointerException() throws Exception {
+               try {
+                       String bar = ObtainStaticTestClass.bar;
+                       //System.out.println("bar2:"+ObtainStaticTest.bar2);
+                       fail(bar);
+               } catch (NullPointerException ex) {
+                       ;// noop
+               }
+       }       
+       
+       /**
+        * 
+        * @throws Exception
+        */
+       public void testBasicObtain() throws Exception {
+               // set @Obtain-able value to "foo" String
+               //provider.setObtainableValue(ObtainStaticTestClass.class, "foo", "foo");
+               
+               assertEquals("foo", ObtainStaticTestClass.foo);
+       }
+
+public void assertEquals(Object a,Object b) {}
+}
diff --git a/tests/multiIncremental/PR157054/base/dash/obtain/ObtainStaticTestClass.java b/tests/multiIncremental/PR157054/base/dash/obtain/ObtainStaticTestClass.java
new file mode 100644 (file)
index 0000000..b8f714b
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+* Copyright (C) 2005  John D. Heintz
+* 
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU Library General Public License
+* as published by the Free Software Foundation; either version 2.1
+* of the License.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+* GNU Library General Public License for more details.
+*
+* John D. Heintz can be reached at: jheintz@pobox.com 
+*/
+package dash.obtain;
+
+public class ObtainStaticTestClass {
+       
+       @Obtain static String foo;
+       @Obtain static String bar;
+       static String baz;
+       
+       public void foo() {
+               //System.out.println("foo: "+ObtainStaticTestClass.foo);
+       }
+}
diff --git a/tests/multiIncremental/PR157054/inc1/dash/obtain/ObtainStaticTest.java b/tests/multiIncremental/PR157054/inc1/dash/obtain/ObtainStaticTest.java
new file mode 100644 (file)
index 0000000..366f37b
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+* Copyright (C) 2005  John D. Heintz
+* 
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU Library General Public License
+* as published by the Free Software Foundation; either version 2.1
+* of the License.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+* GNU Library General Public License for more details.
+*
+* John D. Heintz can be reached at: jheintz@pobox.com 
+*/
+package dash.obtain;
+
+
+public class ObtainStaticTest {
+       
+       @Obtain static String bar2;
+       
+       public void testRegularFieldNull() throws Exception {
+               try {
+                       ObtainStaticTestClass.baz.length();
+                       fail("should have null pointered");
+               } catch (NullPointerException ex) {
+                       ;// noop
+               }
+       }
+
+ public void fail(String s) {}
+
+       /**
+        * 
+        * @throws Exception
+        */
+       public void testNullPointerException() throws Exception {
+               try {
+                       String bar = ObtainStaticTestClass.bar;
+                       System.out.println("bar2:"+ObtainStaticTest.bar2);
+                       fail(bar);
+               } catch (NullPointerException ex) {
+                       ;// noop
+               }
+       }       
+       
+       /**
+        * 
+        * @throws Exception
+        */
+       public void testBasicObtain() throws Exception {
+               // set @Obtain-able value to "foo" String
+               //provider.setObtainableValue(ObtainStaticTestClass.class, "foo", "foo");
+               
+               assertEquals("foo", ObtainStaticTestClass.foo);
+       }
+
+public void assertEquals(Object a,Object b) {}
+}