1 22 package org.jboss.test.jmx.test; 23 24 import java.net.URL ; 25 import java.net.HttpURLConnection ; 26 27 import org.apache.commons.httpclient.methods.PostMethod; 28 import org.apache.commons.httpclient.HttpClient; 29 30 import org.jboss.test.JBossTestCase; 31 import org.jboss.test.util.web.HttpUtils; 32 33 38 public class JMXConsoleUnitTestCase 39 extends JBossTestCase 40 { 41 private String baseURLNoAuth = HttpUtils.getBaseURLNoAuth(); 42 43 public JMXConsoleUnitTestCase(String name) 44 { 45 super(name); 46 } 47 48 51 public void testIndexPage() 52 throws Exception 53 { 54 URL url = new URL (baseURLNoAuth+"jmx-console/index.jsp"); 55 HttpUtils.accessURL(url); 56 } 57 58 61 public void testMBeanInspection() 62 throws Exception 63 { 64 URL url = new URL (baseURLNoAuth+"jmx-console/HtmlAdaptor?action=inspectMBean&name=jboss%3Aservice%3DNaming"); 66 HttpUtils.accessURL(url); 67 } 68 69 72 public void testMBeanOperation() 73 throws Exception 74 { 75 URL url = new URL (baseURLNoAuth+"jmx-console/HtmlAdaptor?action=inspectMBean&name=jboss.system%3Atype%3DServer"); 77 HttpUtils.accessURL(url); 78 PostMethod formPost = new PostMethod(baseURLNoAuth+"jmx-console/HtmlAdaptor"); 80 formPost.addRequestHeader("Referer", baseURLNoAuth+"jmx-console/HtmlAdaptor"); 81 formPost.addParameter("action", "invokeOpByName"); 82 formPost.addParameter("name", "jboss.system:type=Server"); 83 formPost.addParameter("methodName", "runGarbageCollector"); 84 HttpClient httpConn = new HttpClient(); 85 int responseCode = httpConn.executeMethod(formPost.getHostConfiguration(), 86 formPost); 87 assertTrue("HTTP_OK", responseCode==HttpURLConnection.HTTP_OK); 88 } 89 } 90 | Popular Tags |