KickJava   Java API By Example, From Geeks To Geeks.

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


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 import java.io.Serializable JavaDoc;
31
32
33 import javax.management.ObjectName JavaDoc;
34 import javax.management.AttributeList JavaDoc;
35 import javax.management.MBeanServerConnection JavaDoc;
36 import javax.management.NotCompliantMBeanException JavaDoc;
37
38 import com.sun.appserv.management.j2ee.J2EEDomain;
39
40
41 import com.sun.appserv.management.util.jmx.MBeanServerConnectionConnectionSource;
42
43 import com.sun.enterprise.management.support.AMXNonConfigImplBase;
44 import com.sun.enterprise.management.support.QueryMgrImpl;
45 import com.sun.appserv.management.ext.wsmgmt.WebServiceMgr;
46 import com.sun.appserv.management.util.misc.ExceptionUtil;
47 import com.sun.appserv.management.util.misc.TypeCast;
48
49 import com.sun.appserv.management.j2ee.WebServiceEndpoint;
50 import com.sun.appserv.management.config.WebServiceEndpointConfig;
51 import com.sun.appserv.management.ext.wsmgmt.MessageTrace;
52 import com.sun.appserv.management.ext.wsmgmt.MessageTraceImpl;
53 import com.sun.appserv.management.base.XTypes;
54 import com.sun.appserv.management.j2ee.J2EETypes;
55 import com.sun.appserv.management.base.Util;
56
57 import com.sun.enterprise.management.AMXTestBase;
58 import com.sun.enterprise.management.Capabilities;
59
60 /**
61  */

62 public final class WebServiceRuntimeTest extends AMXTestBase
63 {
64
65     public WebServiceRuntimeTest() throws IOException JavaDoc {
66     }
67     
68         public static Capabilities
69     getCapabilities()
70     {
71         return getOfflineCapableCapabilities( false );
72     }
73     
74     public void testRuntimeMBeans() {
75         assert (getDomainRoot().getWebServiceMgr() != null);
76
77        final Set JavaDoc<WebServiceEndpoint> s =
78         getDomainRoot().getQueryMgr().queryJ2EETypeSet( J2EETypes.WEB_SERVICE_ENDPOINT);
79
80        for( final WebServiceEndpoint wsp : s )
81        {
82           wsp.resetStats();
83
84           long ts = wsp.getLastResetTime();
85           System.out.println("Web Service endpoint name is " + wsp.getName());
86           System.out.println("Last reset time is " + ts);
87
88           try {
89               Thread.currentThread().sleep(1);
90           } catch (Exception JavaDoc e) {
91           }
92
93           wsp.resetStats();
94           long ts2 = wsp.getLastResetTime();
95           System.out.println("Last reset time is " + ts2);
96           if (( ts == 0 ) && ( ts2 == 0)) {
97             assert(true);
98           } else {
99               assert( ts != ts2);
100           }
101        }
102     }
103
104     public void testMessageTrace() {
105         assert (getDomainRoot().getWebServiceMgr() != null);
106
107        final Set JavaDoc<WebServiceEndpoint> s =
108         getDomainRoot().getQueryMgr().queryJ2EETypeSet(J2EETypes.WEB_SERVICE_ENDPOINT);
109
110        for( final WebServiceEndpoint wsp : s )
111        {
112           final MessageTrace[] msgs = wsp.getMessagesInHistory();
113             if ( msgs == null)
114             {
115                 System.out.println(" No messages found");
116                 continue;
117             }
118             
119             System.out.println(" Collected messages " + msgs.length);
120             for ( int idx =0; idx < msgs.length; idx++)
121             {
122                 final MessageTrace msg = msgs[idx];
123
124                 System.out.println(" message id " + msg.getMessageID());
125                 System.out.println(" application id " + msg.getApplicationID());
126                 System.out.println(" endpoint name " + msg.getEndpointName());
127                 System.out.println(" response size " + msg.getResponseSize());
128                 System.out.println(" request size " + msg.getRequestSize());
129                 System.out.println(" transport type is " +
130                     msg.getTransportType());
131                 System.out.println(" request headers are " +
132                     msg.getHTTPRequestHeaders() );
133                 System.out.println(" response headers are " +
134                     msg.getHTTPResponseHeaders() );
135                 System.out.println(" fault code is " + msg.getFaultCode());
136                 System.out.println(" fault string is " + msg.getFaultString());
137                 System.out.println(" fault actor is " + msg.getFaultActor());
138                 System.out.println(" client host is " + msg.getClientHost());
139                 System.out.println(" principal name is " +
140                     msg.getPrincipalName());
141                 System.out.println(" request content is " +
142                     msg.getRequestContent());
143                 System.out.println(" response content is " +
144                     msg.getResponseContent());
145                 System.out.println(" call flow enabled " +
146                     msg.isCallFlowEnabled());
147             }
148        }
149     }
150 }
151
152
153
Popular Tags