[jboss-cvs] JBossAS SVN: r64839 - in projects/aop/trunk/aop/src: test/org/jboss/test/aop/beforeafterArgs and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Aug 23 21:07:25 EDT 2007


Author: flavia.rainone at jboss.com
Date: 2007-08-23 21:07:25 -0400 (Thu, 23 Aug 2007)
New Revision: 64839

Added:
   projects/aop/trunk/aop/src/test/org/jboss/test/aop/beforeafterArgs/ThrownInvalidTestCase.java
Modified:
   projects/aop/trunk/aop/src/resources/test/beforeafterArgs/jboss-aop.xml
   projects/aop/trunk/aop/src/test/org/jboss/test/aop/beforeafterArgs/ThrownInvalidPOJO.java
Log:
[JBAOP-387] Added tests for invalid advices with @Thrown-annotated parameters.

Modified: projects/aop/trunk/aop/src/resources/test/beforeafterArgs/jboss-aop.xml
===================================================================
--- projects/aop/trunk/aop/src/resources/test/beforeafterArgs/jboss-aop.xml	2007-08-24 01:01:24 UTC (rev 64838)
+++ projects/aop/trunk/aop/src/resources/test/beforeafterArgs/jboss-aop.xml	2007-08-24 01:07:25 UTC (rev 64839)
@@ -1168,7 +1168,7 @@
       <finally name="finally1" aspect="org.jboss.test.aop.beforeafterArgs.ThrownAspect"/>
 	</bind>
 
-   <bind pointcut="execution(* org.jboss.test.aop.beforeafterArgs.ThrownInvalidPOJO->method1(..))">
+   <bind pointcut="execution(* org.jboss.test.aop.beforeafterArgs.ThrownInvalidPOJO->method1Throwing1(..))">
 		<throwing name="throwing1" aspect="org.jboss.test.aop.beforeafterArgs.ThrownAspect"/>
 	</bind>
    
@@ -1180,8 +1180,11 @@
 	<bind pointcut="execution(* org.jboss.test.aop.beforeafterArgs.ThrownPOJO->method3(..))">
 	</bind>
    
-   <bind pointcut="execution(* org.jboss.test.aop.beforeafterArgs.ThrownInvalidPOJO->method3(..))">
+   <bind pointcut="execution(* org.jboss.test.aop.beforeafterArgs.ThrownInvalidPOJO->method3Throwing3(..))">
 		<throwing name="throwing3" aspect="org.jboss.test.aop.beforeafterArgs.ThrownAspect"/>
+	</bind>
+   
+   <bind pointcut="execution(* org.jboss.test.aop.beforeafterArgs.ThrownInvalidPOJO->method3Finally3(..))">
       <finally name="finally3" aspect="org.jboss.test.aop.beforeafterArgs.ThrownAspect"/>
 	</bind>
 	
@@ -1189,7 +1192,7 @@
       <finally name="finally4" aspect="org.jboss.test.aop.beforeafterArgs.ThrownAspect"/>
 	</bind>
 	
-   <bind pointcut="execution(* org.jboss.test.aop.beforeafterArgs.ThrownInvalidPOJO->method4(..))">
+   <bind pointcut="execution(* org.jboss.test.aop.beforeafterArgs.ThrownInvalidPOJO->method4Throwing4(..))">
 		<throwing name="throwing4" aspect="org.jboss.test.aop.beforeafterArgs.ThrownAspect"/>
 	</bind>
    
@@ -1197,7 +1200,7 @@
       <finally name="finally5" aspect="org.jboss.test.aop.beforeafterArgs.ThrownAspect"/>
 	</bind>
    
-   <bind pointcut="execution(* org.jboss.test.aop.beforeafterArgs.ThrownInvalidPOJO->method5(..))">
+   <bind pointcut="execution(* org.jboss.test.aop.beforeafterArgs.ThrownInvalidPOJO->method5Throwing5(..))">
 		<throwing name="throwing5" aspect="org.jboss.test.aop.beforeafterArgs.ThrownAspect"/>
 	</bind>
 	
@@ -1209,7 +1212,7 @@
    <bind pointcut="execution(* org.jboss.test.aop.beforeafterArgs.ThrownPOJO->method7(..))">
 	</bind>
    
-	<bind pointcut="execution(* org.jboss.test.aop.beforeafterArgs.ThrownInvalidPOJO->method7(..))">
+	<bind pointcut="execution(* org.jboss.test.aop.beforeafterArgs.ThrownInvalidPOJO->method7Throwing8(..))">
 		<throwing name="throwing8" aspect="org.jboss.test.aop.beforeafterArgs.ThrownAspect"/>
 	</bind>
 

