001: /**
002: * EasyBeans
003: * Copyright (C) 2006 Bull S.A.S.
004: * Contact: easybeans@ow2.org
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation; either
009: * version 2.1 of the License, or any later version.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: *
016: * You should have received a copy of the GNU Lesser General Public
017: * License along with this library; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
019: * USA
020: *
021: * --------------------------------------------------------------------------
022: * $Id: TestSFPostConstruct00.java 1970 2007-10-16 11:49:25Z benoitf $
023: * --------------------------------------------------------------------------
024: */package org.ow2.easybeans.tests.interceptors.lifecycle.stateful.containermanaged;
025:
026: import static org.ow2.easybeans.tests.common.helper.EJBHelper.getBeanRemoteInstance;
027:
028: import org.ow2.easybeans.tests.common.ejbs.base.ItfCheckPostConstruct;
029: import org.ow2.easybeans.tests.common.ejbs.stateful.containermanaged.lifecallback.SFSBPostConstructExternalOrder00;
030: import org.ow2.easybeans.tests.common.ejbs.stateful.containermanaged.lifecallback.SFSBPostConstructExternalOrder01;
031: import org.ow2.easybeans.tests.common.ejbs.stateful.containermanaged.lifecallback.SFSBPostConstructInternalOrder00;
032: import org.testng.annotations.BeforeClass;
033: import org.testng.annotations.Test;
034:
035: /**
036: * Verifies if interceptors invocation order.
037: * @reference JSR 220 - EJB 3.0 Core - 12.4
038: * @requirement Application Server must be running; the beans
039: * org.ow2.easybeans.tests.common.ejbs.stateless.containermanaged.lifecallback.*
040: * must be deployed.
041: * (Ant task: install.jar.tests.interceptor.lifecycle)
042: * @author Eduardo Studzinski Estima de Castro
043: * @author Gisele Pinheiro Souza
044: */
045: public class TestSFPostConstruct00 {
046:
047: /**
048: * Bean.
049: */
050: private ItfCheckPostConstruct beanPostConstructExternal00;
051:
052: /**
053: * Bean.
054: */
055: private ItfCheckPostConstruct beanPostConstructExternal01;
056:
057: /**
058: * Bean.
059: */
060: private ItfCheckPostConstruct beanPostConstructInternal;
061:
062: /**
063: * Gets bean instances used in the tests.
064: * @throws Exception if there is a problem with the bean initialization.
065: */
066: @BeforeClass
067: public void startUp() throws Exception {
068: beanPostConstructInternal = getBeanRemoteInstance(
069: SFSBPostConstructInternalOrder00.class,
070: ItfCheckPostConstruct.class);
071: beanPostConstructExternal00 = getBeanRemoteInstance(
072: SFSBPostConstructExternalOrder00.class,
073: ItfCheckPostConstruct.class);
074: beanPostConstructExternal01 = getBeanRemoteInstance(
075: SFSBPostConstructExternalOrder01.class,
076: ItfCheckPostConstruct.class);
077: }
078:
079: /**
080: * Verifies if the post construct callback in invoked in the correct order.
081: * The bean contains an interceptor that sets to true a boolean value and
082: * the check() method verifies if the value was set.
083: * @input -
084: * @output -
085: * @throws Exception if a problem occurs.
086: */
087: @Test
088: public void testInternal() throws Exception {
089: beanPostConstructInternal.check();
090: }
091:
092: /**
093: * Verifies if the post construct callback in an external class is invoked.
094: * @input -
095: * @output -
096: * @throws Exception if a problem occurs.
097: */
098: @Test
099: public void testExternal00() throws Exception {
100: beanPostConstructExternal00.check();
101: }
102:
103: /**
104: * Verifies if the post construct callback in invoked in the correct order.
105: * The bean contains two interceptors(inheritance) that one throw an
106: * exception and the other must catch, the last must throw an exception
107: * that is expected by the first invoked interceptor.
108: * @input -
109: * @output
110: * @throws Exception if a problem occurs.
111: */
112: @Test
113: public void testExternal01() throws Exception {
114: beanPostConstructExternal01.check();
115: }
116: }
|