01: /*
02: * CoadunationLib: The coaduntion implementation library.
03: * Copyright (C) 2006 Rift IT Contracting
04: *
05: * This library is free software; you can redistribute it and/or
06: * modify it under the terms of the GNU Lesser General Public
07: * License as published by the Free Software Foundation; either
08: * version 2.1 of the License, or (at your option) any later version.
09: *
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;
28: import javax.naming.NamingEnumeration;
29:
30: /**
31: *
32: * @author mincemeat
33: */
34: public class MemoryNamingEnumerationTest extends TestCase {
35:
36: public MemoryNamingEnumerationTest(String testName) {
37: super (testName);
38: }
39:
40: protected void setUp() throws Exception {
41: }
42:
43: protected void tearDown() throws Exception {
44: }
45:
46: public static Test suite() {
47: TestSuite suite = new TestSuite(
48: MemoryNamingEnumerationTest.class);
49:
50: return suite;
51: }
52:
53: /**
54: * Test of close MemoryNamingEnumeration
55: */
56: public void testMemoryNamingEnumeration() throws Exception {
57: System.out.println("MemoryNamingEnumeration");
58:
59: MemoryNamingEnumeration instance = new MemoryNamingEnumeration(
60: new NamingParser().parse("java:comp/test/freddy/bob")
61: .getAll());
62:
63: int index = 0;
64: while (instance.hasMore()) {
65: Object result = instance.next();
66: if ((index == 0) && (!result.equals("java:comp"))) {
67: fail("java:comp not found.");
68: } else if ((index == 1) && (!result.equals("test"))) {
69: fail("test not found.");
70: } else if ((index == 2) && (!result.equals("freddy"))) {
71: fail("freddy not found.");
72: } else if ((index == 3) && (!result.equals("bob"))) {
73: fail("bob not found.");
74: }
75: index++;
76: }
77:
78: }
79:
80: }
|