KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > geronimo > itest > client > JndiEnvEntryTest


1 /**
2  *
3  * Copyright 2003-2004 The Apache Software Foundation
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17
18 package org.apache.geronimo.itest.client;
19
20 import javax.naming.InitialContext JavaDoc;
21
22 import junit.framework.TestCase;
23
24 public class JndiEnvEntryTest extends TestCase {
25
26
27     public void testLookupStringEntry() throws Exception JavaDoc {
28         InitialContext JavaDoc ctx = new InitialContext JavaDoc();
29         assertNotNull("The InitialContext is null", ctx);
30
31         String JavaDoc expected = new String JavaDoc("1");
32         String JavaDoc actual = (String JavaDoc) ctx.lookup("java:comp/env/entry/String");
33
34         assertNotNull("The String looked up is null", actual);
35         assertEquals(expected, actual);
36     }
37
38     public void testLookupDoubleEntry() throws Exception JavaDoc {
39         InitialContext JavaDoc ctx = new InitialContext JavaDoc();
40         assertNotNull("The InitialContext is null", ctx);
41
42         Double JavaDoc expected = new Double JavaDoc(1.0D);
43         Double JavaDoc actual = (Double JavaDoc) ctx.lookup("java:comp/env/entry/Double");
44
45         assertNotNull("The Double looked up is null", actual);
46         assertEquals(expected, actual);
47     }
48
49     public void testLookupLongEntry() throws Exception JavaDoc {
50         InitialContext JavaDoc ctx = new InitialContext JavaDoc();
51         assertNotNull("The InitialContext is null", ctx);
52
53         Long JavaDoc expected = new Long JavaDoc(1L);
54         Long JavaDoc actual = (Long JavaDoc) ctx.lookup("java:comp/env/entry/Long");
55
56         assertNotNull("The Long looked up is null", actual);
57         assertEquals(expected, actual);
58     }
59
60     public void testLookupFloatEntry() throws Exception JavaDoc {
61         InitialContext JavaDoc ctx = new InitialContext JavaDoc();
62         assertNotNull("The InitialContext is null", ctx);
63
64         Float JavaDoc expected = new Float JavaDoc(1.0F);
65         Float JavaDoc actual = (Float JavaDoc) ctx.lookup("java:comp/env/entry/Float");
66
67         assertNotNull("The Float looked up is null", actual);
68         assertEquals(expected, actual);
69     }
70
71     public void testLookupIntegerEntry() throws Exception JavaDoc {
72         InitialContext JavaDoc ctx = new InitialContext JavaDoc();
73         assertNotNull("The InitialContext is null", ctx);
74
75         Integer JavaDoc expected = new Integer JavaDoc(1);
76         Integer JavaDoc actual = (Integer JavaDoc) ctx.lookup("java:comp/env/entry/Integer");
77
78         assertNotNull("The Integer looked up is null", actual);
79         assertEquals(expected, actual);
80     }
81
82     public void testLookupShortEntry() throws Exception JavaDoc {
83         InitialContext JavaDoc ctx = new InitialContext JavaDoc();
84         assertNotNull("The InitialContext is null", ctx);
85
86         Short JavaDoc expected = new Short JavaDoc((short) 1);
87         Short JavaDoc actual = (Short JavaDoc) ctx.lookup("java:comp/env/entry/Short");
88
89         assertNotNull("The Short looked up is null", actual);
90         assertEquals(expected, actual);
91     }
92
93     public void testLookupBooleanEntry() throws Exception JavaDoc {
94         InitialContext JavaDoc ctx = new InitialContext JavaDoc();
95         assertNotNull("The InitialContext is null", ctx);
96
97         Boolean JavaDoc expected = new Boolean JavaDoc(true);
98         Boolean JavaDoc actual = (Boolean JavaDoc) ctx.lookup("java:comp/env/entry/Boolean");
99
100         assertNotNull("The Boolean looked up is null", actual);
101         assertEquals(expected, actual);
102     }
103
104     public void testLookupByteEntry() throws Exception JavaDoc {
105         InitialContext JavaDoc ctx = new InitialContext JavaDoc();
106         assertNotNull("The InitialContext is null", ctx);
107
108         Byte JavaDoc expected = new Byte JavaDoc((byte) 1);
109         Byte JavaDoc actual = (Byte JavaDoc) ctx.lookup("java:comp/env/entry/Byte");
110
111         assertNotNull("The Byte looked up is null", actual);
112         assertEquals(expected, actual);
113     }
114
115 }
116
Popular Tags