[jboss-cvs] JBossAS SVN: r79105 - in branches/JBoss_AOP_1_5_5_GA_CP/aop/src: resources/test/annotationproperty and 2 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Oct 3 14:37:09 EDT 2008


Author: jhowell at redhat.com
Date: 2008-10-03 14:37:09 -0400 (Fri, 03 Oct 2008)
New Revision: 79105

Added:
   branches/JBoss_AOP_1_5_5_GA_CP/aop/src/resources/test/annotationproperty/
   branches/JBoss_AOP_1_5_5_GA_CP/aop/src/resources/test/annotationproperty/annotations-aop.xml
   branches/JBoss_AOP_1_5_5_GA_CP/aop/src/test/org/jboss/test/aop/annotationproperty/
   branches/JBoss_AOP_1_5_5_GA_CP/aop/src/test/org/jboss/test/aop/annotationproperty/AnnotationPropertyReplacementTestCase.java
   branches/JBoss_AOP_1_5_5_GA_CP/aop/src/test/org/jboss/test/aop/annotationproperty/Complex.java
   branches/JBoss_AOP_1_5_5_GA_CP/aop/src/test/org/jboss/test/aop/annotationproperty/SimpleValue.java
Log:
[JBPAPP-1199] - Merge changes from Branch_1_5 for JBAOP-633 - system properties replacement in jboss-aop.xml annotation introductions and overrides 

Added: branches/JBoss_AOP_1_5_5_GA_CP/aop/src/resources/test/annotationproperty/annotations-aop.xml
===================================================================
--- branches/JBoss_AOP_1_5_5_GA_CP/aop/src/resources/test/annotationproperty/annotations-aop.xml	                        (rev 0)
+++ branches/JBoss_AOP_1_5_5_GA_CP/aop/src/resources/test/annotationproperty/annotations-aop.xml	2008-10-03 18:37:09 UTC (rev 79105)
@@ -0,0 +1,8 @@
+<aop>
+   <annotation-introduction expr="class(org.jboss.test.aop.annotationproperty.POJO)">
+      @org.jboss.test.aop.annotationproperty.SimpleValue("${value1}")
+   </annotation-introduction>
+   <annotation expr="class(org.jboss.test.aop.annotationproperty.POJO)">
+      @org.jboss.test.aop.annotationproperty.Complex(ch='${ch}', string="${string}", flt=${flt}, dbl=${dbl}, shrt=${shrt}, lng=${lng}, integer=${integer}, bool=${bool}, annotation=${annotation}, array=${array}, clazz=${clazz})
+   </annotation>
+</aop>
\ No newline at end of file

