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:$
023: * --------------------------------------------------------------------------
024: */package org.ow2.easybeans.tests.inheritance;
025:
026: import static org.testng.Assert.assertNotNull;
027:
028: import org.ow2.easybeans.tests.common.ejbs.base.ItfAccessSessionContext;
029: import org.ow2.easybeans.tests.common.ejbs.stateful.containermanaged.inheritance.SFSBAccessResource;
030: import org.ow2.easybeans.tests.common.ejbs.stateless.containermanaged.inheritance.SLSBExtAccessSessionContext;
031: import org.ow2.easybeans.tests.common.helper.EJBHelper;
032: import org.testng.annotations.BeforeClass;
033: import org.testng.annotations.Test;
034:
035: /**
036: * Verifies if the bean inheritance is following the JSR 220 spec.The item 15.2.2
037: * says that the injection must be available in the inheritance hierarchy.
038: * @reference JSR 220-PROPOSED FINAL
039: * @requirement Application Server must be running; the bean that implements the
040: * interface
041: * org.ow2.easybeans.tests.common.inheritance.ItfAcessSessionContext
042: * must be deployed.
043: * @setup gets the reference of bean SFSBAccessResource.
044: * @author Gisele Pinheiro Souza
045: * @author Eduardo Studzinski Estima de Castro
046: */
047: public class TestInheritanceAnnotation {
048:
049: /**
050: * The bean used during the test.
051: */
052: private ItfAccessSessionContext sfsbAccessResource;
053:
054: /**
055: * The bean used during the test.
056: */
057: private ItfAccessSessionContext sfsbExtendedAccessResource;
058:
059: /**
060: * Creates a bean to be used in the tests.
061: * @throws Exception if there is a problem with the bean initialization.
062: */
063: @BeforeClass
064: public void setup() throws Exception {
065: // gets a bean
066: sfsbAccessResource = EJBHelper
067: .getBeanRemoteInstance(SFSBAccessResource.class,
068: ItfAccessSessionContext.class);
069:
070: // gets a bean
071: sfsbExtendedAccessResource = EJBHelper.getBeanRemoteInstance(
072: SLSBExtAccessSessionContext.class,
073: ItfAccessSessionContext.class);
074: }
075:
076: /**
077: * Verifies if a subclass can use the SessionContext injected in the
078: * superclass.
079: * @input -
080: * @output the return SessionContext variable is not egual a null.
081: * @throws Exception if an error during the test occurs.
082: */
083: @Test
084: public void testSessionContextInheritance00() throws Exception {
085: Object obj = sfsbAccessResource.accessSessionContext(null);
086: assertNotNull(obj);
087: }
088:
089: /**
090: * Verifies if a subclass can use a SessionContext injected in the superclas
091: * that is not direct ancestor.
092: * @input -
093: * @output the return SessionContext variable is not egual a null.
094: * @throws Exception if an error during the test occurs.
095: */
096: @Test
097: public void testSessionContextInheritance01() throws Exception {
098: Object obj = sfsbExtendedAccessResource
099: .accessSessionContext(null);
100: assertNotNull(obj);
101: }
102: }
|