KickJava   Java API By Example, From Geeks To Geeks.

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


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  * 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 JavaDoc;
28 import java.util.Properties JavaDoc;
29 import java.io.Serializable JavaDoc;
30 import javax.naming.CompoundName JavaDoc;
31 import javax.naming.Name JavaDoc;
32 import javax.naming.NameParser JavaDoc;
33 import javax.naming.NamingException JavaDoc;
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 JavaDoc testName) {
43         super(testName);
44     }
45
46     protected void setUp() throws Exception JavaDoc {
47     }
48
49     protected void tearDown() throws Exception JavaDoc {
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 JavaDoc {
62         System.out.println("parse");
63         
64         String JavaDoc name = "";
65         NamingParser instance = new NamingParser();
66         
67         Name JavaDoc result = instance.parse("java:comp/test/freddy");
68         int index = 0;
69         for (Enumeration JavaDoc enumer = result.getAll(); enumer.hasMoreElements();index++) {
70             String JavaDoc value = enumer.nextElement().toString();
71             if ((index == 0) && (!value.equals("java:comp"))) {
72                 fail("Parsing failed");
73             }
74             if ((index == 1) && (!value.equals("test"))) {
75                 fail("Parsing failed");
76             }
77             if ((index == 2) && (!value.equals("freddy"))) {
78                 fail("Parsing failed");
79             }
80         }
81     }
82     
83 }
84
Popular Tags