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: * NamingParserTest.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 java.util.Properties;
29: import java.io.Serializable;
30: import javax.naming.CompoundName;
31: import javax.naming.Name;
32: import javax.naming.NameParser;
33: import javax.naming.NamingException;
34:
35: /**
36: * This test tests the naming parser
37: *
38: * @author Brett Chaldecott
39: */
40: public class NamingParserTest extends TestCase {
41:
42: public NamingParserTest(String testName) {
43: super (testName);
44: }
45:
46: protected void setUp() throws Exception {
47: }
48:
49: protected void tearDown() throws Exception {
50: }
51:
52: public static Test suite() {
53: TestSuite suite = new TestSuite(NamingParserTest.class);
54:
55: return suite;
56: }
57:
58: /**
59: * Test of parse method, of class com.rift.coad.lib.naming.cos.NamingParser.
60: */
61: public void testParse() throws Exception {
62: System.out.println("parse");
63:
64: String name = "";
65: NamingParser instance = new NamingParser();
66:
67: Name result = instance.parse("java:comp/test/freddy");
68: int index = 0;
69: for (Enumeration enumer = result.getAll(); enumer
70: .hasMoreElements(); index++) {
71: String value = enumer.nextElement().toString();
72: if ((index == 0) && (!value.equals("java:comp"))) {
73: fail("Parsing failed");
74: }
75: if ((index == 1) && (!value.equals("test"))) {
76: fail("Parsing failed");
77: }
78: if ((index == 2) && (!value.equals("freddy"))) {
79: fail("Parsing failed");
80: }
81: }
82: }
83:
84: }
|