KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > easybeans > tests > inheritance > TestInheritanceAnnotation


1 /**
2  * EasyBeans
3  * Copyright (C) 2006 Bull S.A.S.
4  * Contact: easybeans@objectweb.org
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19  * USA
20  *
21  * --------------------------------------------------------------------------
22  * $Id:$
23  * --------------------------------------------------------------------------
24  */

25 package org.objectweb.easybeans.tests.inheritance;
26
27 import static org.testng.Assert.assertNotNull;
28
29 import org.objectweb.easybeans.tests.common.ejbs.base.ItfAccessSessionContext;
30 import org.objectweb.easybeans.tests.common.ejbs.stateful.containermanaged.inheritance.SFSBAccessResource;
31 import org.objectweb.easybeans.tests.common.ejbs.stateless.containermanaged.inheritance.SLSBExtAccessSessionContext;
32 import org.objectweb.easybeans.tests.common.helper.EJBHelper;
33 import org.testng.annotations.BeforeClass;
34 import org.testng.annotations.Test;
35
36 /**
37  * Verifies if the bean inheritance is following the JSR 220 spec.The item 15.2.2
38  * says that the injection must be available in the inheritance hierarchy.
39  * @reference JSR 220-PROPOSED FINAL
40  * @requirement Application Server must be running; the bean that implements the
41  * interface
42  * org.objectweb.jonas.ejb3.tests.common.inheritance.ItfAcessSessionContext
43  * must be deployed.
44  * @setup gets the reference of bean SFSBAccessResource.
45  * @author Gisele Pinheiro Souza
46  * @author Eduardo Studzinski Estima de Castro
47  */

48 public class TestInheritanceAnnotation {
49
50     /**
51      * The bean used during the test.
52      */

53     private ItfAccessSessionContext sfsbAccessResource;
54
55     /**
56      * The bean used during the test.
57      */

58     private ItfAccessSessionContext sfsbExtendedAccessResource;
59
60     /**
61      * Creates a bean to be used in the tests.
62      * @throws Exception if there is a problem with the bean initialization.
63      */

64     @BeforeClass
65     public void setup() throws Exception JavaDoc {
66         // gets a bean
67
sfsbAccessResource = EJBHelper.getBeanRemoteInstance(SFSBAccessResource.class, ItfAccessSessionContext.class);
68
69         // gets a bean
70
sfsbExtendedAccessResource = EJBHelper.getBeanRemoteInstance(SLSBExtAccessSessionContext.class,
71                 ItfAccessSessionContext.class);
72     }
73
74     /**
75      * Verifies if a subclass can use the SessionContext injected in the
76      * superclass.
77      * @input -
78      * @output the return SessionContext variable is not egual a null.
79      * @throws Exception if an error during the test occurs.
80      */

81     @Test
82     public void testSessionContextInheritance00() throws Exception JavaDoc {
83         Object JavaDoc obj = sfsbAccessResource.accessSessionContext(null);
84         assertNotNull(obj);
85     }
86
87     /**
88      * Verifies if a subclass can use a SessionContext injected in the superclas
89      * that is not direct ancestor.
90      * @input -
91      * @output the return SessionContext variable is not egual a null.
92      * @throws Exception if an error during the test occurs.
93      */

94     @Test
95     public void testSessionContextInheritance01() throws Exception JavaDoc {
96         Object JavaDoc obj = sfsbExtendedAccessResource.accessSessionContext(null);
97         assertNotNull(obj);
98     }
99 }
100
Popular Tags