[jboss-cvs] JBossAS SVN: r64786 - 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
Wed Aug 22 14:55:54 EDT 2007
Author: flavia.rainone at jboss.com
Date: 2007-08-22 14:55:54 -0400 (Wed, 22 Aug 2007)
New Revision: 64786
Added:
projects/aop/trunk/aop/src/test/org/jboss/test/aop/beforeafterArgs/ReturnInvalidTestCase.java
Modified:
projects/aop/trunk/aop/src/resources/test/beforeafterArgs/jboss-aop.xml
projects/aop/trunk/aop/src/test/org/jboss/test/aop/beforeafterArgs/ReturnInvalidPOJO.java
projects/aop/trunk/aop/src/test/org/jboss/test/aop/beforeafterArgs/ReturnPOJO.java
projects/aop/trunk/aop/src/test/org/jboss/test/aop/beforeafterArgs/ReturnTestCase.java
Log:
[JBAOP-387] Added tests for invalid advices with @Return-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-22 18:39:53 UTC (rev 64785)
+++ projects/aop/trunk/aop/src/resources/test/beforeafterArgs/jboss-aop.xml 2007-08-22 18:55:54 UTC (rev 64786)
@@ -880,7 +880,7 @@
<finally name="finally1" aspect="org.jboss.test.aop.beforeafterArgs.ReturnAspect"/>
</bind>
- <bind pointcut="execution(* org.jboss.test.aop.beforeafterArgs.ReturnInvalidPOJO->method1(..))">
+ <bind pointcut="execution(* org.jboss.test.aop.beforeafterArgs.ReturnInvalidPOJO->method1Before(..))">
<before name="before" aspect="org.jboss.test.aop.beforeafterArgs.ReturnAspect"/>
</bind>
@@ -888,7 +888,7 @@
<after name="after2" aspect="org.jboss.test.aop.beforeafterArgs.ReturnAspect"/>
</bind>
- <bind pointcut="execution(* org.jboss.test.aop.beforeafterArgs.ReturnInvalidPOJO->method2(..))">
+ <bind pointcut="execution(* org.jboss.test.aop.beforeafterArgs.ReturnInvalidPOJO->method2Around2(..))">
<around name="around2" aspect="org.jboss.test.aop.beforeafterArgs.ReturnAspect"/>
</bind>
@@ -898,7 +898,7 @@
<finally name="finally3" aspect="org.jboss.test.aop.beforeafterArgs.ReturnAspect"/>
</bind>
- <bind pointcut="execution(* org.jboss.test.aop.beforeafterArgs.ReturnInvalidPOJO->method3(..))">
+ <bind pointcut="execution(* org.jboss.test.aop.beforeafterArgs.ReturnInvalidPOJO->method3Before(..))">
<before name="before" aspect="org.jboss.test.aop.beforeafterArgs.ReturnAspect"/>
</bind>
@@ -913,7 +913,7 @@
<after name="after5" aspect="org.jboss.test.aop.beforeafterArgs.ReturnAspect"/>
</bind>
- <bind pointcut="execution(* org.jboss.test.aop.beforeafterArgs.ReturnInvalidPOJO->method5(..))">
+ <bind pointcut="execution(* org.jboss.test.aop.beforeafterArgs.ReturnInvalidPOJO->method5Finally5(..))">
<finally name="finally5" aspect="org.jboss.test.aop.beforeafterArgs.ReturnAspect"/>
</bind>
@@ -922,7 +922,7 @@
<finally name="finally6" aspect="org.jboss.test.aop.beforeafterArgs.ReturnAspect"/>
</bind>
- <bind pointcut="execution(* org.jboss.test.aop.beforeafterArgs.ReturnInvalidPOJO->method6(..))">
+ <bind pointcut="execution(* org.jboss.test.aop.beforeafterArgs.ReturnInvalidPOJO->method6Around6(..))">
<around name="around6" aspect="org.jboss.test.aop.beforeafterArgs.ReturnAspect"/>
</bind>
@@ -938,16 +938,19 @@
<finally name="finally8" aspect="org.jboss.test.aop.beforeafterArgs.ReturnAspect"/>
</bind>
- <bind pointcut="execution(* org.jboss.test.aop.beforeafterArgs.ReturnInvalidPOJO->method8(..))">
+ <bind pointcut="execution(* org.jboss.test.aop.beforeafterArgs.ReturnInvalidPOJO->method8Before(..))">
<before name="before" aspect="org.jboss.test.aop.beforeafterArgs.ReturnAspect"/>
</bind>
- <bind pointcut="execution(* org.jboss.test.aop.beforeafterArgs.ReturnPOJO->method9(..))">
- </bind>
-
- <bind pointcut="execution(* org.jboss.test.aop.beforeafterArgs.ReturnInvalidPOJO->method9(..))">
+ <bind pointcut="execution(* org.jboss.test.aop.beforeafterArgs.ReturnInvalidPOJO->method9Around9(..))">
<around name="around9" aspect="org.jboss.test.aop.beforeafterArgs.ReturnAspect"/>
+ </bind>
+
+ <bind pointcut="execution(* org.jboss.test.aop.beforeafterArgs.ReturnInvalidPOJO->method9After9(..))">
<after name="after9" aspect="org.jboss.test.aop.beforeafterArgs.ReturnAspect"/>
+ </bind>
+
+ <bind pointcut="execution(* org.jboss.test.aop.beforeafterArgs.ReturnInvalidPOJO->method9Finally9(..))">
<finally name="finally9" aspect="org.jboss.test.aop.beforeafterArgs.ReturnAspect"/>
</bind>
@@ -956,8 +959,11 @@
<finally name="finally10" aspect="org.jboss.test.aop.beforeafterArgs.ReturnAspect"/>
</bind>
- <bind pointcut="execution(* org.jboss.test.aop.beforeafterArgs.ReturnInvalidPOJO->method10(..))">
+ <bind pointcut="execution(* org.jboss.test.aop.beforeafterArgs.ReturnInvalidPOJO->method10Before(..))">
<before name="before" aspect="org.jboss.test.aop.beforeafterArgs.ReturnAspect"/>
+ </bind>
+
+ <bind pointcut="execution(* org.jboss.test.aop.beforeafterArgs.ReturnInvalidPOJO->method10After10(..))">
<after name="after10" aspect="org.jboss.test.aop.beforeafterArgs.ReturnAspect"/>
</bind>
Modified: projects/aop/trunk/aop/src/test/org/jboss/test/aop/beforeafterArgs/ReturnInvalidPOJO.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/beforeafterArgs/ReturnInvalidPOJO.java 2007-08-22 18:39:53 UTC (rev 64785)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/beforeafterArgs/ReturnInvalidPOJO.java 2007-08-22 18:55:54 UTC (rev 64786)
@@ -29,65 +29,71 @@
*/
public class ReturnInvalidPOJO
{
- public void method1() {}
+ /* method1() */
+
+ public void method1Before() {}
- public String method2()
+ /* method2() */
+
+ public String method2Around2()
{
return "method2";
}
- public String method3()
+ /* method3() */
+
+ public String method3Before()
{
return "method3";
}
- public String method4()
- {
- return "method4";
- }
+ /* method5() */
- public String method5()
+ public String method5Finally5()
{
return "method5";
}
- public String method6()
+ /* method6Around6() */
+
+ public String method6Around6()
{
return "method6";
}
- public String method7()
- {
- return "method7";
- }
+ /* method8() */
- public SubValue method8()
+ public SubValue method8Before()
{
return new SubValue(8);
}
- public SubValue method9()
+ /* method9() */
+
+ public SubValue method9Around9()
{
return new SubValue(9);
}
- public SuperValue method10()
+ public SubValue method9After9()
{
- return new SuperValue(10);
+ return new SubValue(9);
}
- public SuperValue method11()
+ public SubValue method9Finally9()
{
- return new SuperValue(11);
+ return new SubValue(9);
}
- public SubValue method12() throws POJOException
+ /* method10() */
+
+ public SuperValue method10Before()
{
- throw new POJOException();
+ return new SuperValue(10);
}
- public SubValue method13() throws POJOException
+ public SuperValue method10After10()
{
- throw new POJOException();
+ return new SuperValue(10);
}
}
\ No newline at end of file
Added: projects/aop/trunk/aop/src/test/org/jboss/test/aop/beforeafterArgs/ReturnInvalidTestCase.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/beforeafterArgs/ReturnInvalidTestCase.java (rev 0)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/beforeafterArgs/ReturnInvalidTestCase.java 2007-08-22 18:55:54 UTC (rev 64786)
@@ -0,0 +1,208 @@
+/*
+ * 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 both the use of @Return parameter with invalid advices, and the use of
+ * return values in invalid advices.
+ *
+ * @author <a href="flavia.rainone at jboss.com">Flavia Rainone</a>
+ */
+public class ReturnInvalidTestCase extends AOPTestWithSetup
+{
+ private ReturnInvalidPOJO pojo;
+
+ public static void main(String[] args)
+ {
+ TestRunner.run(suite());
+ }
+
+ public static Test suite()
+ {
+ TestSuite suite = new TestSuite("ReturnTestCase");
+ suite.addTestSuite(ReturnInvalidTestCase.class);
+ return suite;
+ }
+
+ public ReturnInvalidTestCase(String name)
+ {
+ super(name);
+ }
+
+ public void setUp() throws Exception
+ {
+ super.setUp();
+ ReturnAspect.clear();
+ this.pojo = new ReturnInvalidPOJO();
+ }
+
+ public void test1()
+ {
+ boolean thrown = false;
+ try
+ {
+ pojo.method1Before();
+ }
+ catch (NoMatchingAdviceException e)
+ {
+ thrown = true;
+ }
+ assertTrue(thrown);
+ }
+
+ public void test2()
+ {
+ boolean thrown = false;
+ try
+ {
+ pojo.method2Around2();
+ }
+ catch (NoMatchingAdviceException e)
+ {
+ thrown = true;
+ }
+ assertTrue(thrown);
+ }
+
+ public void test3()
+ {
+ boolean thrown = false;
+ try
+ {
+ pojo.method3Before();
+ }
+ catch (NoMatchingAdviceException e)
+ {
+ thrown = true;
+ }
+ assertTrue(thrown);
+ }
+
+ public void test5()
+ {
+ boolean thrown = false;
+ try
+ {
+ pojo.method5Finally5();
+ }
+ catch (NoMatchingAdviceException e)
+ {
+ thrown = true;
+ }
+ assertTrue(thrown);
+ }
+
+ public void test6()
+ {
+ boolean thrown = false;
+ try
+ {
+ pojo.method6Around6();
+ }
+ catch (NoMatchingAdviceException e)
+ {
+ thrown = true;
+ }
+ assertTrue(thrown);
+ }
+
+ public void test8()
+ {
+ boolean thrown = false;
+ try
+ {
+ pojo.method8Before();
+ }
+ catch (NoMatchingAdviceException e)
+ {
+ thrown = true;
+ }
+ }
+
+ public void test9()
+ {
+ boolean thrown = false;
+ try
+ {
+ pojo.method9Around9();
+ }
+ catch (NoMatchingAdviceException e)
+ {
+ thrown = true;
+ }
+ assertTrue(thrown);
+
+ thrown = false;
+ try
+ {
+ pojo.method9After9();
+ }
+ catch (NoMatchingAdviceException e)
+ {
+ thrown = true;
+ }
+ assertTrue(thrown);
+
+ thrown = false;
+ try
+ {
+ pojo.method9Finally9();
+ }
+ catch (NoMatchingAdviceException e)
+ {
+ thrown = true;
+ }
+ assertTrue(thrown);
+ }
+
+ public void test10()
+ {
+ boolean thrown = false;
+ try
+ {
+ pojo.method10Before();
+ }
+ catch (NoMatchingAdviceException e)
+ {
+ thrown = true;
+ }
+ assertTrue(thrown);
+
+ thrown = false;
+ try
+ {
+ pojo.method10After10();
+ }
+ catch (NoMatchingAdviceException e)
+ {
+ thrown = true;
+ }
+ assertTrue(thrown);
+ }
+}
\ No newline at end of file
Modified: projects/aop/trunk/aop/src/test/org/jboss/test/aop/beforeafterArgs/ReturnPOJO.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/beforeafterArgs/ReturnPOJO.java 2007-08-22 18:39:53 UTC (rev 64785)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/beforeafterArgs/ReturnPOJO.java 2007-08-22 18:55:54 UTC (rev 64786)
@@ -66,11 +66,6 @@
return new SubValue(8);
}
- public SubValue method9()
- {
- return new SubValue(9);
- }
-
public SuperValue method10()
{
return new SuperValue(10);
Modified: projects/aop/trunk/aop/src/test/org/jboss/test/aop/beforeafterArgs/ReturnTestCase.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/beforeafterArgs/ReturnTestCase.java 2007-08-22 18:39:53 UTC (rev 64785)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/beforeafterArgs/ReturnTestCase.java 2007-08-22 18:55:54 UTC (rev 64786)
@@ -167,21 +167,6 @@
assertNull(ReturnAspect.finallyThrown);
}
- public void test9()
- {
- SubValue value = pojo.method9();
- assertNotNull(value);
- assertEquals(9, value.i);
-
- assertNull(ReturnAspect.aroundAdvice);
- assertNull(ReturnAspect.aroundReturn);
- assertNull(ReturnAspect.afterAdvice);
- assertNull(ReturnAspect.afterReturn);
- assertNull(ReturnAspect.finallyAdvice);
- assertNull(ReturnAspect.finallyReturn);
- assertNull(ReturnAspect.finallyThrown);
- }
-
public void test10()
{
SuperValue value = pojo.method10();
More information about the jboss-cvs-commits
mailing list