Modified: projects/aop/trunk/aop/src/test/org/jboss/test/aop/beforeafterArgs/ThrownInvalidPOJO.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/beforeafterArgs/ThrownInvalidPOJO.java	2007-08-24 01:01:24 UTC (rev 64838)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/beforeafterArgs/ThrownInvalidPOJO.java	2007-08-24 01:07:25 UTC (rev 64839)
@@ -28,37 +28,42 @@
  */
 public class ThrownInvalidPOJO
 {
-   // as a convention, the number of the thrown exception should never be 0, so we
-   // can identify when the number hasn't been set in ThrownAspect, and when it has
+   /* method1(int) */
    
-   public void method1(int i) throws POJOException
+   public void method1Throwing1(int i) throws POJOException
    {
       throw new POJOException(i);
    }
    
-   public void method2(int i) throws POJOException
+   /* method3(int) */
+   
+   public void method3Throwing3(int i) throws POJOException
    {
       throw new POJOException(i);
    }
    
-   public void method3(int i) throws POJOException
+   public void method3Finally3(int i) throws POJOException
    {
       throw new POJOException(i);
    }
    
-   public void method4(int i) throws POJOException
+   /* method4(int) */
+   
+   public void method4Throwing4(int i) throws POJOException
    {
       throw new POJOException(i);
    }
    
-   public void method5(int i) throws POJOException
+   /* method5(int) */
+   
+   public void method5Throwing5(int i) throws POJOException
    {
       throw new POJOException(i);
    }
    
-   public void method6() throws POJOException { }
+   /* method7() */
    
-   public void method7() throws POJOException
+   public void method7Throwing8() throws POJOException
    {
       throw new POJOException(6);
    }

Added: projects/aop/trunk/aop/src/test/org/jboss/test/aop/beforeafterArgs/ThrownInvalidTestCase.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/beforeafterArgs/ThrownInvalidTestCase.java	                        (rev 0)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/beforeafterArgs/ThrownInvalidTestCase.java	2007-08-24 01:07:25 UTC (rev 64839)
@@ -0,0 +1,145 @@
+/*
+ * 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.beforeafterArgs;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+
+import org.jboss.aop.advice.NoMatchingAdviceException;
+import org.jboss.test.aop.AOPTestWithSetup;
+
+/**
+ * Tests parameter annotation @Thrown with invalid advices. 
+ * 
+ * @author <a href="flavia.rainone at jboss.com">Flavia Rainone</a>
+ *
+ */
+public class ThrownInvalidTestCase extends AOPTestWithSetup
+{
+   private ThrownInvalidPOJO pojo;
+
+   public static void main(String[] args)
+   {
+      TestRunner.run(suite());
+   }
+
+   public static Test suite()
+   {
+      TestSuite suite = new TestSuite("ThrownTestCase");
+      suite.addTestSuite(ThrownInvalidTestCase.class);
+      return suite;
+   }
+
+   public ThrownInvalidTestCase(String name)
+   {
+      super(name);
+   }
+
+   public void setUp() throws Exception
+   {
+      super.setUp();
+      ThrownAspect.clear();
+      this.pojo = new ThrownInvalidPOJO();
+   }
+
+   public void test1() throws POJOException
+   {
+      boolean thrown = false;
+      try
+      {
+         pojo.method1Throwing1(11);
+      }
+      catch(NoMatchingAdviceException e)
+      {
+         thrown = true;
+      }
+      assertTrue(thrown);
+   }
+
+   public void test3() throws POJOException
+   {
+      boolean thrown = false;
+      try
+      {
+         pojo.method3Throwing3(3);
+      }
+      catch(NoMatchingAdviceException e)
+      {
+         thrown = true;
+      }
+      assertTrue(thrown);
+      
+      thrown = false;
+      try
+      {
+         pojo.method3Finally3(3);
+      }
+      catch(NoMatchingAdviceException e)
+      {
+         thrown = true;
+      }
+      assertTrue(thrown);
+   }
+   
+   public void test4() throws POJOException
+   {
+      boolean thrown = false;
+      try
+      {
+         pojo.method4Throwing4(4);
+      }
+      catch(NoMatchingAdviceException e)
+      {
+         thrown = true;
+      }
+      assertTrue(thrown);
+   }
+   
+   public void test5() throws POJOException
+   {
+      boolean thrown = false;
+      try
+      {
+         pojo.method5Throwing5(5);
+      }
+      catch(NoMatchingAdviceException e)
+      {
+         thrown = true;
+      }
+      assertTrue(thrown);
+   }
+   
+   public void test7() throws POJOException
+   {
+      boolean thrown = false;
+      try
+      {
+         pojo.method7Throwing8();
+      }
+      catch(NoMatchingAdviceException e)
+      {
+         thrown = true;
+      }
+      assertTrue(thrown);
+   }
+}
\ No newline at end of file




More information about the jboss-cvs-commits mailing list