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: TestSFSessionBeanInterfaceWithAnnotation.java 1970 2007-10-16 11:49:25Z benoitf $
023: * --------------------------------------------------------------------------
024: */package org.ow2.easybeans.tests.sessionbean.stateful.sbinterface;
025:
026: import static org.ow2.easybeans.tests.common.ejbs.entity.callbacklogger.CallbackType.PRE_DESTROY;
027: import static org.ow2.easybeans.tests.common.ejbs.stateless.containermanaged.callbacklogger.ItfCallbackLoggerAccess.SLEEP;
028: import static org.ow2.easybeans.tests.common.helper.EJBHelper.getBeanRemoteInstance;
029:
030: import java.util.ArrayList;
031: import java.util.List;
032:
033: import org.ow2.easybeans.tests.common.ejbs.base.ItfCheck02;
034: import org.ow2.easybeans.tests.common.ejbs.stateful.containermanaged.sbinterface.SFSBSessionBeanItfWithAnnotation;
035: import org.ow2.easybeans.tests.common.ejbs.stateless.containermanaged.callbacklogger.ItfCallbackLoggerAccess;
036: import org.ow2.easybeans.tests.common.ejbs.stateless.containermanaged.callbacklogger.SLSBCallbackLoggerAccess;
037: import org.testng.annotations.BeforeMethod;
038: import org.testng.annotations.Test;
039:
040: /**
041: * Tests beans that implements the SessionBean interface.
042: * @author Eduardo Studzinski Estima de Castro
043: * @author Gisele Pinheiro Souza
044: */
045: public class TestSFSessionBeanInterfaceWithAnnotation {
046:
047: /**
048: * Bean.
049: */
050: private ItfCheck02 bean;
051:
052: /**
053: * Logger bean.
054: */
055: private ItfCallbackLoggerAccess beanLogger;
056:
057: /**
058: * Gets bean instances used in the tests.
059: * @throws Exception if there is a problem with bean initialization.
060: */
061: @BeforeMethod
062: public void startUp() throws Exception {
063: bean = getBeanRemoteInstance(
064: SFSBSessionBeanItfWithAnnotation.class,
065: ItfCheck02.class);
066: beanLogger = getBeanRemoteInstance(
067: SLSBCallbackLoggerAccess.class,
068: ItfCallbackLoggerAccess.class);
069: beanLogger.deleteAll();
070: }
071:
072: /**
073: * Verifies the ejbActivate() with the @PostActivate annotation is
074: * working properly.
075: * @input -
076: * @output -
077: * @throws Exception if a problem occurs.
078: */
079: // @Test
080: public void verifyEjbActivate() throws Exception {
081: // TODO: test
082: }
083:
084: /**
085: * Verifies the ejbPassivate() with the @PrePassivate annotation is
086: * working properly.
087: * @input -
088: * @output -
089: * @throws Exception if a problem occurs.
090: */
091: // @Test
092: public void verifyEjbPassivate() throws Exception {
093: // TODO: test
094: }
095:
096: /**
097: * Verifies if the ejbRemove() with the @PreDestroy annotation is
098: * working properly.
099: * @input -
100: * @output -
101: * @throws Exception if a problem occurs.
102: */
103: @Test
104: public void verifyEjbRemove() throws Exception {
105: bean.remove();
106:
107: // Sleep used to wait all interceptors execution
108: Thread.sleep(SLEEP);
109:
110: // Interceptors list
111: List<String> arLife = new ArrayList<String>();
112:
113: arLife.add(SFSBSessionBeanItfWithAnnotation.class.getName());
114:
115: beanLogger.verifyCallbackOrder(
116: SFSBSessionBeanItfWithAnnotation.class, PRE_DESTROY,
117: arLife.toArray(new String[0]));
118: }
119: }
|