[jboss-cvs] JBossAS SVN: r59742 - in projects/aop/trunk/aop/src: test/org/jboss/test/aop/regression/jbaop336callnpe and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Jan 17 20:52:33 EST 2007
Author: flavia.rainone at jboss.com
Date: 2007-01-17 20:52:33 -0500 (Wed, 17 Jan 2007)
New Revision: 59742
Added:
projects/aop/trunk/aop/src/test/org/jboss/test/aop/regression/jbaop336callnpe/CallerNPETestCase.java
projects/aop/trunk/aop/src/test/org/jboss/test/aop/regression/jbaop336callnpe/Log.java
projects/aop/trunk/aop/src/test/org/jboss/test/aop/regression/jbaop336callnpe/LogInterceptor.java
projects/aop/trunk/aop/src/test/org/jboss/test/aop/regression/jbaop336callnpe/POJO.java
Modified:
projects/aop/trunk/aop/src/resources/test/regression/jboss-aop.xml
Log:
[JBAOP-336] Test for caller pointcuts
Modified: projects/aop/trunk/aop/src/resources/test/regression/jboss-aop.xml
===================================================================
--- projects/aop/trunk/aop/src/resources/test/regression/jboss-aop.xml 2007-01-18 01:52:20 UTC (rev 59741)
+++ projects/aop/trunk/aop/src/resources/test/regression/jboss-aop.xml 2007-01-18 01:52:33 UTC (rev 59742)
@@ -155,4 +155,14 @@
</bind>
<prepare expr="all(org.jboss.test.aop.regression.jbaop316annotationsinwrapperonly.POJO)"/>
-</aop>
+
+ <interceptor class="org.jboss.test.aop.regression.jbaop336callnpe.LogInterceptor" scope="PER_INSTANCE"/>
+
+ <bind pointcut="call(org.jboss.test.aop.regression.jbaop336callnpe.Log->new(java.lang.String))">
+ <interceptor-ref name="org.jboss.test.aop.regression.jbaop336callnpe.LogInterceptor"/>
+ </bind>
+
+ <bind pointcut="call(void org.jboss.test.aop.regression.jbaop336callnpe.Log->overwriteFile(java.lang.String))">
+ <interceptor-ref name="org.jboss.test.aop.regression.jbaop336callnpe.LogInterceptor"/>
+ </bind>
+</aop>
\ No newline at end of file
Added: projects/aop/trunk/aop/src/test/org/jboss/test/aop/regression/jbaop336callnpe/CallerNPETestCase.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/regression/jbaop336callnpe/CallerNPETestCase.java (rev 0)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/regression/jbaop336callnpe/CallerNPETestCase.java 2007-01-18 01:52:33 UTC (rev 59742)
@@ -0,0 +1,84 @@
+/*
+ * 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.regression.jbaop336callnpe;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+
+import org.jboss.aop.Advised;
+
+
+/**
+ * http://jira.jboss.com/jira/browse/JBAOP-316
+ *
+ * @author <a href="mailto:kabir.khan at jboss.org">Kabir Khan</a>
+ */
+public class CallerNPETestCase extends junit.framework.TestCase
+{
+ public static void main(String[] args)
+ {
+ TestRunner.run(suite());
+ }
+
+ public static Test suite()
+ {
+ TestSuite suite = new TestSuite("CallerNPETestCase");
+ suite.addTestSuite(CallerNPETestCase.class);
+ return suite;
+ }
+
+ public CallerNPETestCase(String name)
+ {
+ super(name);
+ }
+
+ public void testConstructorCallerInterceptor1() throws Exception
+ {
+ POJO pojo = new POJO("XYZ");
+ assertEquals("XYZ", LogInterceptor.logFile);
+ assertNotNull(((Advised) pojo)._getInstanceAdvisor());
+ }
+
+ public void testConstructorCallerInterceptor2() throws Exception
+ {
+ POJO pojo = new POJO("XYZ", "ABC");
+ assertEquals("ABC", LogInterceptor.logFile);
+ assertNotNull(((Advised) pojo)._getInstanceAdvisor());
+ }
+
+ public void testMethodCallerInterceptor1()
+ {
+ POJO pojo = new POJO();
+ pojo.recreateLog("UVW");
+ assertEquals("UVW", LogInterceptor.logFile);
+ assertNotNull(((Advised) pojo)._getInstanceAdvisor());
+ }
+
+ public void testMethodCallerInterceptor2()
+ {
+ POJO pojo = new POJO();
+ pojo.setLogFile("DEF");
+ assertEquals("DEF", LogInterceptor.logFile);
+ assertNotNull(((Advised) pojo)._getInstanceAdvisor());
+ }
+}
\ No newline at end of file
Added: projects/aop/trunk/aop/src/test/org/jboss/test/aop/regression/jbaop336callnpe/Log.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/regression/jbaop336callnpe/Log.java (rev 0)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/regression/jbaop336callnpe/Log.java 2007-01-18 01:52:33 UTC (rev 59742)
@@ -0,0 +1,46 @@
+/*
+* 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.regression.jbaop336callnpe;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ */
+public class Log
+{
+ String logFile;
+
+ public Log(String logFile)
+ {
+ this.logFile = logFile;
+ }
+
+ public Log()
+ {
+ this.logFile = null;
+ }
+
+ public void overwriteFile(String logFile)
+ {
+ this.logFile = logFile;
+ }
+}
Added: projects/aop/trunk/aop/src/test/org/jboss/test/aop/regression/jbaop336callnpe/LogInterceptor.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/regression/jbaop336callnpe/LogInterceptor.java (rev 0)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/regression/jbaop336callnpe/LogInterceptor.java 2007-01-18 01:52:33 UTC (rev 59742)
@@ -0,0 +1,66 @@
+/*
+ * 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.regression.jbaop336callnpe;
+
+import org.jboss.aop.advice.Interceptor;
+import org.jboss.aop.joinpoint.ConstructorCalledByConstructorInvocation;
+import org.jboss.aop.joinpoint.ConstructorCalledByMethodInvocation;
+import org.jboss.aop.joinpoint.Invocation;
+import org.jboss.aop.joinpoint.MethodCalledByConstructorInvocation;
+import org.jboss.aop.joinpoint.MethodCalledByMethodInvocation;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ */
+public class LogInterceptor implements Interceptor
+{
+ public static String logFile;
+
+ public String getName()
+ {
+ return this.getClass().getName();
+ }
+
+ public Object invoke(Invocation invocation) throws Throwable
+ {
+ if (invocation instanceof ConstructorCalledByConstructorInvocation)
+ {
+ logFile = (String)((ConstructorCalledByConstructorInvocation)invocation).getArguments()[0];
+ }
+ else if (invocation instanceof ConstructorCalledByMethodInvocation)
+ {
+ logFile = (String) ((ConstructorCalledByMethodInvocation) invocation).getArguments()[0];
+ }
+ else if (invocation instanceof MethodCalledByConstructorInvocation)
+ {
+ logFile = (String)((MethodCalledByConstructorInvocation)invocation).getArguments()[0];
+ }
+ else if (invocation instanceof MethodCalledByMethodInvocation)
+ {
+ logFile = (String) ((MethodCalledByMethodInvocation) invocation).getArguments()[0];
+ }
+
+ return invocation.invokeNext();
+ }
+
+}
Added: projects/aop/trunk/aop/src/test/org/jboss/test/aop/regression/jbaop336callnpe/POJO.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/regression/jbaop336callnpe/POJO.java (rev 0)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/regression/jbaop336callnpe/POJO.java 2007-01-18 01:52:33 UTC (rev 59742)
@@ -0,0 +1,57 @@
+/*
+ * 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.regression.jbaop336callnpe;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ */
+public class POJO
+{
+ Log log;
+
+ public POJO()
+ {
+ log = new Log();
+ }
+
+ public POJO(String logFile)
+ {
+ log = new Log(logFile);
+ }
+
+ public POJO(String logFile, String newLogFile)
+ {
+ log = new Log(logFile);
+ log.overwriteFile(newLogFile);
+ }
+
+ public void recreateLog(String logFile)
+ {
+ log = new Log(logFile);
+ }
+
+ public void setLogFile(String logFile)
+ {
+ log.overwriteFile(logFile);
+ }
+}
More information about the jboss-cvs-commits
mailing list