1 26 package org.objectweb.jonas.applications.clients.apps.mejb; 27 28 import java.net.URL ; 29 import javax.xml.namespace.QName ; 30 import junit.framework.TestSuite; 31 import junit.textui.TestRunner; 32 import org.apache.axis.client.Call; 33 import org.apache.axis.client.Service; 34 import org.objectweb.jonas.applications.util.JApplicationsTestCase; 35 36 41 public class F_MonitoringEndpoint extends JApplicationsTestCase{ 42 43 44 47 private static final String URL_ENDPOINT = "/mejb/ManagementEndpoint/ManagementEndpoint"; 48 49 52 private static final String NAMESPACE = "http://mejb.jonas.objectweb.org"; 53 54 57 private static Call call; 58 59 63 public static void main(String [] args) { 64 String testtorun = null; 65 for (int argn = 0; argn < args.length; argn++) { 66 String sArg = args[argn]; 67 if (sArg.equals("-n")) { 68 testtorun = args[++argn]; 69 } 70 } 71 if (testtorun == null) { 72 TestRunner.run(suite()); 73 } else { 74 TestRunner.run(new F_MonitoringEndpoint(testtorun)); 75 } 76 } 77 78 82 public F_MonitoringEndpoint(String s) { 83 super (s, URL_ENDPOINT); 84 } 85 86 90 public static TestSuite suite() { 91 return new TestSuite(F_MonitoringEndpoint.class); 92 } 93 94 98 protected void setUp() throws Exception { 99 super.setUp(); 100 useEar("mejb"); 101 Service service = new Service(); 102 call = (Call) service.createCall(); 103 call.setTargetEndpointAddress (new URL (getAbsoluteUrl(URL_ENDPOINT))); 104 } 105 106 110 public void testGetMBeanCount() throws Exception { 111 call.setOperationName (new QName (NAMESPACE, "getMBeanCount")); 112 Integer res = (Integer ) call.invoke (new Object []{}); 113 if (res.intValue() <= 0) { 114 fail ("Could not get any mbeans"); 115 } 116 } 117 118 122 public void testGetServers() throws Exception { 123 call.setOperationName (new QName (NAMESPACE, "getServers")); 124 String [] res = (String []) call.invoke (new Object []{}); 125 if (res.length < 1) { 126 fail ("No servers found in the domain"); 127 } 128 } 129 130 135 public void testDefaultDomain() throws Exception { 136 call.setOperationName (new QName (NAMESPACE, "getDefaultDomain")); 138 String res = (String ) call.invoke (new Object []{}); 139 if (!res.equals("jonas")) { 140 fail ("The domain name gotten through the endpoint does not match the actual domain name. Expected :jonas, received :" + res); 141 } 142 } 143 144 149 public void testGetAttribute() throws Exception { 150 String serverName = "jonas"; 152 String domainName = "jonas"; 153 String objectName = domainName + ":j2eeType=J2EEServer,name=" + serverName; 154 155 call.setOperationName (new QName (NAMESPACE, "getAttribute")); 156 String [] res = (String []) call.invoke (new Object []{serverName, objectName, "serverName"}); 157 if (!res[0].equals(serverName)) { 158 fail ("The attribute value received does not match its acual value. Expected :" 159 + serverName + ", received:" + res[0]); 160 } 161 } 162 } 163 | Popular Tags |