[jboss-cvs] JBossAS SVN: r63559 - in projects/aop/trunk/aop: src/resources/test and 5 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Jun 18 12:02:50 EDT 2007
Author: kabir.khan at jboss.com
Date: 2007-06-18 12:02:50 -0400 (Mon, 18 Jun 2007)
New Revision: 63559
Added:
projects/aop/trunk/aop/src/resources/test/beforeafterthrowingstack/
projects/aop/trunk/aop/src/resources/test/beforeafterthrowingstack/jboss-aop.xml
projects/aop/trunk/aop/src/test/org/jboss/test/aop/beforeafterthrowingstack/
projects/aop/trunk/aop/src/test/org/jboss/test/aop/beforeafterthrowingstack/Aspect.java
projects/aop/trunk/aop/src/test/org/jboss/test/aop/beforeafterthrowingstack/BeforeAfterThrowingStackTestCase.java
projects/aop/trunk/aop/src/test/org/jboss/test/aop/beforeafterthrowingstack/POJO.java
projects/aop/trunk/aop/src/test/org/jboss/test/aop/beforeafterthrowingstack/ThrownByTestException.java
Modified:
projects/aop/trunk/aop/build-tests-jdk50.xml
projects/aop/trunk/aop/src/resources/test/stress/config.properties
projects/aop/trunk/aop/src/test/org/jboss/test/aop/stress/batf/BeforeAfterThrowingFinallyVersusAroundTestCase.java
Log:
[JBAOP-423] Test B/A/T/F with stacks
Modified: projects/aop/trunk/aop/build-tests-jdk50.xml
===================================================================
--- projects/aop/trunk/aop/build-tests-jdk50.xml 2007-06-18 15:25:58 UTC (rev 63558)
+++ projects/aop/trunk/aop/build-tests-jdk50.xml 2007-06-18 16:02:50 UTC (rev 63559)
@@ -401,6 +401,10 @@
<param name="test" value="beforeafterArgs"/>
<param name="caller" value="javaagent-genadvisor-tests"/>
</antcall>
+ <antcall target="_run-javaagent-test" inheritRefs="true">
+ <param name="test" value="beforeafterthrowingstack"/>
+ <param name="caller" value="javaagent-genadvisor-tests"/>
+ </antcall>
<!-- Add tests in _base-tests unless they should only be run in this weaving mode -->
<antcall target="_base-jdk50-tests" inheritRefs="true">
@@ -576,12 +580,18 @@
<param name="test" value="nameddomain"/>
<param name="caller" value="precompiled-genadvisor-tests"/>
</antcall>
+ <antcall target="_run-precompiled-test" inheritRefs="true">
+ <param name="test" value="beforeafterthrowingstack"/>
+ <param name="caller" value="precompiled-genadvisor-tests"/>
+ </antcall>
+
<!-- This should only be run using compile-time weaving -->
<antcall target="_run-precompiled-test" inheritRefs="true">
<param name="test" value="postweavingmixins"/>
<param name="caller" value="precompiled-genadvisor-tests"/>
</antcall>
+
<!-- Add tests in _base-precompiled-tests unless they should only be run in this weaving mode -->
<antcall target="_base-jdk50-tests" inheritRefs="true">
<param name="caller" value="precompiled-genadvisor-tests"/>
Added: projects/aop/trunk/aop/src/resources/test/beforeafterthrowingstack/jboss-aop.xml
===================================================================
--- projects/aop/trunk/aop/src/resources/test/beforeafterthrowingstack/jboss-aop.xml (rev 0)
+++ projects/aop/trunk/aop/src/resources/test/beforeafterthrowingstack/jboss-aop.xml 2007-06-18 16:02:50 UTC (rev 63559)
@@ -0,0 +1,15 @@
+<aop>
+ <aspect class="org.jboss.test.aop.beforeafterthrowingstack.Aspect" scope="PER_VM"/>
+
+ <stack name="bat">
+ <before aspect="org.jboss.test.aop.beforeafterthrowingstack.Aspect" name="before"/>
+ <around aspect="org.jboss.test.aop.beforeafterthrowingstack.Aspect" name="around"/>
+ <after aspect="org.jboss.test.aop.beforeafterthrowingstack.Aspect" name="after"/>
+ <throwing aspect="org.jboss.test.aop.beforeafterthrowingstack.Aspect" name="throwing"/>
+ <finally aspect="org.jboss.test.aop.beforeafterthrowingstack.Aspect" name="finaly"/>
+ </stack>
+
+ <bind pointcut="execution(* org.jboss.test.aop.beforeafterthrowingstack.POJO->stack*())">
+ <stack-ref name="bat"/>
+ </bind>
+</aop>
\ No newline at end of file
Modified: projects/aop/trunk/aop/src/resources/test/stress/config.properties
===================================================================
--- projects/aop/trunk/aop/src/resources/test/stress/config.properties 2007-06-18 15:25:58 UTC (rev 63558)
+++ projects/aop/trunk/aop/src/resources/test/stress/config.properties 2007-06-18 16:02:50 UTC (rev 63559)
@@ -1,5 +1,5 @@
-warmup=1
-loops=1000
+warmup=1000000
+loops=10000000
threads=1
random_sleep_interval=false
sleeptime_millis=0
Added: projects/aop/trunk/aop/src/test/org/jboss/test/aop/beforeafterthrowingstack/Aspect.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/beforeafterthrowingstack/Aspect.java (rev 0)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/beforeafterthrowingstack/Aspect.java 2007-06-18 16:02:50 UTC (rev 63559)
@@ -0,0 +1,122 @@
+/*
+* 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.beforeafterthrowingstack;
+
+import org.jboss.aop.advice.annotation.Thrown;
+import org.jboss.aop.joinpoint.Invocation;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class Aspect
+{
+ public static int aroundBefore;
+ public static int aroundAfter;
+ public static int aroundThrowing;
+ public static int aroundFinally;
+
+ public static int before;
+ public static int after;
+ public static int throwing;
+ public static int finaly;
+
+ public static Aspect aspect;
+
+ public Object around(Invocation inv) throws Throwable
+ {
+ try
+ {
+ aroundBefore++;
+ setAspect(true);
+ Object o = inv.invokeNext();
+ aroundAfter++;
+ return o;
+ }
+ catch(ThrownByTestException e)
+ {
+ aroundThrowing++;
+ throw e;
+ }
+ finally
+ {
+ aroundFinally++;
+ }
+ }
+
+
+ public void before()
+ {
+ before++;
+ setAspect(false);
+ }
+
+ public void after()
+ {
+ setAspect(true);
+ after++;
+ }
+
+ public void throwing(@Thrown Throwable e)
+ {
+ setAspect(true);
+ throwing++;
+ }
+
+ public void finaly()
+ {
+ setAspect(true);
+ finaly++;
+ }
+
+ public static void reset()
+ {
+ aroundBefore = 0;
+ aroundAfter = 0;
+ aroundThrowing = 0;
+ aroundFinally = 0;
+ before = 0;
+ after = 0;
+ throwing = 0;
+ finaly = 0;
+ aspect = null;
+ }
+
+ private void setAspect(boolean shouldHaveBeenSet)
+ {
+ if (aspect == null && shouldHaveBeenSet)
+ {
+ throw new RuntimeException("Aspect should have existed");
+ }
+
+ if (aspect != null)
+ {
+ if (aspect != this)
+ {
+ throw new RuntimeException("Wrong instance");
+ }
+ }
+
+ aspect = this;
+ }
+}
Added: projects/aop/trunk/aop/src/test/org/jboss/test/aop/beforeafterthrowingstack/BeforeAfterThrowingStackTestCase.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/beforeafterthrowingstack/BeforeAfterThrowingStackTestCase.java (rev 0)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/beforeafterthrowingstack/BeforeAfterThrowingStackTestCase.java 2007-06-18 16:02:50 UTC (rev 63559)
@@ -0,0 +1,109 @@
+/*
+* 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.beforeafterthrowingstack;
+
+import org.jboss.test.aop.AOPTestWithSetup;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class BeforeAfterThrowingStackTestCase extends AOPTestWithSetup
+{
+
+ public static void main(String[] args)
+ {
+ TestRunner.run(suite());
+ }
+
+ public static Test suite()
+ {
+ TestSuite suite = new TestSuite("BeforeAfterThrowingStackTestCase");
+ suite.addTestSuite(BeforeAfterThrowingStackTestCase.class);
+ return suite;
+ }
+
+ public BeforeAfterThrowingStackTestCase(String name)
+ {
+ super(name);
+ }
+
+ public void testMethodNoStack()
+ {
+ Aspect.reset();
+ POJO pojo = new POJO();
+ pojo.noStack();
+
+ assertEquals(0, Aspect.before);
+ assertEquals(0, Aspect.after);
+ assertEquals(0, Aspect.throwing);
+ assertEquals(0, Aspect.finaly);
+ assertEquals(0, Aspect.aroundBefore);
+ assertEquals(0, Aspect.aroundAfter);
+ assertEquals(0, Aspect.aroundThrowing);
+ assertEquals(0, Aspect.aroundFinally);
+ }
+
+ public void testMethodWithStack()
+ {
+ Aspect.reset();
+ POJO pojo = new POJO();
+ pojo.stack();
+
+ assertEquals(1, Aspect.before);
+ assertEquals(1, Aspect.after);
+ assertEquals(0, Aspect.throwing);
+ assertEquals(1, Aspect.finaly);
+ assertEquals(1, Aspect.aroundBefore);
+ assertEquals(1, Aspect.aroundAfter);
+ assertEquals(0, Aspect.aroundThrowing);
+ assertEquals(1, Aspect.aroundFinally);
+ }
+
+ public void testMethodWithStackAndException()
+ {
+ Aspect.reset();
+ POJO pojo = new POJO();
+ try
+ {
+ pojo.stackWithException();
+ fail("Should have had ThrownByTestException");
+ }
+ catch(ThrownByTestException expected)
+ {
+ }
+
+ assertEquals(1, Aspect.before);
+ assertEquals(0, Aspect.after);
+ assertEquals(1, Aspect.throwing);
+ assertEquals(1, Aspect.finaly);
+ assertEquals(1, Aspect.aroundBefore);
+ assertEquals(0, Aspect.aroundAfter);
+ assertEquals(1, Aspect.aroundThrowing);
+ assertEquals(1, Aspect.aroundFinally);
+ }
+}
\ No newline at end of file
Added: projects/aop/trunk/aop/src/test/org/jboss/test/aop/beforeafterthrowingstack/POJO.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/beforeafterthrowingstack/POJO.java (rev 0)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/beforeafterthrowingstack/POJO.java 2007-06-18 16:02:50 UTC (rev 63559)
@@ -0,0 +1,47 @@
+/*
+* 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.beforeafterthrowingstack;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class POJO
+{
+ public static boolean run;
+ public void noStack()
+ {
+ run = true;
+ }
+
+ public void stack()
+ {
+ run = true;
+ }
+
+ public void stackWithException() throws ThrownByTestException
+ {
+ run = true;
+ throw new ThrownByTestException();
+ }
+}
Added: projects/aop/trunk/aop/src/test/org/jboss/test/aop/beforeafterthrowingstack/ThrownByTestException.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/beforeafterthrowingstack/ThrownByTestException.java (rev 0)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/beforeafterthrowingstack/ThrownByTestException.java 2007-06-18 16:02:50 UTC (rev 63559)
@@ -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.beforeafterthrowingstack;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class ThrownByTestException extends Exception
+{
+
+}
Modified: projects/aop/trunk/aop/src/test/org/jboss/test/aop/stress/batf/BeforeAfterThrowingFinallyVersusAroundTestCase.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/stress/batf/BeforeAfterThrowingFinallyVersusAroundTestCase.java 2007-06-18 15:25:58 UTC (rev 63558)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/stress/batf/BeforeAfterThrowingFinallyVersusAroundTestCase.java 2007-06-18 16:02:50 UTC (rev 63559)
@@ -33,7 +33,8 @@
{
public static void main(String[] args)
- {
+ {int i = -5;
+ i*=(-1);
junit.textui.TestRunner.run(BeforeAfterThrowingFinallyVersusAroundTestCase.class);
}
More information about the jboss-cvs-commits
mailing list