From: Kabir K. <kk...@jb...> - 2006-07-04 17:55:53
|
User: kkhan Date: 06/07/04 13:55:51 Modified: src/tests/org/jboss/test/microcontainer/test InterceptorWithOverriddenMethodAnnotationDependencyTestCase.java Added: src/tests/org/jboss/test/microcontainer/test InterceptorWithOverriddenMethodAnnotationDependencyForChildTestCase.java InterceptorWithOverriddenMethodAnnotationDependencyBaseTest.java Log: [JBAOP-239] More tests for dependencies from annotations. Test annotated methods in superclass Revision Changes Path 1.2 +8 -202 aop-mc-int/src/tests/org/jboss/test/microcontainer/test/InterceptorWithOverriddenMethodAnnotationDependencyTestCase.java (In the diff below, changes in quantity of whitespace are not shown.) Index: InterceptorWithOverriddenMethodAnnotationDependencyTestCase.java =================================================================== RCS file: /cvsroot/jboss/aop-mc-int/src/tests/org/jboss/test/microcontainer/test/InterceptorWithOverriddenMethodAnnotationDependencyTestCase.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -b -r1.1 -r1.2 --- InterceptorWithOverriddenMethodAnnotationDependencyTestCase.java 4 Jul 2006 13:18:48 -0000 1.1 +++ InterceptorWithOverriddenMethodAnnotationDependencyTestCase.java 4 Jul 2006 17:55:51 -0000 1.2 @@ -24,14 +24,7 @@ import junit.framework.Test; import junit.textui.TestRunner; -import org.jboss.aop.microcontainer.junit.AOPMicrocontainerTest; -import org.jboss.dependency.spi.ControllerState; -import org.jboss.kernel.spi.dependency.KernelControllerContext; -import org.jboss.test.microcontainer.support.InterceptorWithAnnotationDependency; -import org.jboss.test.microcontainer.support.OverriddenPropertyAnnotatedBean; -import org.jboss.test.microcontainer.support.SimpleBean; - -public class InterceptorWithOverriddenMethodAnnotationDependencyTestCase extends AOPMicrocontainerTest +public class InterceptorWithOverriddenMethodAnnotationDependencyTestCase extends InterceptorWithOverriddenMethodAnnotationDependencyBaseTest { public static void main(String[] args) { @@ -48,207 +41,20 @@ super(name); } - public void testInterceptorWithAnnotationDependencyCorrectOrder() throws Exception - { - deploy("InterceptorWithOverriddenMethodAnnotationDependencyTestCaseNotAutomatic0.xml"); - deploy("InterceptorWithOverriddenMethodAnnotationDependencyTestCaseNotAutomatic1.xml"); - try - { - SimpleBean dependency1 = (SimpleBean) getBean("Dependency1"); - assertNotNull(dependency1); - SimpleBean dependency2 = (SimpleBean) getBean("Dependency2"); - assertNotNull(dependency2); - deploy("InterceptorWithOverriddenMethodAnnotationDependencyTestCaseNotAutomatic2.xml"); - try - { - checkInterceptedAndInjected("Depends1", "A", dependency1); - checkInterceptedAndInjected("Depends1", "B", dependency1); - checkInterceptedAndInjected("Depends2", "B", dependency2); - checkInterceptedAndInjected("Depends2", "B", dependency2); - checkInterceptedAndInjected("Depends1And2", "A", dependency1); - checkInterceptedAndInjected("Depends1And2", "B", dependency2); - checkNotInstalledAndDescribed("NotDeployable"); - checkNotInstalledAndDescribed("NotDeployable1"); - checkNotInstalledAndDescribed("NotDeployable2"); - } - finally - { - undeploy("InterceptorWithOverriddenMethodAnnotationDependencyTestCaseNotAutomatic2.xml"); - } - } - finally + protected String getDependency1DD() { - undeploy("InterceptorWithOverriddenMethodAnnotationDependencyTestCaseNotAutomatic0.xml"); - undeploy("InterceptorWithOverriddenMethodAnnotationDependencyTestCaseNotAutomatic1.xml"); + return "InterceptorWithOverriddenMethodAnnotationDependencyTestCaseNotAutomatic0.xml"; } - } - - public void testInterceptorWithAnnotationDependencyWrongOrderAndRedeploy() throws Exception - { - deploy("InterceptorWithOverriddenMethodAnnotationDependencyTestCaseNotAutomatic2.xml"); - try - { - checkNotInstalledAndDescribed("Depends1"); - checkNotInstalledAndDescribed("Depends2"); - checkNotInstalledAndDescribed("Depends1And2"); - checkNotInstalledAndDescribed("NotDeployable"); - checkNotInstalledAndDescribed("NotDeployable1"); - checkNotInstalledAndDescribed("NotDeployable2"); - deploy("InterceptorWithOverriddenMethodAnnotationDependencyTestCaseNotAutomatic0.xml"); - try + protected String getDependency2DD() { - SimpleBean dependency1 = (SimpleBean) getBean("Dependency1"); - assertNotNull(dependency1); - checkInterceptedAndInjected("Depends1", "A", dependency1); - checkInterceptedAndInjected("Depends1", "B", dependency1); - checkNotInstalledAndDescribed("Depends2"); - checkNotInstalledAndDescribed("Depends1And2"); - checkNotInstalledAndDescribed("NotDeployable"); - checkNotInstalledAndDescribed("NotDeployable1"); - checkNotInstalledAndDescribed("NotDeployable2"); - - } - finally - { - undeploy("InterceptorWithOverriddenMethodAnnotationDependencyTestCaseNotAutomatic0.xml"); - checkNotInstalledAndDescribed("Depends1"); - checkNotInstalledAndDescribed("Depends2"); - checkNotInstalledAndDescribed("Depends1And2"); - checkNotInstalledAndDescribed("NotDeployable"); - checkNotInstalledAndDescribed("NotDeployable1"); - checkNotInstalledAndDescribed("NotDeployable2"); - } - - deploy("InterceptorWithOverriddenMethodAnnotationDependencyTestCaseNotAutomatic1.xml"); - try - { - SimpleBean dependency2 = (SimpleBean) getBean("Dependency2"); - assertNotNull(dependency2); - checkNotInstalledAndDescribed("Depends1"); - checkInterceptedAndInjected("Depends2", "A", dependency2); - checkInterceptedAndInjected("Depends2", "B", dependency2); - checkNotInstalledAndDescribed("Depends1And2"); - checkNotInstalledAndDescribed("NotDeployable"); - checkNotInstalledAndDescribed("NotDeployable1"); - checkNotInstalledAndDescribed("NotDeployable2"); - - } - finally - { - undeploy("InterceptorWithOverriddenMethodAnnotationDependencyTestCaseNotAutomatic1.xml"); - checkNotInstalledAndDescribed("Depends1"); - checkNotInstalledAndDescribed("Depends2"); - checkNotInstalledAndDescribed("Depends1And2"); - checkNotInstalledAndDescribed("NotDeployable"); - checkNotInstalledAndDescribed("NotDeployable1"); - checkNotInstalledAndDescribed("NotDeployable2"); - } - - deploy("InterceptorWithOverriddenMethodAnnotationDependencyTestCaseNotAutomatic0.xml"); - deploy("InterceptorWithOverriddenMethodAnnotationDependencyTestCaseNotAutomatic1.xml"); - try - { - SimpleBean dependency1 = (SimpleBean) getBean("Dependency1"); - assertNotNull(dependency1); - SimpleBean dependency2 = (SimpleBean) getBean("Dependency2"); - assertNotNull(dependency2); - checkInterceptedAndInjected("Depends1", "A", dependency1); - checkInterceptedAndInjected("Depends1", "B", dependency1); - checkInterceptedAndInjected("Depends2", "A", dependency2); - checkInterceptedAndInjected("Depends2", "B", dependency2); - checkInterceptedAndInjected("Depends1And2", "A", dependency1); - checkInterceptedAndInjected("Depends1And2", "B", dependency2); - checkNotInstalledAndDescribed("NotDeployable"); - checkNotInstalledAndDescribed("NotDeployable1"); - checkNotInstalledAndDescribed("NotDeployable2"); - - } - finally - { - undeploy("InterceptorWithOverriddenMethodAnnotationDependencyTestCaseNotAutomatic0.xml"); - undeploy("InterceptorWithOverriddenMethodAnnotationDependencyTestCaseNotAutomatic1.xml"); - checkNotInstalledAndDescribed("Depends1"); - checkNotInstalledAndDescribed("Depends2"); - checkNotInstalledAndDescribed("Depends1And2"); - checkNotInstalledAndDescribed("NotDeployable"); - checkNotInstalledAndDescribed("NotDeployable1"); - checkNotInstalledAndDescribed("NotDeployable2"); - } - } - finally - { - undeploy("InterceptorWithOverriddenMethodAnnotationDependencyTestCaseNotAutomatic2.xml"); - checkNotInstalledAndNotDescribed("Depends1"); - checkNotInstalledAndNotDescribed("Depends2"); - checkNotInstalledAndNotDescribed("Depends1And2"); - checkNotInstalledAndNotDescribed("NotDeployable"); - checkNotInstalledAndNotDescribed("NotDeployable1"); - checkNotInstalledAndNotDescribed("NotDeployable2"); - } + return "InterceptorWithOverriddenMethodAnnotationDependencyTestCaseNotAutomatic1.xml"; } - protected void configureLogging() + protected String getMainDD() { - //enableTrace("org.jboss.kernel.plugins.dependency"); + return "InterceptorWithOverriddenMethodAnnotationDependencyTestCaseNotAutomatic2.xml"; } - private void checkInterceptedAndInjected(String name, String property, SimpleBean dependency) - { - InterceptorWithAnnotationDependency.intercepted = null; - OverriddenPropertyAnnotatedBean bean = (OverriddenPropertyAnnotatedBean) getBean(name); - assertNotNull(bean); - - if (property.equals("A")) - { - bean.setPropertyA(5); - } - else if (property.equals("B")) - { - bean.setPropertyB(5); - } - else - { - throw new RuntimeException("Invalid property passed in"); - } - - assertTrue(dependency == InterceptorWithAnnotationDependency.intercepted); - } - - private void checkNotInstalledAndNotDescribed(String name) - { - try - { - getBean(name); - fail("'" + name + "' should not be installed yet"); - } - catch (IllegalStateException expected) - { - } - - try - { - getBean(name, ControllerState.DESCRIBED); - fail("'" + name + "' should not be described"); - } - catch(IllegalStateException expected) - { - - } - } - - private void checkNotInstalledAndDescribed(String name) - { - try - { - getBean(name); - fail("'" + name + "' should not be installed yet"); - } - catch (IllegalStateException expected) - { - KernelControllerContext context = getControllerContext(name, ControllerState.DESCRIBED); - assertNotNull(context); - } - } } 1.1 date: 2006/07/04 17:55:51; author: kkhan; state: Exp;aop-mc-int/src/tests/org/jboss/test/microcontainer/test/InterceptorWithOverriddenMethodAnnotationDependencyForChildTestCase.java Index: InterceptorWithOverriddenMethodAnnotationDependencyForChildTestCase.java =================================================================== /* * 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.microcontainer.test; import junit.framework.Test; import junit.textui.TestRunner; public class InterceptorWithOverriddenMethodAnnotationDependencyForChildTestCase extends InterceptorWithOverriddenMethodAnnotationDependencyBaseTest { public static void main(String[] args) { TestRunner.run(suite()); } public static Test suite() { return suite(InterceptorWithOverriddenMethodAnnotationDependencyForChildTestCase.class); } public InterceptorWithOverriddenMethodAnnotationDependencyForChildTestCase(String name) { super(name); } protected String getDependency1DD() { return "InterceptorWithOverriddenMethodAnnotationDependencyForChildTestCaseNotAutomatic0.xml"; } protected String getDependency2DD() { return "InterceptorWithOverriddenMethodAnnotationDependencyForChildTestCaseNotAutomatic1.xml"; } protected String getMainDD() { return "InterceptorWithOverriddenMethodAnnotationDependencyForChildTestCaseNotAutomatic2.xml"; } } 1.1 date: 2006/07/04 17:55:51; author: kkhan; state: Exp;aop-mc-int/src/tests/org/jboss/test/microcontainer/test/InterceptorWithOverriddenMethodAnnotationDependencyBaseTest.java Index: InterceptorWithOverriddenMethodAnnotationDependencyBaseTest.java =================================================================== /* * 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.microcontainer.test; import org.jboss.aop.microcontainer.junit.AOPMicrocontainerTest; import org.jboss.dependency.spi.ControllerState; import org.jboss.kernel.spi.dependency.KernelControllerContext; import org.jboss.test.microcontainer.support.InterceptorWithAnnotationDependency; import org.jboss.test.microcontainer.support.OverriddenPropertyAnnotatedBean; import org.jboss.test.microcontainer.support.SimpleBean; public abstract class InterceptorWithOverriddenMethodAnnotationDependencyBaseTest extends AOPMicrocontainerTest { public InterceptorWithOverriddenMethodAnnotationDependencyBaseTest(String name) { super(name); } public void testInterceptorWithAnnotationDependencyCorrectOrder() throws Exception { deploy(getDependency1DD()); deploy(getDependency2DD()); try { SimpleBean dependency1 = (SimpleBean) getBean("Dependency1"); assertNotNull(dependency1); SimpleBean dependency2 = (SimpleBean) getBean("Dependency2"); assertNotNull(dependency2); deploy(getMainDD()); try { checkInterceptedAndInjected("Depends1", "A", dependency1); checkInterceptedAndInjected("Depends1", "B", dependency1); checkInterceptedAndInjected("Depends2", "B", dependency2); checkInterceptedAndInjected("Depends2", "B", dependency2); checkInterceptedAndInjected("Depends1And2", "A", dependency1); checkInterceptedAndInjected("Depends1And2", "B", dependency2); checkNotInstalledAndDescribed("NotDeployable"); checkNotInstalledAndDescribed("NotDeployable1"); checkNotInstalledAndDescribed("NotDeployable2"); } finally { undeploy(getMainDD()); } } finally { undeploy(getDependency1DD()); undeploy(getDependency2DD()); } } public void testInterceptorWithAnnotationDependencyWrongOrderAndRedeploy() throws Exception { deploy(getMainDD()); try { checkNotInstalledAndDescribed("Depends1"); checkNotInstalledAndDescribed("Depends2"); checkNotInstalledAndDescribed("Depends1And2"); checkNotInstalledAndDescribed("NotDeployable"); checkNotInstalledAndDescribed("NotDeployable1"); checkNotInstalledAndDescribed("NotDeployable2"); deploy(getDependency1DD()); try { SimpleBean dependency1 = (SimpleBean) getBean("Dependency1"); assertNotNull(dependency1); checkInterceptedAndInjected("Depends1", "A", dependency1); checkInterceptedAndInjected("Depends1", "B", dependency1); checkNotInstalledAndDescribed("Depends2"); checkNotInstalledAndDescribed("Depends1And2"); checkNotInstalledAndDescribed("NotDeployable"); checkNotInstalledAndDescribed("NotDeployable1"); checkNotInstalledAndDescribed("NotDeployable2"); } finally { undeploy(getDependency1DD()); checkNotInstalledAndDescribed("Depends1"); checkNotInstalledAndDescribed("Depends2"); checkNotInstalledAndDescribed("Depends1And2"); checkNotInstalledAndDescribed("NotDeployable"); checkNotInstalledAndDescribed("NotDeployable1"); checkNotInstalledAndDescribed("NotDeployable2"); } deploy(getDependency2DD()); try { SimpleBean dependency2 = (SimpleBean) getBean("Dependency2"); assertNotNull(dependency2); checkNotInstalledAndDescribed("Depends1"); checkInterceptedAndInjected("Depends2", "A", dependency2); checkInterceptedAndInjected("Depends2", "B", dependency2); checkNotInstalledAndDescribed("Depends1And2"); checkNotInstalledAndDescribed("NotDeployable"); checkNotInstalledAndDescribed("NotDeployable1"); checkNotInstalledAndDescribed("NotDeployable2"); } finally { undeploy(getDependency2DD()); checkNotInstalledAndDescribed("Depends1"); checkNotInstalledAndDescribed("Depends2"); checkNotInstalledAndDescribed("Depends1And2"); checkNotInstalledAndDescribed("NotDeployable"); checkNotInstalledAndDescribed("NotDeployable1"); checkNotInstalledAndDescribed("NotDeployable2"); } deploy(getDependency1DD()); deploy(getDependency2DD()); try { SimpleBean dependency1 = (SimpleBean) getBean("Dependency1"); assertNotNull(dependency1); SimpleBean dependency2 = (SimpleBean) getBean("Dependency2"); assertNotNull(dependency2); checkInterceptedAndInjected("Depends1", "A", dependency1); checkInterceptedAndInjected("Depends1", "B", dependency1); checkInterceptedAndInjected("Depends2", "A", dependency2); checkInterceptedAndInjected("Depends2", "B", dependency2); checkInterceptedAndInjected("Depends1And2", "A", dependency1); checkInterceptedAndInjected("Depends1And2", "B", dependency2); checkNotInstalledAndDescribed("NotDeployable"); checkNotInstalledAndDescribed("NotDeployable1"); checkNotInstalledAndDescribed("NotDeployable2"); } finally { undeploy(getDependency1DD()); undeploy(getDependency2DD()); checkNotInstalledAndDescribed("Depends1"); checkNotInstalledAndDescribed("Depends2"); checkNotInstalledAndDescribed("Depends1And2"); checkNotInstalledAndDescribed("NotDeployable"); checkNotInstalledAndDescribed("NotDeployable1"); checkNotInstalledAndDescribed("NotDeployable2"); } } finally { undeploy(getMainDD()); checkNotInstalledAndNotDescribed("Depends1"); checkNotInstalledAndNotDescribed("Depends2"); checkNotInstalledAndNotDescribed("Depends1And2"); checkNotInstalledAndNotDescribed("NotDeployable"); checkNotInstalledAndNotDescribed("NotDeployable1"); checkNotInstalledAndNotDescribed("NotDeployable2"); } } protected void configureLogging() { //enableTrace("org.jboss.kernel.plugins.dependency"); } private void checkInterceptedAndInjected(String name, String property, SimpleBean dependency) { InterceptorWithAnnotationDependency.intercepted = null; OverriddenPropertyAnnotatedBean bean = (OverriddenPropertyAnnotatedBean) getBean(name); assertNotNull(bean); if (property.equals("A")) { bean.setPropertyA(5); } else if (property.equals("B")) { bean.setPropertyB(5); } else { throw new RuntimeException("Invalid property passed in"); } assertTrue(dependency == InterceptorWithAnnotationDependency.intercepted); } private void checkNotInstalledAndNotDescribed(String name) { try { getBean(name); fail("'" + name + "' should not be installed yet"); } catch (IllegalStateException expected) { } try { getBean(name, ControllerState.DESCRIBED); fail("'" + name + "' should not be described"); } catch(IllegalStateException expected) { } } private void checkNotInstalledAndDescribed(String name) { try { getBean(name); fail("'" + name + "' should not be installed yet"); } catch (IllegalStateException expected) { KernelControllerContext context = getControllerContext(name, ControllerState.DESCRIBED); assertNotNull(context); } } protected abstract String getDependency1DD(); protected abstract String getDependency2DD(); protected abstract String getMainDD(); } |