KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > rift > coad > lib > naming > cos > MemoryNamingEnumerationTest


1 /*
2  * CoadunationLib: The coaduntion implementation library.
3  * Copyright (C) 2006 Rift IT Contracting
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18  *
19  * MemoryNamingEnumerationTest.java
20  *
21  * JUnit based test
22  */

23
24 package com.rift.coad.lib.naming.cos;
25
26 import junit.framework.*;
27 import java.util.Enumeration JavaDoc;
28 import javax.naming.NamingEnumeration JavaDoc;
29
30 /**
31  *
32  * @author mincemeat
33  */

34 public class MemoryNamingEnumerationTest extends TestCase {
35     
36     public MemoryNamingEnumerationTest(String JavaDoc testName) {
37         super(testName);
38     }
39
40     protected void setUp() throws Exception JavaDoc {
41     }
42
43     protected void tearDown() throws Exception JavaDoc {
44     }
45
46     public static Test suite() {
47         TestSuite suite = new TestSuite(MemoryNamingEnumerationTest.class);
48         
49         return suite;
50     }
51
52     /**
53      * Test of close MemoryNamingEnumeration
54      */

55     public void testMemoryNamingEnumeration() throws Exception JavaDoc {
56         System.out.println("MemoryNamingEnumeration");
57         
58         MemoryNamingEnumeration instance = new MemoryNamingEnumeration(
59                 new NamingParser().parse("java:comp/test/freddy/bob").getAll());
60         
61         int index = 0;
62         while (instance.hasMore()) {
63             Object JavaDoc result = instance.next();
64             if ((index == 0) && (!result.equals("java:comp"))) {
65                 fail("java:comp not found.");
66             } else if ((index == 1) && (!result.equals("test"))) {
67                 fail("test not found.");
68             } else if ((index == 2) && (!result.equals("freddy"))) {
69                 fail("freddy not found.");
70             } else if ((index == 3) && (!result.equals("bob"))) {
71                 fail("bob not found.");
72             }
73             index++;
74         }
75         
76     }
77
78     
79 }
80
Popular Tags