KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > easybeans > tests > environment > reference > simpleentry > TestSimpleEnvironmentEntryFieldInjection


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: TestSimpleEnvironmentEntryFieldInjection.java 978 2006-07-28 13:19:14Z studzine $
23  * --------------------------------------------------------------------------
24  */

25 package org.objectweb.easybeans.tests.environment.reference.simpleentry;
26
27 import static org.objectweb.easybeans.tests.common.enhancer.ClassesEnhancer.EXT_CLASS;
28 import static org.objectweb.easybeans.tests.common.enhancer.ClassesEnhancer.enhanceNewClassLoader;
29 import static org.objectweb.easybeans.tests.common.helper.EJBHelper.getBeanRemoteInstance;
30
31 import java.io.File JavaDoc;
32 import java.util.ArrayList JavaDoc;
33 import java.util.List JavaDoc;
34
35 import org.objectweb.easybeans.tests.common.ejbs.base.ItfOneMethod01;
36 import org.objectweb.easybeans.tests.common.ejbs.base.ItfSimpleEnvEntry;
37 import org.objectweb.easybeans.tests.common.ejbs.base.ItfSimpleEnvEntryByDescriptor;
38 import org.objectweb.easybeans.tests.common.ejbs.stateless.containermanaged.simpleentry.SLSBSimpleEnvEntryByDescriptor;
39 import org.objectweb.easybeans.tests.common.ejbs.stateless.containermanaged.simpleentry.SLSBSimpleEnvEntryFieldInjection00;
40 import org.objectweb.easybeans.tests.common.ejbs.stateless.containermanaged.simpleentry.wrongspecification.SLSBFinalFieldEntry;
41 import org.objectweb.easybeans.tests.common.ejbs.stateless.containermanaged.simpleentry.wrongspecification.SLSBStaticEntry;
42 import org.objectweb.easybeans.tests.common.enhancer.ClassesEnhancer.TYPE;
43 import org.testng.annotations.BeforeMethod;
44 import org.testng.annotations.Test;
45
46 /**
47  * Verifies if the simple environment entries injection is following the JSR 220.
48  * The items covered in this test are: 16.4
49  * @reference JSR 220-PROPOSED FINAL
50  * @requirement Application Server must be running; the bean
51  * org.objectweb.easybeans.tests.common.ejbs.stateless.containermanaged.simpleentry.*
52  * must be deployed. (Ant task: install.jar.tests.simple.environment.session)
53  * @setup gets the reference of the bean
54  * @author Eduardo Studzinski Estima de Castro
55  * @author Gisele Pinheiro Souza
56  */

57 public class TestSimpleEnvironmentEntryFieldInjection {
58
59     /**
60      * Bean used in tests.
61      */

62     private ItfSimpleEnvEntry bean;
63
64     /**
65      * Bean used in tests.
66      */

67     private ItfSimpleEnvEntryByDescriptor beanInjectionByDescriptor;
68
69     /**
70      * Gets bean instances used in the tests.
71      * @throws Exception if there is a problem with the bean initialization.
72      */

73     @BeforeMethod
74     public void startUp() throws Exception JavaDoc {
75         bean = getBeanRemoteInstance(SLSBSimpleEnvEntryFieldInjection00.class, ItfSimpleEnvEntry.class);
76         beanInjectionByDescriptor = getBeanRemoteInstance(SLSBSimpleEnvEntryByDescriptor.class,
77                 ItfSimpleEnvEntryByDescriptor.class);
78     }
79
80     /**
81      * Tests if a string value was correctly injected.
82      * @input -
83      * @output -
84      */

85     @Test
86     public void testString00() {
87         bean.checkString00();
88     }
89
90     /**
91      * Tests if a character value was correctly injected.
92      * @input -
93      * @output -
94      */

95     @Test
96     public void testCharacter00() {
97         bean.checkCharacter00();
98     }
99
100     /**
101      * Tests if an integer value was correctly injected.
102      * @input -
103      * @output -
104      */

105     @Test
106     public void testInteger00() {
107         bean.checkInteger00();
108     }
109
110     /**
111      * Tests if a boolean value was correctly injected.
112      * @input -
113      * @output -
114      */

115     @Test
116     public void testBoolean00() {
117         bean.checkBoolean00();
118     }
119
120     /**
121      * Tests if a double value was correctly injected.
122      * @input -
123      * @output -
124      */

125     @Test
126     public void testDouble00() {
127         bean.checkDouble00();
128     }
129
130     /**
131      * Tests if a byte value was correctly injected.
132      * @input -
133      * @output -
134      */

135     @Test
136     public void testByte00() {
137         bean.checkByte00();
138     }
139
140     /**
141      * Tests if a short value was correctly injected.
142      * @input -
143      * @output -
144      */

145     @Test
146     public void testShort00() {
147         bean.checkByte00();
148     }
149
150     /**
151      * Tests if a byte value was correctly injected.
152      * @input -
153      * @output -
154      */

155     @Test
156     public void testLong00() {
157         bean.checkLong00();
158     }
159
160     /**
161      * Tests if a float value was correctly injected.
162      * @input -
163      * @output -
164      */

165     @Test
166     public void testFloat00() {
167         bean.checkFloat00();
168     }
169
170     /**
171      * Tests if a variable continues with its default value when the
172      * evn-entry-value is not specified.
173      * @input -
174      * @output -
175      */

176     @Test
177     public void testNotOverride00() {
178         beanInjectionByDescriptor.checkNotOverride00();
179     }
180
181     /**
182      * Tests if injection by deployment descriptor using injection-target tag is working properly.
183      * @input -
184      * @output -
185      */

186     @Test
187     public void testInjectionByDeploymentDescriptor00() {
188         beanInjectionByDescriptor.checkStringInjection00();
189     }
190
191     /**
192      * This test should cause an enhancer exception. The @Resource is annoted in a static field, it is denied by the
193      * specification.
194      * @input -
195      * @output -
196      * @throws Exception if there is an enhancer exception.
197      */

198     @Test(groups = {"withWrongSpecification"}, expectedExceptions = IllegalStateException JavaDoc.class)
199     public void testWrongSpec00() throws Exception JavaDoc {
200         List JavaDoc<String JavaDoc> lstFiles = new ArrayList JavaDoc<String JavaDoc>();
201
202         lstFiles.add(ItfOneMethod01.class.getName().replace(".", File.separator) + EXT_CLASS);
203         lstFiles.add(SLSBStaticEntry.class.getName().replace(".", File.separator) + EXT_CLASS);
204         enhanceNewClassLoader(lstFiles, TYPE.ALL);
205     }
206
207     /**
208      * This test should cause an enhancer exception. The &#64;Resource is annoted in a final field, it is denied by the
209      * specification.
210      * @input -
211      * @output -
212      * @throws Exception if there is an enhancer exception.
213      */

214     @Test(groups = {"withWrongSpecification"}, expectedExceptions = IllegalStateException JavaDoc.class)
215     public void testWrongSpec01() throws Exception JavaDoc {
216         List JavaDoc<String JavaDoc> lstFiles = new ArrayList JavaDoc<String JavaDoc>();
217
218         lstFiles.add(ItfOneMethod01.class.getName().replace(".", File.separator) + EXT_CLASS);
219         lstFiles.add(SLSBFinalFieldEntry.class.getName().replace(".", File.separator) + EXT_CLASS);
220         enhanceNewClassLoader(lstFiles, TYPE.ALL);
221     }
222
223 }
224
Popular Tags