[jboss-cvs] JBossAS SVN: r78235 - in projects/aop/trunk/aop/src: resources/test/synthetic and 1 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Sep 9 05:54:19 EDT 2008


Author: kabir.khan at jboss.com
Date: 2008-09-09 05:54:19 -0400 (Tue, 09 Sep 2008)
New Revision: 78235

Modified:
   projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/Instrumentor.java
   projects/aop/trunk/aop/src/resources/test/synthetic/jboss-aop.xml
   projects/aop/trunk/aop/src/test/org/jboss/test/aop/synthetic/SyntheticTestCase.java
Log:
[JBAOP-635] Test that things are synthetic for caller pointcuts

Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/Instrumentor.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/Instrumentor.java	2008-09-09 09:10:59 UTC (rev 78234)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/Instrumentor.java	2008-09-09 09:54:19 UTC (rev 78235)
@@ -261,6 +261,7 @@
       newMethod.setModifiers(Modifier.PUBLIC);
       clazz.addMethod(newMethod);
       
+      //TODO remove this hack once we have a version of javassist that makes the _added_m$ emthods synthetic 
       //The following depends on javassist internals
       ClassFile cf = clazz.getClassFile();
       List<MethodInfo> infos = cf.getMethods();

Modified: projects/aop/trunk/aop/src/resources/test/synthetic/jboss-aop.xml
===================================================================
--- projects/aop/trunk/aop/src/resources/test/synthetic/jboss-aop.xml	2008-09-09 09:10:59 UTC (rev 78234)
+++ projects/aop/trunk/aop/src/resources/test/synthetic/jboss-aop.xml	2008-09-09 09:54:19 UTC (rev 78235)
@@ -28,4 +28,10 @@
          org.jboss.test.aop.synthetic.SomeInterface
       </interfaces>
    </introduction>
+   <bind pointcut="call(org.jboss.test.aop.synthetic.Called->new())">
+      <interceptor-ref name="org.jboss.test.aop.synthetic.SimpleInterceptor"/>
+   </bind>
+   <bind pointcut="call(* org.jboss.test.aop.synthetic.Called->called())">
+      <interceptor-ref name="org.jboss.test.aop.synthetic.SimpleInterceptor"/>
+   </bind>
 </aop>

Modified: projects/aop/trunk/aop/src/test/org/jboss/test/aop/synthetic/SyntheticTestCase.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/synthetic/SyntheticTestCase.java	2008-09-09 09:10:59 UTC (rev 78234)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/synthetic/SyntheticTestCase.java	2008-09-09 09:54:19 UTC (rev 78235)
@@ -131,10 +131,10 @@
       assertEquals(2, POJO.staticField);
       assertTrue(SimpleInterceptor.intercepted);
       
-//      @SuppressWarnings("unused")
-//      MixinInterface mi = (MixinInterface)pojo;
-//      @SuppressWarnings("unused")
-//      SomeInterface si = (SomeInterface)pojo;
+      @SuppressWarnings("unused")
+      MixinInterface mi = (MixinInterface)pojo;
+      @SuppressWarnings("unused")
+      SomeInterface si = (SomeInterface)pojo;
 
       //Now check that we have the synthetic attributes
       for (Constructor<?> ctor : pojo.getClass().getDeclaredConstructors())
@@ -165,6 +165,35 @@
       }
    }
    
+   public void testCallerSynthetic() throws Exception
+   {
+      //These validate interception behind the scenes
+      Caller caller = new Caller();
+      caller.call();
+
+   
+      //Now check that we have the synthetic attributes
+      for (Constructor<?> ctor : caller.getClass().getDeclaredConstructors())
+      {
+         assertFalse(ctor.toString() + " should not be synthetic", ctor.isSynthetic());
+      }
+      for (Field field : caller.getClass().getDeclaredFields())
+      {
+         assertTrue(field.toString() + " should be synthetic", field.isSynthetic());
+      }
+      for (Method method : caller.getClass().getDeclaredMethods())
+      {
+         if (method.getName().equals("call"))
+         {
+            assertFalse(method.toString() + " should not be synthetic", method.isSynthetic());
+         }
+         else
+         {
+            assertTrue(method.toString() + " should be synthetic", method.isSynthetic());
+         }
+      }
+}
+   
    public void testProxiedSynthetic() throws Exception
    {
       HashSet<String> fieldsAndMethods = new HashSet<String>();




More information about the jboss-cvs-commits mailing list