KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > management > ext > wsmgmt > WebServiceMgrTest


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 package com.sun.enterprise.management.ext.wsmgmt;
24
25 import java.util.Set JavaDoc;
26 import java.util.Iterator JavaDoc;
27 import java.io.IOException JavaDoc;
28 import java.util.Map JavaDoc;
29 import java.util.HashMap JavaDoc;
30
31 import com.sun.appserv.management.j2ee.WebServiceEndpoint;
32 import com.sun.appserv.management.monitor.WebServiceEndpointMonitor;
33
34 import com.sun.appserv.management.ext.wsmgmt.WebServiceMgr;
35 import com.sun.appserv.management.ext.wsmgmt.WebServiceEndpointInfo;
36
37 import com.sun.enterprise.management.AMXTestBase;
38 import com.sun.enterprise.management.Capabilities;
39
40
41
42 /**
43  */

44 public final class WebServiceMgrTest extends AMXTestBase
45 {
46
47     public WebServiceMgrTest(){
48     }
49     
50         public static Capabilities
51     getCapabilities()
52     {
53         return getOfflineCapableCapabilities( false );
54     }
55     
56     public void testGetWebServiceMgr() {
57         assert (getDomainRoot().getWebServiceMgr() != null);
58     }
59     
60     public void testGetWebServiceNames() {
61         java.util.Map JavaDoc m = null;
62         
63         m = getDomainRoot().getWebServiceMgr().getWebServiceEndpointKeys();
64         
65         if ( m == null) {
66             System.out.println("No web services found ");
67             return;
68         }
69         
70         System.out.println("Number of web services " + m.keySet().size());
71         System.out.println("Fully qualified names...");
72         for (Iterator JavaDoc iter = m.keySet().iterator(); iter.hasNext();) {
73             String JavaDoc key = (String JavaDoc)iter.next();
74             System.out.println("Looking for runtime objects for " + key);
75             Set JavaDoc<WebServiceEndpoint> epSet =
76             getDomainRoot().getWebServiceMgr().getWebServiceEndpointSet(key,
77             "server");
78             if ( epSet != null) {
79                 System.out.println("Found " + epSet.size() + " for " + key);
80                 for(Iterator JavaDoc epItr = epSet.iterator(); epItr.hasNext();) {
81                     WebServiceEndpoint ep = (WebServiceEndpoint) epItr.next();
82                     System.out.println("Found " + ep.getName() );
83                     WebServiceEndpointMonitor epm = (WebServiceEndpointMonitor)
84                     ep.getMonitoringPeer();
85                     System.out.println("Monitoing peer for " + ep.getName() +
86                     " is " + epm);
87
88                 }
89             }
90         }
91         System.out.println("Display names...");
92         for (Iterator JavaDoc iter = m.values().iterator(); iter.hasNext();) {
93             System.out.println((String JavaDoc)iter.next());
94         }
95         assert(true);
96     }
97
98     public void testGetWebServiceInfo() {
99         Map JavaDoc<Object JavaDoc,String JavaDoc> m = null;
100         
101         m = getDomainRoot().getWebServiceMgr().getWebServiceEndpointKeys();
102         
103         if ( m == null) {
104             System.out.println("No web services found ");
105             return;
106         }
107         
108         System.out.println("Number of web services " + m.keySet().size());
109         System.out.println("Fully qualified names...");
110         for( final Object JavaDoc fqn : m.keySet() )
111         {
112             System.out.println("Info for web service " + fqn);
113             
114             final WebServiceEndpointInfo info =
115                 getDomainRoot().getWebServiceMgr().getWebServiceEndpointInfo(fqn);
116             
117             /*
118             System.out.println("Keys are " + propMap.keySet().size());
119             for( final String key : infos.keySet() )
120             {
121                 System.out.println( key );
122             }
123             
124             System.out.println("Values are ");
125             for( final WebServiceEndpointInfo info : infos.values() )
126             {
127                  System.out.println( obj.toString() );
128             }
129             */

130        }
131     }
132     
133     /**
134      * Tests to see if any RegistryLocations are present.
135      * Expects to see atleast one, else the test fails. Create a connection
136      * pool with a type javax.xml.registry.ConnectionFactory
137      */

138     public void testListRegistryLocations (){
139         String JavaDoc[] list = getDomainRoot().getWebServiceMgr().listRegistryLocations();
140         if(list == null){
141             fail("Did not get any registry locations. Please check you have " +
142                     "created one with the name foo");
143         } else{
144             for (int i = 0; i< list.length; i++){
145                 System.out.println("RegistryLocation = "+list[i]);
146             }
147             // if you get any names in the connection definition, pass the test
148
assert(true);
149         }
150     }
151
152     public void testAddRegistryConnectionResources (){
153         String JavaDoc jndiname = "eis/SOAR";
154         String JavaDoc description = "Duh";
155         String JavaDoc purl = "http://publishurl";
156         String JavaDoc qurl = "http://queryurl";
157         Map JavaDoc<String JavaDoc, String JavaDoc> map = new HashMap JavaDoc <String JavaDoc, String JavaDoc> ();
158         map.put (WebServiceMgr.QUERY_URL_KEY, qurl);
159         map.put (WebServiceMgr.PUBLISH_URL_KEY, purl);
160         
161         //getDomainRoot().getWebServiceMgr().addRegistryConnectionResources (jndiname, description,
162
// map);
163
assertTrue(true);
164     }
165
166     public void testRemoveRegistryConnectionResources (){
167         String JavaDoc jndiname = "eis/SOAR";
168         getDomainRoot().getWebServiceMgr().removeRegistryConnectionResources (jndiname);
169         assertTrue(true);
170     }
171 }
172
173
174
Popular Tags