[jboss-cvs] JBossAS SVN: r71088 - in projects/microcontainer/trunk/aop-mc-int/src: tests/org/jboss/test/microcontainer/beans and 4 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Mar 20 13:34:27 EDT 2008
Author: kabir.khan at jboss.com
Date: 2008-03-20 13:34:27 -0400 (Thu, 20 Mar 2008)
New Revision: 71088
Added:
projects/microcontainer/trunk/aop-mc-int/src/resources/tests/org/jboss/test/microcontainer/beans/test/FieldAccessTestCase.xml
projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/beans/support/
projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/beans/support/AccessBean.java
projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/beans/test/FieldAccessTestCase.java
projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/support/AnnotatedBean.java
projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/support/Marker.java
Removed:
projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/test/InitialLifecycleCallbackWithDependencyAopTestCase.java
projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/test/InitialLifecycleCallbackWithDependencyDeploymentTestCase.java
projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/test/InitialLifecycleCallbackWithDependencyTest.java
Log:
Rollback the JAXB changes to the tests - I had deleted Ales's FieldAccessTestCase
Added: projects/microcontainer/trunk/aop-mc-int/src/resources/tests/org/jboss/test/microcontainer/beans/test/FieldAccessTestCase.xml
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/resources/tests/org/jboss/test/microcontainer/beans/test/FieldAccessTestCase.xml (rev 0)
+++ projects/microcontainer/trunk/aop-mc-int/src/resources/tests/org/jboss/test/microcontainer/beans/test/FieldAccessTestCase.xml 2008-03-20 17:34:27 UTC (rev 71088)
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+ <bean name="AspectManager" class="org.jboss.aop.AspectManager">
+ <constructor factoryClass="org.jboss.aop.AspectManager" factoryMethod="instance"/>
+ </bean>
+
+ <interceptor xmlns="urn:jboss:aop-beans:1.0" class="org.jboss.test.microcontainer.beans.TestInterceptor"/>
+
+ <bind xmlns="urn:jboss:aop-beans:1.0" pointcut="execution(* org.jboss.test.microcontainer.beans.support.AccessBean->*(..))">
+ <interceptor-ref name="org.jboss.test.microcontainer.beans.TestInterceptor"/>
+ </bind>
+
+ <bean name="private" class="org.jboss.test.microcontainer.beans.support.AccessBean" access-mode="ALL">
+ <property name="priString">foobar</property>
+ </bean>
+
+ <bean name="protected" class="org.jboss.test.microcontainer.beans.support.AccessBean" access-mode="ALL">
+ <property name="protString">foobar</property>
+ </bean>
+
+ <bean name="public" class="org.jboss.test.microcontainer.beans.support.AccessBean" access-mode="ALL">
+ <property name="pubString">foobar</property>
+ </bean>
+
+</deployment>
Added: projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/beans/support/AccessBean.java
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/beans/support/AccessBean.java (rev 0)
+++ projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/beans/support/AccessBean.java 2008-03-20 17:34:27 UTC (rev 71088)
@@ -0,0 +1,48 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.beans.support;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class AccessBean
+{
+ @SuppressWarnings("unused")
+ private String priString;
+ protected String protString;
+ public String pubString;
+
+ public String getPriString()
+ {
+ return priString;
+ }
+
+ public String getProtString()
+ {
+ return protString;
+ }
+
+ public String getPubString()
+ {
+ return pubString;
+ }
+}
Added: projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/beans/test/FieldAccessTestCase.java
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/beans/test/FieldAccessTestCase.java (rev 0)
+++ projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/beans/test/FieldAccessTestCase.java 2008-03-20 17:34:27 UTC (rev 71088)
@@ -0,0 +1,86 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.beans.test;
+
+import junit.framework.Test;
+import org.jboss.test.aop.junit.AbstractTypeTest;
+import org.jboss.test.aop.junit.AbstractTypeTestDelegate;
+import org.jboss.test.microcontainer.beans.support.AccessBean;
+
+/**
+ * AOP field test case.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class FieldAccessTestCase extends AbstractTypeTest
+{
+ public FieldAccessTestCase(String name)
+ {
+ super(name);
+ }
+
+ public static Test suite()
+ {
+ return suite(FieldAccessTestCase.class);
+ }
+
+ protected void testAccessBean(String name) throws Throwable
+ {
+ AccessBean bean = getBean(name, AccessBean.class);
+ AbstractTypeTestDelegate.Type type = getType(name);
+ if (type == AbstractTypeTestDelegate.Type.PROXY)
+ {
+ assertNull(bean.getPriString());
+ assertNull(bean.getProtString());
+ assertNull(bean.getPubString());
+ }
+ else
+ {
+ assertEquals("foobar", concat(bean));
+ }
+ }
+
+ private String concat(AccessBean bean)
+ {
+ String string = "";
+ if (bean.getPriString() != null)
+ string += bean.getPriString();
+ if (bean.getProtString() != null)
+ string += bean.getProtString();
+ if (bean.getPubString() != null)
+ string += bean.getPubString();
+ return string;
+ }
+
+ public void testFieldAccess() throws Throwable
+ {
+ testAccessBean("private");
+ testAccessBean("protected");
+ testAccessBean("public");
+
+ // this should fail or something :-) on proxy
+ AccessBean pb = getBean("public", AccessBean.class);
+ assertEquals("foobar", pb.pubString);
+ AbstractTypeTestDelegate.Type type = getType("public");
+ assertTrue(pb.getPubString() == null || type != AbstractTypeTestDelegate.Type.PROXY);
+ }
+}
Added: projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/support/AnnotatedBean.java
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/support/AnnotatedBean.java (rev 0)
+++ projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/support/AnnotatedBean.java 2008-03-20 17:34:27 UTC (rev 71088)
@@ -0,0 +1,34 @@
+/*
+* 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.microcontainer.support;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+ at Test
+public class AnnotatedBean
+{
+ @Test
+ public void method() {}
+}
Added: projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/support/Marker.java
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/support/Marker.java (rev 0)
+++ projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/support/Marker.java 2008-03-20 17:34:27 UTC (rev 71088)
@@ -0,0 +1,31 @@
+/*
+* 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.microcontainer.support;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public @interface Marker {
+
+}
Deleted: projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/test/InitialLifecycleCallbackWithDependencyAopTestCase.java
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/test/InitialLifecycleCallbackWithDependencyAopTestCase.java 2008-03-20 17:17:18 UTC (rev 71087)
+++ projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/test/InitialLifecycleCallbackWithDependencyAopTestCase.java 2008-03-20 17:34:27 UTC (rev 71088)
@@ -1,54 +0,0 @@
-/*
-* 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.microcontainer.test;
-
-import junit.framework.Test;
-
-/**
- *
- * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
- * @version $Revision: 1.1 $
- */
-public class InitialLifecycleCallbackWithDependencyAopTestCase extends InitialLifecycleCallbackWithDependencyTest
-{
- public InitialLifecycleCallbackWithDependencyAopTestCase(String name)
- {
- super(name);
- }
-
- public static Test suite()
- {
- return suite(InitialLifecycleCallbackWithDependencyAopTestCase.class);
- }
-
- @Override
- protected String getFile0()
- {
- return "InitialLifecycleCallbackWithDependencyAopTestCaseNotAutomatic0.xml";
- }
-
- @Override
- protected String getFile1()
- {
- return "InitialLifecycleCallbackWithDependencyAopTestCaseNotAutomatic1.xml";
- }
-}
Deleted: projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/test/InitialLifecycleCallbackWithDependencyDeploymentTestCase.java
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/test/InitialLifecycleCallbackWithDependencyDeploymentTestCase.java 2008-03-20 17:17:18 UTC (rev 71087)
+++ projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/test/InitialLifecycleCallbackWithDependencyDeploymentTestCase.java 2008-03-20 17:34:27 UTC (rev 71088)
@@ -1,55 +0,0 @@
-/*
-* 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.microcontainer.test;
-
-import junit.framework.Test;
-
-/**
- *
- * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
- * @version $Revision: 1.1 $
- */
-public class InitialLifecycleCallbackWithDependencyDeploymentTestCase extends InitialLifecycleCallbackWithDependencyTest
-{
-
- public InitialLifecycleCallbackWithDependencyDeploymentTestCase(String name)
- {
- super(name);
- }
-
- public static Test suite()
- {
- return suite(InitialLifecycleCallbackWithDependencyDeploymentTestCase.class);
- }
-
- @Override
- protected String getFile0()
- {
- return "InitialLifecycleCallbackWithDependencyDeploymentTestCaseNotAutomatic0.xml";
- }
-
- @Override
- protected String getFile1()
- {
- return "InitialLifecycleCallbackWithDependencyDeploymentTestCaseNotAutomatic1.xml";
- }
-}
Deleted: projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/test/InitialLifecycleCallbackWithDependencyTest.java
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/test/InitialLifecycleCallbackWithDependencyTest.java 2008-03-20 17:17:18 UTC (rev 71087)
+++ projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/test/InitialLifecycleCallbackWithDependencyTest.java 2008-03-20 17:34:27 UTC (rev 71088)
@@ -1,357 +0,0 @@
-/*
-* 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.microcontainer.test;
-
-import org.jboss.dependency.spi.ControllerState;
-import org.jboss.kernel.spi.dependency.KernelControllerContext;
-import org.jboss.test.aop.junit.AOPMicrocontainerTest;
-import org.jboss.test.microcontainer.support.LifecycleCallbackWithBeanDependency;
-import org.jboss.test.microcontainer.support.SimpleBean;
-
-/**
- *
- * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
- * @version $Revision: 1.1 $
- */
-public abstract class InitialLifecycleCallbackWithDependencyTest extends AOPMicrocontainerTest
-{
- public InitialLifecycleCallbackWithDependencyTest(String name)
- {
- super(name);
- }
-
- public void testLifecycleInterceptionsWithDependencyCorrectOrder() throws Exception
- {
- deploy(getFile0());
- try
- {
- Object dependency = getCheckBeanExists("Dependency");
- assertNotNull(dependency);
- boolean itworked = false;
-
- LifecycleCallbackWithBeanDependency.interceptions.clear();
- deploy(getFile1());
- try
- {
- validate();
- getCheckBeanExists("Intercepted");
- LifecycleCallbackWithBeanDependency lifecycle = (LifecycleCallbackWithBeanDependency)getCheckBeanExists("LifecycleCallback");
- assertEquals(1, LifecycleCallbackWithBeanDependency.interceptions.size());
- LifecycleCallbackWithBeanDependency.Handled handled = LifecycleCallbackWithBeanDependency.interceptions.get(0);
- assertEquals("Intercepted", handled.contextName);
- assertEquals(ControllerState.CONFIGURED, handled.toState);
- assertNotNull(lifecycle.getDependency());
- assertEquals(dependency, lifecycle.getDependency());
- itworked = true;
- }
- finally
- {
- LifecycleCallbackWithBeanDependency.interceptions.clear();
- undeploy(getFile1());
- if (itworked)
- {
- assertEquals(1, LifecycleCallbackWithBeanDependency.interceptions.size());
- LifecycleCallbackWithBeanDependency.Handled handled = LifecycleCallbackWithBeanDependency.interceptions.get(0);
- assertEquals("Intercepted", handled.contextName);
- assertEquals(ControllerState.CONFIGURED, handled.toState);
- }
- }
- }
- finally
- {
- undeploy(getFile0());
- }
- }
-
- public void testLifecycleInterceptionsWithDependencyWrongOrder() throws Exception
- {
- deploy(getFile1());
- try
- {
- SimpleBean bean;
- try
- {
- bean = (SimpleBean) getBean("Intercepted");
- fail("'Interceped' should not be installed yet");
- }
- catch (IllegalStateException expected)
- {
- }
-
- bean = (SimpleBean) getBean("Intercepted", ControllerState.DESCRIBED);
- assertNull("This should not be deployed until the interceptor is", bean);
-
- boolean itworked = false;
- LifecycleCallbackWithBeanDependency.interceptions.clear();
- deploy(getFile0());
- try
- {
- validate();
- Object dependency = getCheckBeanExists("Dependency");
- LifecycleCallbackWithBeanDependency lifecycle = (LifecycleCallbackWithBeanDependency)getCheckBeanExists("LifecycleCallback");
- getCheckBeanExists("Intercepted");
- assertEquals(1, LifecycleCallbackWithBeanDependency.interceptions.size());
- LifecycleCallbackWithBeanDependency.Handled handled = LifecycleCallbackWithBeanDependency.interceptions.get(0);
- assertEquals("Intercepted", handled.contextName);
- assertEquals(ControllerState.CONFIGURED, handled.toState);
- assertNotNull(lifecycle.getDependency());
- assertEquals(dependency, lifecycle.getDependency());
-
- itworked = true;
-
- }
- finally
- {
- LifecycleCallbackWithBeanDependency.interceptions.clear();
- undeploy(getFile0());
- if (itworked)
- {
- assertEquals(1, LifecycleCallbackWithBeanDependency.interceptions.size());
- LifecycleCallbackWithBeanDependency.Handled handled = LifecycleCallbackWithBeanDependency.interceptions.get(0);
- assertEquals("Intercepted", handled.contextName);
- assertEquals(ControllerState.CONFIGURED, handled.toState);
- }
-
- try
- {
- bean = (SimpleBean) getBean("Intercepted");
- fail("'Interceped' should not be installed yet");
- }
- catch (IllegalStateException expected)
- {
- }
-
- bean = (SimpleBean) getBean("Intercepted", ControllerState.DESCRIBED);
- assertNull("This should not be deployed until the interceptor is", bean);
- }
- }
- finally
- {
- undeploy(getFile1());
- }
- }
-
- public void testLifecycleInterceptionsWithDependencyRedeploy() throws Exception
- {
- deploy(getFile1());
- try
- {
- SimpleBean bean;
- try
- {
- bean = (SimpleBean) getBean("Intercepted");
- fail("'Interceped' should not be installed yet");
- }
- catch (IllegalStateException expected)
- {
- }
-
- bean = (SimpleBean) getBean("Intercepted", ControllerState.DESCRIBED);
- assertNull("This should not be deployed until the interceptor is", bean);
-
- boolean itworked = false;
- LifecycleCallbackWithBeanDependency.interceptions.clear();
- deploy(getFile0());
- try
- {
- validate();
- Object dependency = getCheckBeanExists("Dependency");
- LifecycleCallbackWithBeanDependency lifecycle = (LifecycleCallbackWithBeanDependency)getCheckBeanExists("LifecycleCallback");
- getCheckBeanExists("Intercepted");
- assertEquals(1, LifecycleCallbackWithBeanDependency.interceptions.size());
- LifecycleCallbackWithBeanDependency.Handled handled = LifecycleCallbackWithBeanDependency.interceptions.get(0);
- assertEquals("Intercepted", handled.contextName);
- assertEquals(ControllerState.CONFIGURED, handled.toState);
- assertNotNull(lifecycle.getDependency());
- assertEquals(dependency, lifecycle.getDependency());
-
- itworked = true;
-
- }
- finally
- {
- LifecycleCallbackWithBeanDependency.interceptions.clear();
- undeploy(getFile0());
- if (itworked)
- {
- assertEquals(1, LifecycleCallbackWithBeanDependency.interceptions.size());
- LifecycleCallbackWithBeanDependency.Handled handled = LifecycleCallbackWithBeanDependency.interceptions.get(0);
- assertEquals("Intercepted", handled.contextName);
- assertEquals(ControllerState.CONFIGURED, handled.toState);
- }
-
- try
- {
- bean = (SimpleBean) getBean("Intercepted");
- fail("'Interceped' should not be installed yet");
- }
- catch (IllegalStateException expected)
- {
- }
-
- bean = (SimpleBean) getBean("Intercepted", ControllerState.DESCRIBED);
- assertNull("This should not be deployed until the interceptor is", bean);
- }
-
- try
- {
- bean = (SimpleBean) getBean("Intercepted");
- fail("'Interceped' should not be installed yet");
- }
- catch (IllegalStateException expected)
- {
- KernelControllerContext context = getControllerContext("Intercepted", ControllerState.DESCRIBED);
- assertNotNull(context);
- }
-
- itworked = false;
- LifecycleCallbackWithBeanDependency.interceptions.clear();
- deploy(getFile0());
- try
- {
- validate();
- Object dependency = getCheckBeanExists("Dependency");
- LifecycleCallbackWithBeanDependency lifecycle = (LifecycleCallbackWithBeanDependency)getCheckBeanExists("LifecycleCallback");
- getCheckBeanExists("Intercepted");
- assertEquals(1, LifecycleCallbackWithBeanDependency.interceptions.size());
- LifecycleCallbackWithBeanDependency.Handled handled = LifecycleCallbackWithBeanDependency.interceptions.get(0);
- assertEquals("Intercepted", handled.contextName);
- assertEquals(ControllerState.CONFIGURED, handled.toState);
- assertNotNull(lifecycle.getDependency());
- assertTrue("Should not be caching the lifecycle's callback across rebinding", dependency == lifecycle.getDependency());
-
- itworked = true;
- }
- finally
- {
- LifecycleCallbackWithBeanDependency.interceptions.clear();
- undeploy(getFile0());
- if (itworked)
- {
- assertEquals(1, LifecycleCallbackWithBeanDependency.interceptions.size());
- LifecycleCallbackWithBeanDependency.Handled handled = LifecycleCallbackWithBeanDependency.interceptions.get(0);
- assertEquals("Intercepted", handled.contextName);
- assertEquals(ControllerState.CONFIGURED, handled.toState);
- }
-
- try
- {
- bean = (SimpleBean) getBean("Intercepted");
- fail("'Interceped' should not be installed yet");
- }
- catch (IllegalStateException expected)
- {
- }
-
- bean = (SimpleBean) getBean("Intercepted", ControllerState.DESCRIBED);
- assertNull("This should not be deployed until the interceptor is", bean);
- }
- }
- finally
- {
- undeploy(getFile1());
- }
- }
-
- public void testLifecycleInterceptionsWithDependencyRedeploy2() throws Exception
- {
- deploy(getFile0());
- try
- {
- Object dependency = getCheckBeanExists("Dependency");
- boolean itworked = false;
-
- LifecycleCallbackWithBeanDependency.interceptions.clear();
- deploy(getFile1());
- try
- {
- validate();
- getCheckBeanExists("Intercepted");
- LifecycleCallbackWithBeanDependency lifecycle = (LifecycleCallbackWithBeanDependency)getCheckBeanExists("LifecycleCallback");
- assertEquals(1, LifecycleCallbackWithBeanDependency.interceptions.size());
- LifecycleCallbackWithBeanDependency.Handled handled = LifecycleCallbackWithBeanDependency.interceptions.get(0);
- assertEquals("Intercepted", handled.contextName);
- assertEquals(ControllerState.CONFIGURED, handled.toState);
- assertNotNull(lifecycle.getDependency());
- assertTrue(dependency == lifecycle.getDependency());
- itworked = true;
- }
- finally
- {
- LifecycleCallbackWithBeanDependency.interceptions.clear();
- undeploy(getFile1());
- if (itworked)
- {
- assertEquals(1, LifecycleCallbackWithBeanDependency.interceptions.size());
- LifecycleCallbackWithBeanDependency.Handled handled = LifecycleCallbackWithBeanDependency.interceptions.get(0);
- assertEquals("Intercepted", handled.contextName);
- assertEquals(ControllerState.CONFIGURED, handled.toState);
- }
- }
-
- Object dependency2 = getCheckBeanExists("Dependency");
- assertTrue(dependency == dependency2);
- LifecycleCallbackWithBeanDependency.interceptions.clear();
- deploy(getFile1());
- try
- {
- validate();
- getCheckBeanExists("Intercepted");
- LifecycleCallbackWithBeanDependency lifecycle = (LifecycleCallbackWithBeanDependency)getCheckBeanExists("LifecycleCallback");
- assertEquals(1, LifecycleCallbackWithBeanDependency.interceptions.size());
- LifecycleCallbackWithBeanDependency.Handled handled = LifecycleCallbackWithBeanDependency.interceptions.get(0);
- assertEquals("Intercepted", handled.contextName);
- assertEquals(ControllerState.CONFIGURED, handled.toState);
- assertNotNull(lifecycle.getDependency());
- assertTrue(dependency == lifecycle.getDependency());
- itworked = true;
- }
- finally
- {
- LifecycleCallbackWithBeanDependency.interceptions.clear();
- undeploy(getFile1());
- if (itworked)
- {
- assertEquals(1, LifecycleCallbackWithBeanDependency.interceptions.size());
- LifecycleCallbackWithBeanDependency.Handled handled = LifecycleCallbackWithBeanDependency.interceptions.get(0);
- assertEquals("Intercepted", handled.contextName);
- assertEquals(ControllerState.CONFIGURED, handled.toState);
- }
- }
- }
- finally
- {
- undeploy(getFile0());
- }
- }
-
- public Object getCheckBeanExists(String name)
- {
- Object bean = getBean(name);
- assertNotNull(bean);
- return bean;
- }
-
- protected abstract String getFile0();
-
- protected abstract String getFile1();
-}
More information about the jboss-cvs-commits
mailing list