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

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Nov 1 09:29:15 EDT 2007


Author: kabir.khan at jboss.com
Date: 2007-11-01 09:29:14 -0400 (Thu, 01 Nov 2007)
New Revision: 66647

Added:
   projects/aop/trunk/aop/src/resources/test/annotationoverride/
   projects/aop/trunk/aop/src/resources/test/annotationoverride/jboss-aop.xml
   projects/aop/trunk/aop/src/test/org/jboss/test/aop/annotationoverride/
   projects/aop/trunk/aop/src/test/org/jboss/test/aop/annotationoverride/AnnotationOverrideTestCase.java
   projects/aop/trunk/aop/src/test/org/jboss/test/aop/annotationoverride/Other.java
   projects/aop/trunk/aop/src/test/org/jboss/test/aop/annotationoverride/Proxied.java
   projects/aop/trunk/aop/src/test/org/jboss/test/aop/annotationoverride/Some.java
   projects/aop/trunk/aop/src/test/org/jboss/test/aop/annotationoverride/Woven.java
Modified:
   projects/aop/trunk/aop/base-tests.xml
Log:
Add a test to make sure that Advisor.resolveAnnotation() works the way it should for class and method level annotations

Modified: projects/aop/trunk/aop/base-tests.xml
===================================================================
--- projects/aop/trunk/aop/base-tests.xml	2007-11-01 11:58:34 UTC (rev 66646)
+++ projects/aop/trunk/aop/base-tests.xml	2007-11-01 13:29:14 UTC (rev 66647)
@@ -2,6 +2,9 @@
 
    <target name="_base-tests">
       <antcall target="${test-target}" inheritRefs="true">
+         <param name="test" value="annotationoverride"/>
+      </antcall>
+      <antcall target="${test-target}" inheritRefs="true">
          <param name="test" value="arguments"/>
       </antcall>
       <antcall target="${test-target}" inheritRefs="true">

Added: projects/aop/trunk/aop/src/resources/test/annotationoverride/jboss-aop.xml
===================================================================
--- projects/aop/trunk/aop/src/resources/test/annotationoverride/jboss-aop.xml	                        (rev 0)
+++ projects/aop/trunk/aop/src/resources/test/annotationoverride/jboss-aop.xml	2007-11-01 13:29:14 UTC (rev 66647)
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<aop>
+	<prepare expr="all(org.jboss.test.aop.annotationoverride.Woven)"/>
+	<annotation expr="class(org.jboss.test.aop.annotationoverride.Woven)">
+		@org.jboss.test.aop.annotationoverride.Some
+	</annotation>
+	<annotation expr="method(void org.jboss.test.aop.annotationoverride.Woven->method())">
+		@org.jboss.test.aop.annotationoverride.Other(value="method")
+	</annotation>
+	<annotation expr="constructor(org.jboss.test.aop.annotationoverride.Woven->new())">
+		@org.jboss.test.aop.annotationoverride.Other(value="ctor")
+	</annotation>
+	<annotation expr="field(int org.jboss.test.aop.annotationoverride.Woven->field)">
+		@org.jboss.test.aop.annotationoverride.Other(value="field")
+	</annotation>
+
+	<annotation expr="class(org.jboss.test.aop.annotationoverride.Proxied)">
+		@org.jboss.test.aop.annotationoverride.Some
+	</annotation>
+	<annotation expr="method(void org.jboss.test.aop.annotationoverride.Proxied->method())">
+		@org.jboss.test.aop.annotationoverride.Other(value="method")
+	</annotation>
+	   
+</aop>