Added: branches/JBoss_AOP_1_5_5_GA_CP/aop/src/test/org/jboss/test/aop/annotationproperty/AnnotationPropertyReplacementTestCase.java
===================================================================
--- branches/JBoss_AOP_1_5_5_GA_CP/aop/src/test/org/jboss/test/aop/annotationproperty/AnnotationPropertyReplacementTestCase.java	                        (rev 0)
+++ branches/JBoss_AOP_1_5_5_GA_CP/aop/src/test/org/jboss/test/aop/annotationproperty/AnnotationPropertyReplacementTestCase.java	2008-10-03 18:37:09 UTC (rev 79105)
@@ -0,0 +1,133 @@
+/*
+  * JBoss, Home of Professional Open Source
+  * Copyright 2005, JBoss Inc., and individual contributors as indicated
+  * by the @authors tag. See the copyright.txt 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.annotationproperty;
+
+import java.io.IOException;
+import java.net.URL;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.List;
+
+import org.jboss.aop.AspectManager;
+import org.jboss.aop.AspectXmlLoader;
+import org.jboss.aop.annotation.AnnotationCreator;
+import org.jboss.aop.introduction.AnnotationIntroduction;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+
+/**
+ * @author <a href="mailto:kabir.khan at jboss.org">Kabir Khan</a>
+ * @version $Revision: 75505 $
+ */
+public class AnnotationPropertyReplacementTestCase extends TestCase
+{
+   public static void main(String[] args)
+   {
+      TestRunner.run(suite());
+   }
+
+   public static Test suite()
+   {
+      TestSuite suite = new TestSuite("AOPTester");
+      suite.addTestSuite(AnnotationPropertyReplacementTestCase.class);
+      return suite;
+   }
+
+   public AnnotationPropertyReplacementTestCase(String name)
+   {
+      super(name);
+   }
+
+   
+   public void testPropertyReplacement() throws Exception
+   {
+      AccessController.doPrivileged(new PrivilegedAction() {
+
+         public Object run()
+         {
+            //Properties for the @SimpleValue
+            System.setProperty("value1", "Test");
+            
+            //Properties for the @Complex
+            System.setProperty("ch", "a");
+            System.setProperty("string", "Test123");
+            System.setProperty("flt", "9.9");
+            System.setProperty("dbl", "123456789.99");
+            System.setProperty("shrt", "1");
+            System.setProperty("lng", "987654321");
+            System.setProperty("integer", "123");
+            System.setProperty("bool", "true");
+            System.setProperty("annotation", "@org.jboss.test.aop.annotationproperty.SimpleValue(\"Yes\")");
+            System.setProperty("array", "{\"Test\", \"123\"}");
+            System.setProperty("clazz", "java.lang.Long.class");
+            return null;
+         }});
+      
+      URL url = getURLRelativeToProjectRoot("/src/resources/test/annotationproperty/annotations-aop.xml");
+      AspectXmlLoader.deployXML(url);
+      
+      List introductions = AspectManager.instance().getAnnotationIntroductions();
+      assertEquals(1, introductions.size());
+
+      SimpleValue value = (SimpleValue)AnnotationCreator.createAnnotation(((AnnotationIntroduction)introductions.get(0)).getOriginalAnnotationExpr(), SimpleValue.class);
+      assertNotNull(value);
+      assertEquals("Test", value.value());
+      
+      List overrides = AspectManager.instance().getAnnotationOverrides();
+      assertEquals(1, overrides.size());
+      
+      Complex complex = (Complex)AnnotationCreator.createAnnotation(((AnnotationIntroduction)overrides.get(0)).getOriginalAnnotationExpr(), Complex.class);
+      assertNotNull(complex);
+      assertEquals('a', complex.ch());
+      assertEquals("Test123", complex.string());
+      assertEquals(9,9, complex.flt());
+      assertTrue(123456789.99 == complex.dbl());
+      assertEquals(1, complex.shrt());
+      assertEquals(987654321, complex.lng());
+      assertEquals(123, complex.integer());
+      assertEquals(true, complex.bool());
+      assertEquals(Long.class, complex.clazz());
+      assertEquals("Yes", complex.annotation().value());
+      
+      assertEquals(2, complex.array().length);
+      assertEquals("Test", complex.array()[0]);
+      assertEquals("123", complex.array()[1]);
+   }
+   
+   
+   
+   protected URL getURLRelativeToProjectRoot(String relativePath) throws IOException
+   {
+      URL url = this.getClass().getProtectionDomain().getCodeSource().getLocation();
+      String location = url.toString();
+      int index = location.indexOf("/output/");
+      location = location.substring(0, index);
+      
+      location = location + relativePath;
+      return new URL(location);
+   }
+
+}
+

Added: branches/JBoss_AOP_1_5_5_GA_CP/aop/src/test/org/jboss/test/aop/annotationproperty/Complex.java
===================================================================
--- branches/JBoss_AOP_1_5_5_GA_CP/aop/src/test/org/jboss/test/aop/annotationproperty/Complex.java	                        (rev 0)
+++ branches/JBoss_AOP_1_5_5_GA_CP/aop/src/test/org/jboss/test/aop/annotationproperty/Complex.java	2008-10-03 18:37:09 UTC (rev 79105)
@@ -0,0 +1,53 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt 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.annotationproperty;
+
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 69888 $
+ */
+public interface Complex 
+{
+   char ch();
+
+   String string();
+
+   float flt();
+
+   double dbl();
+
+   short shrt();
+
+   long lng();
+
+   int integer();
+
+   boolean bool();
+
+   SimpleValue annotation();
+
+   String[] array();
+
+   Class clazz();
+}

Added: branches/JBoss_AOP_1_5_5_GA_CP/aop/src/test/org/jboss/test/aop/annotationproperty/SimpleValue.java
===================================================================
--- branches/JBoss_AOP_1_5_5_GA_CP/aop/src/test/org/jboss/test/aop/annotationproperty/SimpleValue.java	                        (rev 0)
+++ branches/JBoss_AOP_1_5_5_GA_CP/aop/src/test/org/jboss/test/aop/annotationproperty/SimpleValue.java	2008-10-03 18:37:09 UTC (rev 79105)
@@ -0,0 +1,33 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt 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.annotationproperty;
+
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 46363 $
+ */
+public interface SimpleValue
+{
+   String value();
+}




More information about the jboss-cvs-commits mailing list