Methods Summary |
---|
public void | changeLevel(MonitoringLevel from, MonitoringLevel to, MonitoredObjectType type)
|
public void | changeLevel(MonitoringLevel from, MonitoringLevel to, javax.management.j2ee.statistics.Stats handback)
|
private javax.management.ObjectName | getObjectName()
ObjectName obj =null;
try{
obj = new ObjectName("defaultDomain:category=monitor,type=jvm,name=jvm");
}catch (Exception e){
e.printStackTrace();
}
return obj;
|
public static void | main(java.lang.String[] args)
junit.textui.TestRunner.run(suite());
|
public void | setLevel(MonitoringLevel level)
|
protected void | setUp()
server = (MBeanServer) (MBeanServerFactory.createMBeanServer(null));
mrh = MonitoringRegistrationHelper.getInstance();
|
public static junit.framework.Test | suite()
TestSuite suite = new TestSuite(MonitoringRegistrationHelperTest.class);
return suite;
|
protected void | tearDown()
|
public void | testCreation()
assertNotNull(mrh);
|
public void | testRegisterStats()
try{
ObjectName obj = getObjectName();
Stats stats = new S1ASJVMStatsImplMock();
try{
mrh.registerJVMStats((JVMStats)stats, this);
}
catch(Exception e){
e.printStackTrace();
assertEquals("MonitoringRegistrationException", e.getClass().getName());
}
assertEquals(1, server.getMBeanCount().intValue());
assertEquals(true, server.isInstanceOf(obj, "GeneratedMonitoringMBeanImpl"));
}catch(Exception e){
e.getLocalizedMessage();
}
|
public void | testRegisteredMBean()
try{
assertNotNull(server);
ObjectName obj = getObjectName();
Stats stats = new S1ASJVMStatsImplMock();
try{
mrh.registerJVMStats((JVMStats)stats, this);
}
catch(Exception e){
e.printStackTrace();
assertEquals("MonitoringRegistrationException", e.getClass().getName());
}
//assertEquals(true, server.isRegistered(obj));
MBeanInfo mInfo = (MBeanInfo)server.getMBeanInfo(obj);
assertNotNull(mInfo);
MBeanAttributeInfo[] attrInfo = mInfo.getAttributes();
assertNotNull(attrInfo);
for(int i=0; i<attrInfo.length;i++){
String attr = attrInfo[i].getName();
System.out.println("getting attribute:"+attr);
Object n = server.getAttribute(obj,attr);
try{
assertEquals(Long.class, n.getClass());
}
catch(Error ex){
ex.getLocalizedMessage();
assertEquals(String.class, n.getClass());
}
catch(Exception e){
assertNull(n);
}
}
}
catch(Exception ex){
ex.printStackTrace();
assertEquals(NullPointerException.class, ex.getClass());
}
|
public void | testUnregisterStats()
try{
ObjectName obj = getObjectName();
mrh.unregisterJVMStats();
assertEquals(false, server.isRegistered(obj));
assertEquals(0, server.queryMBeans(obj, null).size());
}catch(Exception e){
e.getLocalizedMessage();
}
|