[jboss-cvs] JBossAS SVN: r72604 - in projects/ejb3/trunk/interceptors/src/test: java/org/jboss/ejb3/test/interceptors/badbinding/unit and 5 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Apr 23 02:05:05 EDT 2008
Author: kabir.khan at jboss.com
Date: 2008-04-23 02:05:05 -0400 (Wed, 23 Apr 2008)
New Revision: 72604
Added:
projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/badbinding/BaseLifecycleBean.java
projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/badbinding/BaseLifecycleInterceptor.java
projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/badbinding/ChildLifecycleBean.java
projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/badbinding/ChildLifecycleInterceptor.java
projects/ejb3/trunk/interceptors/src/test/resources/badbinding/badbean-bean-overridden-lifecycle/
projects/ejb3/trunk/interceptors/src/test/resources/badbinding/badbean-bean-overridden-lifecycle/META-INF/
projects/ejb3/trunk/interceptors/src/test/resources/badbinding/badbean-bean-overridden-lifecycle/META-INF/ejb-jar.xml
projects/ejb3/trunk/interceptors/src/test/resources/badbinding/badbean-interceptor-overridden-lifecycle/
projects/ejb3/trunk/interceptors/src/test/resources/badbinding/badbean-interceptor-overridden-lifecycle/META-INF/
projects/ejb3/trunk/interceptors/src/test/resources/badbinding/badbean-interceptor-overridden-lifecycle/META-INF/ejb-jar.xml
Modified:
projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/badbinding/unit/BadBindingTestCase.java
Log:
[EJBTHREE-1314] Only call bottom interceptor method if methods are overridden.
Added: projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/badbinding/BaseLifecycleBean.java
===================================================================
--- projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/badbinding/BaseLifecycleBean.java (rev 0)
+++ projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/badbinding/BaseLifecycleBean.java 2008-04-23 06:05:05 UTC (rev 72604)
@@ -0,0 +1,40 @@
+/*
+* 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.ejb3.test.interceptors.badbinding;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class BaseLifecycleBean
+{
+ public void lifecycle()
+ {
+
+ }
+
+ public void lifecycle2()
+ {
+
+ }
+}
Added: projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/badbinding/BaseLifecycleInterceptor.java
===================================================================
--- projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/badbinding/BaseLifecycleInterceptor.java (rev 0)
+++ projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/badbinding/BaseLifecycleInterceptor.java 2008-04-23 06:05:05 UTC (rev 72604)
@@ -0,0 +1,42 @@
+/*
+* 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.ejb3.test.interceptors.badbinding;
+
+import javax.interceptor.InvocationContext;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class BaseLifecycleInterceptor
+{
+ public void lifecycle(InvocationContext ctx)
+ {
+
+ }
+
+ public void lifecycle2(InvocationContext ctx)
+ {
+
+ }
+}
Added: projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/badbinding/ChildLifecycleBean.java
===================================================================
--- projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/badbinding/ChildLifecycleBean.java (rev 0)
+++ projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/badbinding/ChildLifecycleBean.java 2008-04-23 06:05:05 UTC (rev 72604)
@@ -0,0 +1,41 @@
+/*
+* 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.ejb3.test.interceptors.badbinding;
+
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class ChildLifecycleBean extends BaseLifecycleBean
+{
+ public void lifecycle()
+ {
+
+ }
+
+ public void lifecycle2()
+ {
+
+ }
+}
Added: projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/badbinding/ChildLifecycleInterceptor.java
===================================================================
--- projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/badbinding/ChildLifecycleInterceptor.java (rev 0)
+++ projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/badbinding/ChildLifecycleInterceptor.java 2008-04-23 06:05:05 UTC (rev 72604)
@@ -0,0 +1,42 @@
+/*
+* 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.ejb3.test.interceptors.badbinding;
+
+import javax.interceptor.InvocationContext;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class ChildLifecycleInterceptor extends BaseLifecycleInterceptor
+{
+ public void lifecycle(InvocationContext ctx)
+ {
+
+ }
+
+ public void lifecycle2(InvocationContext ctx)
+ {
+
+ }
+}
Modified: projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/badbinding/unit/BadBindingTestCase.java
===================================================================
--- projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/badbinding/unit/BadBindingTestCase.java 2008-04-23 05:13:40 UTC (rev 72603)
+++ projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/badbinding/unit/BadBindingTestCase.java 2008-04-23 06:05:05 UTC (rev 72604)
@@ -34,6 +34,7 @@
import org.jboss.ejb3.interceptors.metadata.InterceptorMetaDataBridge;
import org.jboss.ejb3.metadata.MetaDataBridge;
import org.jboss.ejb3.metadata.annotation.AnnotationRepositoryToMetaData;
+import org.jboss.ejb3.test.interceptors.badbinding.ChildLifecycleBean;
import org.jboss.ejb3.test.interceptors.common.CommonInterceptor;
import org.jboss.ejb3.test.interceptors.metadata.MetadataBean;
import org.jboss.logging.Logger;
@@ -207,8 +208,40 @@
testBinding("badbinding/goodbean-interceptor-order-binding-with-method/META-INF/ejb-jar.xml");
}
- private MyContainer<MetadataBean> testBinding(String ejbJarXml) throws Throwable
+
+ public void testBadBeanBeanOverriddenLifecycle() throws Throwable
{
+ try
+ {
+ MyContainer container = testBinding("badbinding/badbean-bean-overridden-lifecycle/META-INF/ejb-jar.xml", ChildLifecycleBean.class, "ChildLifecycleBean");
+ container.construct();
+ fail("Only the child lifecycle method should have been chosen");
+ }
+ catch(Exception expected)
+ {
+ }
+ }
+
+ public void testBadBeanInterceptorOverriddenLifecycle() throws Throwable
+ {
+ try
+ {
+ MyContainer container = testBinding("badbinding/badbean-interceptor-overridden-lifecycle/META-INF/ejb-jar.xml", ChildLifecycleBean.class, "ChildLifecycleBean");
+ container.construct();
+ fail("Only the child lifecycle method should have been chosen");
+ }
+ catch(Exception expected)
+ {
+ }
+ }
+
+ private MyContainer testBinding(String ejbJarXml) throws Throwable
+ {
+ return testBinding(ejbJarXml, MetadataBean.class, "MetadataBean");
+ }
+
+ private MyContainer testBinding(String ejbJarXml, Class<?> clazz, String name) throws Throwable
+ {
// To make surefire happy
Thread.currentThread().setContextClassLoader(MetadataBean.class.getClassLoader());
@@ -220,12 +253,12 @@
JBoss50MetaData jbossMetaData = new JBoss50MetaData();
jbossMetaData.merge(null, metaData);
- JBossEnterpriseBeanMetaData beanMetaData = jbossMetaData.getEnterpriseBean("MetadataBean");
+ JBossEnterpriseBeanMetaData beanMetaData = jbossMetaData.getEnterpriseBean(name);
assertNotNull(beanMetaData);
assertEquals(0, CommonInterceptor.postConstructs);
- MyContainer<MetadataBean> container = new MyContainer<MetadataBean>("MetadataBean", "Test", MetadataBean.class, beanMetaData);
+ MyContainer container = new MyContainer(name, "Test", clazz, beanMetaData);
container.testAdvisor();
Added: projects/ejb3/trunk/interceptors/src/test/resources/badbinding/badbean-bean-overridden-lifecycle/META-INF/ejb-jar.xml
===================================================================
--- projects/ejb3/trunk/interceptors/src/test/resources/badbinding/badbean-bean-overridden-lifecycle/META-INF/ejb-jar.xml (rev 0)
+++ projects/ejb3/trunk/interceptors/src/test/resources/badbinding/badbean-bean-overridden-lifecycle/META-INF/ejb-jar.xml 2008-04-23 06:05:05 UTC (rev 72604)
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ejb-jar
+ xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
+ http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd"
+ version="3.0">
+ <display-name>InterceptorsTest</display-name>
+ <!-- Must define a bean here, because we have no annotation on it -->
+ <!-- (Can't use @Stateless within ejb3-interceptors) -->
+ <enterprise-beans>
+ <session>
+ <ejb-name>ChildLifecycleBean</ejb-name>
+ <around-invoke>
+ <method-name>aroundInvoke</method-name>
+ </around-invoke>
+ <post-construct>
+ <lifecycle-callback-method>lifecycle</lifecycle-callback-method>
+ </post-construct>
+ <post-construct>
+ <lifecycle-callback-method>lifecycle2</lifecycle-callback-method>
+ </post-construct>
+ </session>
+ </enterprise-beans>
+</ejb-jar>
\ No newline at end of file
Added: projects/ejb3/trunk/interceptors/src/test/resources/badbinding/badbean-interceptor-overridden-lifecycle/META-INF/ejb-jar.xml
===================================================================
--- projects/ejb3/trunk/interceptors/src/test/resources/badbinding/badbean-interceptor-overridden-lifecycle/META-INF/ejb-jar.xml (rev 0)
+++ projects/ejb3/trunk/interceptors/src/test/resources/badbinding/badbean-interceptor-overridden-lifecycle/META-INF/ejb-jar.xml 2008-04-23 06:05:05 UTC (rev 72604)
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ejb-jar
+ xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
+ http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd"
+ version="3.0">
+ <display-name>InterceptorsTest</display-name>
+ <!-- Must define a bean here, because we have no annotation on it -->
+ <!-- (Can't use @Stateless within ejb3-interceptors) -->
+ <enterprise-beans>
+ <session>
+ <ejb-name>ChildLifecycleBean</ejb-name>
+ <around-invoke>
+ <method-name>aroundInvoke</method-name>
+ </around-invoke>
+ </session>
+ </enterprise-beans>
+ <interceptors>
+ <interceptor>
+ <interceptor-class>org.jboss.ejb3.test.interceptors.badbinding.ChildLifecycleInterceptor</interceptor-class>
+ <post-construct>
+ <lifecycle-callback-method>lifecycle</lifecycle-callback-method>
+ </post-construct>
+ <post-construct>
+ <lifecycle-callback-method>lifecycle2</lifecycle-callback-method>
+ </post-construct>
+ </interceptor>
+ </interceptors>
+ <assembly-descriptor>
+ <interceptor-binding>
+ <ejb-name>*</ejb-name>
+ <interceptor-order>
+ <interceptor-class>org.jboss.ejb3.test.interceptors.badbinding.ChildLifecycleInterceptor</interceptor-class>
+ </interceptor-order>
+ </interceptor-binding>
+ </assembly-descriptor>
+</ejb-jar>
\ No newline at end of file
More information about the jboss-cvs-commits
mailing list