Methods Summary |
---|
public static void | main(java.lang.String[] args)
junit.textui.TestRunner.run(suite());
|
protected void | setUp()
mbean = new GeneratedMonitoringMBeanImpl();
jvm = new S1ASJVMStatsImplMock();
m = mbean.introspect(jvm);
attrs = m.getAttributes();
for(int i=0; i< attrs.length;i++){
attributes.put(attrs[i].getName(),attrs[i].getName());
}
|
public static junit.framework.Test | suite()
TestSuite suite = new TestSuite(GeneratedMonitoringMBeanTest.class);
return suite;
|
protected void | tearDown()
|
public void | testAtrributes()
Enumeration en = attributes.elements();
while(en.hasMoreElements()){
String attr = (String)en.nextElement();
System.out.println("testing attribute:"+attr);
try{ assertEquals("HeapSize", attr.substring(0,attr.indexOf("_")));
}catch(Error ex){
try{assertEquals("MaxMemory",attr.substring(0,attr.indexOf("_")));
}catch(Error e){
try{assertEquals("UpTime",attr.substring(0,attr.indexOf("_")));
}catch(Error e1){
assertEquals("AvailableProcessors",attr.substring(0,attr.indexOf("_")));
}
}
}
}
|
public void | testCreation()
assertNotNull(mbean);
assertNotNull(m);
assertNotNull(jvm);
assertNotNull(attrs);
|
public void | testGetAttributeWithCorrectAttrName()
try{
Enumeration e = attributes.keys();
while(e.hasMoreElements()){
String elem = (String)e.nextElement();
Object n = mbean.getAttribute(elem);
try{
assertEquals(Long.class, n.getClass());
}
catch(Error ex){
ex.getLocalizedMessage();
assertEquals(String.class, n.getClass());
}
}
}
catch(Exception ex){
assertEquals(NullPointerException.class, ex.getClass());
}
|
public void | testGetAttributeWithIncorrectAttrName()
try{
Enumeration e = attributes.keys();
while(e.hasMoreElements()){
String elem = (String)e.nextElement();
Object n = mbean.getAttribute(elem+"o");
try{
assertEquals(Long.class, n.getClass());
}
catch(Error ex){
ex.getLocalizedMessage();
assertEquals(String.class, n.getClass());
}
}
}
catch(Exception ex){
assertEquals(AttributeNotFoundException.class, ex.getClass());
}
|
public void | testGetAttributeWithNull()
try{
Enumeration e = attributes.keys();
while(e.hasMoreElements()){
Object n = mbean.getAttribute(null);
try{
assertEquals(Long.class, n.getClass());
}
catch(Error ex){
ex.getLocalizedMessage();
assertEquals(String.class, n.getClass());
}
}
}
catch(Exception ex){
assertEquals(NullPointerException.class, ex.getClass());
}
|