Added: projects/aop/trunk/aop/src/test/org/jboss/test/aop/annotationoverride/AnnotationOverrideTestCase.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/annotationoverride/AnnotationOverrideTestCase.java	                        (rev 0)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/annotationoverride/AnnotationOverrideTestCase.java	2007-11-01 13:29:14 UTC (rev 66647)
@@ -0,0 +1,110 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors. 
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software 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
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/ 
+package org.jboss.test.aop.annotationoverride;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.jboss.aop.Advised;
+import org.jboss.aop.Advisor;
+import org.jboss.aop.AspectManager;
+import org.jboss.aop.ClassContainer;
+import org.jboss.test.aop.AOPTestWithSetup;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class AnnotationOverrideTestCase extends AOPTestWithSetup
+{
+   public AnnotationOverrideTestCase(String arg0)
+   {
+      // FIXME AnnotationOverrideTestCase constructor
+      super(arg0);
+   }
+
+   public static Test suite()
+   {
+      TestSuite suite = new TestSuite("AnnotationOverrideTestCase");
+      suite.addTestSuite(AnnotationOverrideTestCase.class);
+      return suite;
+   }
+
+   public void testWovenClass() throws Exception
+   {
+      Woven woven = new Woven();
+      Advisor advisor = ((Advised)woven)._getAdvisor();
+      
+      Some some = (Some)advisor.resolveAnnotation(Some.class);
+      assertNotNull(some);
+      Other other = (Other)advisor.resolveAnnotation(Other.class);
+      assertNull(other);
+      
+      Method m = Woven.class.getDeclaredMethod("method");
+      some = (Some)advisor.resolveAnnotation(m, Some.class);
+      assertNull(some);
+      other = (Other)advisor.resolveAnnotation(m, Other.class);
+      assertNotNull(other);
+      assertEquals("method", other.value());
+      
+      Field f = Woven.class.getDeclaredField("field");
+      some = (Some)advisor.resolveAnnotation(f, Some.class);
+      assertNull(some);
+      other = (Other)advisor.resolveAnnotation(f, Other.class);
+      assertNotNull(other);
+      assertEquals("field", other.value());
+      
+      Constructor<Woven> c = Woven.class.getDeclaredConstructor();
+      some = (Some)advisor.resolveAnnotation(c, Some.class);
+      assertNull(some);
+      other = (Other)advisor.resolveAnnotation(c, Other.class);
+      assertNotNull(other);
+      assertEquals("ctor", other.value());
+   }
+   
+   public void testClassContainerProxiedClass() throws Exception
+   {
+      ClassContainer container = new ClassContainer("test", AspectManager.instance());
+      container.setClass(Proxied.class);
+      container.initializeClassContainer();
+      
+      Some some = (Some)container.resolveAnnotation(Some.class);
+      assertNotNull(some);
+      Other other = (Other)container.resolveAnnotation(Other.class);
+      assertNull(other);
+      
+      Method m = Proxied.class.getDeclaredMethod("method");
+      some = (Some)container.resolveAnnotation(m, Some.class);
+      assertNull(some);
+      other = (Other)container.resolveAnnotation(m, Other.class);
+      assertNotNull(other);
+      assertEquals("method", other.value());
+      
+      
+   }
+
+}

Added: projects/aop/trunk/aop/src/test/org/jboss/test/aop/annotationoverride/Other.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/annotationoverride/Other.java	                        (rev 0)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/annotationoverride/Other.java	2007-11-01 13:29:14 UTC (rev 66647)
@@ -0,0 +1,31 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors. 
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software 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
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/ 
+package org.jboss.test.aop.annotationoverride;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public @interface Other {
+   String value();
+}

Added: projects/aop/trunk/aop/src/test/org/jboss/test/aop/annotationoverride/Proxied.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/annotationoverride/Proxied.java	                        (rev 0)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/annotationoverride/Proxied.java	2007-11-01 13:29:14 UTC (rev 66647)
@@ -0,0 +1,32 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors. 
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software 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
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/ 
+package org.jboss.test.aop.annotationoverride;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class Proxied
+{
+   void method() {}
+}

Added: projects/aop/trunk/aop/src/test/org/jboss/test/aop/annotationoverride/Some.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/annotationoverride/Some.java	                        (rev 0)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/annotationoverride/Some.java	2007-11-01 13:29:14 UTC (rev 66647)
@@ -0,0 +1,31 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors. 
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software 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
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/ 
+package org.jboss.test.aop.annotationoverride;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public @interface Some {
+
+}

Added: projects/aop/trunk/aop/src/test/org/jboss/test/aop/annotationoverride/Woven.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/annotationoverride/Woven.java	                        (rev 0)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/annotationoverride/Woven.java	2007-11-01 13:29:14 UTC (rev 66647)
@@ -0,0 +1,33 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors. 
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software 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
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/ 
+package org.jboss.test.aop.annotationoverride;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class Woven
+{  
+   int field;
+   void method() {}
+}




More information about the jboss-cvs-commits mailing list