KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > admin > wsmgmt > registry > ConfigHelperTest


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24 /*
25  * ConfigHelperTest.java
26  *
27  * Created on June 10, 2005, 2:45 PM
28  */

29
30 package com.sun.enterprise.admin.wsmgmt.registry;
31
32 /**
33  *
34  * @author Harpreet Singh
35  */

36
37 import com.sun.enterprise.admin.wsmgmt.registry.*;
38
39 import junit.framework.TestCase;
40 import junit.framework.TestResult;
41 import junit.framework.TestSuite;
42 import com.sun.enterprise.config.ConfigContext;
43 import com.sun.enterprise.config.ConfigBean;
44 import com.sun.enterprise.config.ConfigFactory;
45 import com.sun.enterprise.config.ConfigException;
46 import com.sun.enterprise.admin.wsmgmt.registry.ConfigHelper;
47
48
49 import java.util.List JavaDoc;
50 import java.util.Map JavaDoc;
51 import java.util.HashMap JavaDoc;
52 import java.util.Iterator JavaDoc;
53
54 public class ConfigHelperTest extends TestCase {
55    
56     public ConfigHelperTest(String JavaDoc name) {
57         super(name);
58     }
59
60     public void testListRegistryLocations() throws ConfigException {
61         try {
62             String JavaDoc[] locations = ch_query.listRegistryLocations();
63             System.out.println("Looking up Connection Jndi Name. Name" +
64                     " should be "+POOL_NAME);
65             
66             if(locations.length == 1){
67                 System.out.println("Locations = "+ locations[0]);
68                 assertEquals("Looked up Registry Location ", POOL_NAME,
69                         locations[0]);
70             } else{
71                 fail(" Returned wrong number of RegistryLocation");
72             }
73         } catch (ConfigException ce) {
74             ce.printStackTrace();
75             throw ce;
76         }
77     }
78
79  
80     protected void setUp() {
81         try{
82             System.out.println("ConfigHelperTest");
83             ch_query = ConfigHelper.getInstanceToQueryRegistryLocations();
84             ConfigContext ctx = ConfigFactory.createConfigContext(URL);
85             ch_query.setConfigContext(ctx);
86         } catch (Exception JavaDoc e){
87             e.printStackTrace();
88         }
89     }
90
91     private final static String JavaDoc URL =
92        "tests/com/sun/enterprise/admin/wsmgmt/registry/connectionpool-domain.xml";
93     private final static String JavaDoc POOL_NAME = "foojndi";
94     
95     private ConfigHelper ch_query = null;
96     private ConfigHelper ch_add_delete = null;
97     public static void main(String JavaDoc args[]) {
98         junit.textui.TestRunner.run(ConfigHelperTest.class);
99     }
100 }
101
Popular Tags