diff --git a/build-release-pkgs.xml b/build-release-pkgs.xml index 89d783e6..7ff61530 100644 --- a/build-release-pkgs.xml +++ b/build-release-pkgs.xml @@ -86,10 +86,10 @@ - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -452,6 +494,63 @@ --> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/dd/scripts/misc/TestInterfaceInjection.txt b/tests/dd/scripts/misc/TestInterfaceInjection.txt new file mode 100644 index 00000000..3b07a3d2 --- /dev/null +++ b/tests/dd/scripts/misc/TestInterfaceInjection.txt @@ -0,0 +1,33 @@ +############################################################################## +# JBoss, Home of Professional Open Source +# Copyright 2009, Red Hat Middleware LLC, and individual contributors +# 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. +# +# @authors Andrew Dinn +# + +RULE test entry trigger for interface method +INTERFACE TestInterface +METHOD testMethod() +HELPER org.jboss.byteman.tests.helpers.Default +AT ENTRY +BIND test : Test = $0.getTest() +IF TRUE +DO test.log("ENTRY triggered in TestInterface.testMethod") +ENDRULE diff --git a/tests/dd/scripts/misc/TestOverridingInjection.txt b/tests/dd/scripts/misc/TestOverridingInjection.txt new file mode 100644 index 00000000..21f080d9 --- /dev/null +++ b/tests/dd/scripts/misc/TestOverridingInjection.txt @@ -0,0 +1,43 @@ +############################################################################## +# JBoss, Home of Professional Open Source +# Copyright 2009, Red Hat Middleware LLC, and individual contributors +# 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. +# +# @authors Andrew Dinn +# + +RULE test overriding entry trigger for constructor +CLASS ^TestEntryExitAuxiliary +METHOD (Test) +HELPER org.jboss.byteman.tests.helpers.Default +AT ENTRY +BIND test : Test = $1 +IF TRUE +DO test.log("ENTRY triggered in constructor") +ENDRULE + +RULE test overriding entry trigger for method +CLASS ^TestEntryExitAuxiliary +METHOD testMethod() +HELPER org.jboss.byteman.tests.helpers.Default +AT ENTRY +BIND test : Test = $0.getTest() +IF TRUE +DO test.log("ENTRY triggered in ^TestEntryExitAuxiliary.testMethod") +ENDRULE diff --git a/tests/dd/scripts/misc/TestOverridingInterfaceInjection.txt b/tests/dd/scripts/misc/TestOverridingInterfaceInjection.txt new file mode 100644 index 00000000..cde5737e --- /dev/null +++ b/tests/dd/scripts/misc/TestOverridingInterfaceInjection.txt @@ -0,0 +1,33 @@ +############################################################################## +# JBoss, Home of Professional Open Source +# Copyright 2009, Red Hat Middleware LLC, and individual contributors +# 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. +# +# @authors Andrew Dinn +# + +RULE test overriding entry trigger for interface method +INTERFACE ^TestInterface +METHOD testMethod() +HELPER org.jboss.byteman.tests.helpers.Default +AT ENTRY +BIND test : Test = $0.getTest() +IF TRUE +DO test.log("ENTRY triggered in ^TestInterface.testMethod") +ENDRULE diff --git a/tests/src/org/jboss/byteman/tests/auxiliary/TestEntryExitAuxiliary.java b/tests/src/org/jboss/byteman/tests/auxiliary/TestEntryExitAuxiliary.java index 4088d91b..61774a4c 100644 --- a/tests/src/org/jboss/byteman/tests/auxiliary/TestEntryExitAuxiliary.java +++ b/tests/src/org/jboss/byteman/tests/auxiliary/TestEntryExitAuxiliary.java @@ -28,8 +28,7 @@ /** * Auxiliary class used by entry and exit location test classes */ -public class TestEntryExitAuxiliary -{ +public class TestEntryExitAuxiliary implements TestInterface { protected Test test; public TestEntryExitAuxiliary(Test test) diff --git a/tests/src/org/jboss/byteman/tests/auxiliary/TestInterface.java b/tests/src/org/jboss/byteman/tests/auxiliary/TestInterface.java new file mode 100644 index 00000000..1a1d932e --- /dev/null +++ b/tests/src/org/jboss/byteman/tests/auxiliary/TestInterface.java @@ -0,0 +1,12 @@ +package org.jboss.byteman.tests.auxiliary; + +import org.jboss.byteman.tests.Test; + +/** + * Interface used to test injection through interfaces + */ +public interface TestInterface { + void testMethod(); + + Test getTest(); +} diff --git a/tests/src/org/jboss/byteman/tests/misc/TestInterfaceInjection.java b/tests/src/org/jboss/byteman/tests/misc/TestInterfaceInjection.java new file mode 100644 index 00000000..0a12bd4b --- /dev/null +++ b/tests/src/org/jboss/byteman/tests/misc/TestInterfaceInjection.java @@ -0,0 +1,56 @@ +package org.jboss.byteman.tests.misc; + +import org.jboss.byteman.tests.Test; +import org.jboss.byteman.tests.auxiliary.TestEntryExitAuxiliarySub; +import org.jboss.byteman.tests.auxiliary.TestEntryExitAuxiliary; + +/** + * Test class to ensure injection into interfaces without overriding works as expected + */ +public class TestInterfaceInjection extends Test +{ + public TestInterfaceInjection() + { + super(TestInterfaceInjection.class.getName()); + } + + public void test() + { + // this is much the same as the TestEntry code but we use an interface rule to inject + // rule trace into the parent testMethod. note we cannot inject into constructors via + // an interface rule + + try { + TestEntryExitAuxiliary testAuxiliary; + log("creating TestEntryExitAuxiliarySub"); + testAuxiliary = new TestEntryExitAuxiliarySub(this); + log("created TestEntryExitAuxiliarySub"); + log("calling TestEntryExitAuxiliarySub.testMethod"); + testAuxiliary.testMethod(); + log("called TestEntryExitAuxiliarySub.testMethod"); + } catch (Exception e) { + log(e); + } + + checkOutput(); + } + + @Override + public String getExpected() { + logExpected("creating TestEntryExitAuxiliarySub"); + // parent constructor will log first + logExpected("inside TestEntryExitAuxiliary(Test)"); + logExpected("inside TestEntryExitAuxiliarySub(Test)"); + logExpected("created TestEntryExitAuxiliarySub"); + // we should only see injected coed ein the superclass method + logExpected("calling TestEntryExitAuxiliarySub.testMethod"); + logExpected("inside TestEntryExitAuxiliarySub.testMethod"); + logExpected("calling TestEntryExitAuxiliary.testMethod"); + logExpected("ENTRY triggered in TestInterface.testMethod"); + logExpected("inside TestEntryExitAuxiliary.testMethod"); + logExpected("called TestEntryExitAuxiliary.testMethod"); + logExpected("called TestEntryExitAuxiliarySub.testMethod"); + + return super.getExpected(); + } +} \ No newline at end of file diff --git a/tests/src/org/jboss/byteman/tests/misc/TestOverridingInjection.java b/tests/src/org/jboss/byteman/tests/misc/TestOverridingInjection.java new file mode 100644 index 00000000..d4f3a69d --- /dev/null +++ b/tests/src/org/jboss/byteman/tests/misc/TestOverridingInjection.java @@ -0,0 +1,60 @@ +package org.jboss.byteman.tests.misc; + +import org.jboss.byteman.tests.Test; +import org.jboss.byteman.tests.auxiliary.TestEntryExitAuxiliarySub; +import org.jboss.byteman.tests.auxiliary.TestEntryExitAuxiliary; + +/** + * Test class to ensure injection into overriding methods works as expected + */ +public class TestOverridingInjection extends Test +{ + public TestOverridingInjection() + { + super(TestOverridingInjection.class.getName()); + } + + public void test() + { + // this is much the same as the TestEntry code but we use a single rule to inject + // rule trace into both constructors. ditto for both implementations of testMethod. + + try { + TestEntryExitAuxiliary testAuxiliary; + log("creating TestEntryExitAuxiliarySub"); + testAuxiliary = new TestEntryExitAuxiliarySub(this); + log("created TestEntryExitAuxiliarySub"); + log("calling TestEntryExitAuxiliarySub.testMethod"); + testAuxiliary.testMethod(); + log("called TestEntryExitAuxiliarySub.testMethod"); + } catch (Exception e) { + log(e); + } + + checkOutput(); + } + + @Override + public String getExpected() { + logExpected("creating TestEntryExitAuxiliarySub"); + // super constructor should log first then the sub constructor + logExpected("ENTRY triggered in constructor"); + logExpected("inside TestEntryExitAuxiliary(Test)"); + logExpected("ENTRY triggered in constructor"); + logExpected("inside TestEntryExitAuxiliarySub(Test)"); + logExpected("created TestEntryExitAuxiliarySub"); + // injected ENTRY code should log in subclass method code then + // body of subclass hsoudl log then injected ENTRY code in superclass method + // then body of superclass method + logExpected("calling TestEntryExitAuxiliarySub.testMethod"); + logExpected("ENTRY triggered in ^TestEntryExitAuxiliary.testMethod"); + logExpected("inside TestEntryExitAuxiliarySub.testMethod"); + logExpected("calling TestEntryExitAuxiliary.testMethod"); + logExpected("ENTRY triggered in ^TestEntryExitAuxiliary.testMethod"); + logExpected("inside TestEntryExitAuxiliary.testMethod"); + logExpected("called TestEntryExitAuxiliary.testMethod"); + logExpected("called TestEntryExitAuxiliarySub.testMethod"); + + return super.getExpected(); + } +} diff --git a/tests/src/org/jboss/byteman/tests/misc/TestOverridingInterfaceInjection.java b/tests/src/org/jboss/byteman/tests/misc/TestOverridingInterfaceInjection.java new file mode 100644 index 00000000..2fb9575b --- /dev/null +++ b/tests/src/org/jboss/byteman/tests/misc/TestOverridingInterfaceInjection.java @@ -0,0 +1,57 @@ +package org.jboss.byteman.tests.misc; + +import org.jboss.byteman.tests.Test; +import org.jboss.byteman.tests.auxiliary.TestEntryExitAuxiliarySub; +import org.jboss.byteman.tests.auxiliary.TestEntryExitAuxiliary; + +/** + * Test class to ensure injection into interfaces with overriding works as expected + */ +public class TestOverridingInterfaceInjection extends Test +{ + public TestOverridingInterfaceInjection() + { + super(TestOverridingInterfaceInjection.class.getName()); + } + + public void test() + { + // this is much the same as the TestEntry code but we use an interface rule to inject + // rule trace into the parent testMethod. note we cannot inject into constructors via + // an interface rule + + try { + TestEntryExitAuxiliary testAuxiliary; + log("creating TestEntryExitAuxiliarySub"); + testAuxiliary = new TestEntryExitAuxiliarySub(this); + log("created TestEntryExitAuxiliarySub"); + log("calling TestEntryExitAuxiliarySub.testMethod"); + testAuxiliary.testMethod(); + log("called TestEntryExitAuxiliarySub.testMethod"); + } catch (Exception e) { + log(e); + } + + checkOutput(); + } + + @Override + public String getExpected() { + logExpected("creating TestEntryExitAuxiliarySub"); + // parent constructor will log first + logExpected("inside TestEntryExitAuxiliary(Test)"); + logExpected("inside TestEntryExitAuxiliarySub(Test)"); + logExpected("created TestEntryExitAuxiliarySub"); + // we see injected coede in the subclass method and then in the superclass method + logExpected("calling TestEntryExitAuxiliarySub.testMethod"); + logExpected("ENTRY triggered in ^TestInterface.testMethod"); + logExpected("inside TestEntryExitAuxiliarySub.testMethod"); + logExpected("calling TestEntryExitAuxiliary.testMethod"); + logExpected("ENTRY triggered in ^TestInterface.testMethod"); + logExpected("inside TestEntryExitAuxiliary.testMethod"); + logExpected("called TestEntryExitAuxiliary.testMethod"); + logExpected("called TestEntryExitAuxiliarySub.testMethod"); + + return super.getExpected(); + } +} \ No newline at end of file