1 22 package org.jboss.test.jmx.compliance.metadata; 23 24 25 import javax.management.MBeanFeatureInfo ; 26 27 import junit.framework.AssertionFailedError; 28 import junit.framework.TestCase; 29 30 36 public class MBeanFeatureInfoTEST extends TestCase 37 { 38 public MBeanFeatureInfoTEST(String s) 39 { 40 super(s); 41 } 42 43 46 public void testConstructor() 47 { 48 try 49 { 50 MBeanFeatureInfo info = new MBeanFeatureInfo ("Name", "This is a description."); 51 52 assertTrue(info.getName().equals("Name")); 53 assertTrue(info.getDescription().equals("This is a description.")); 54 } 55 catch (AssertionFailedError e) 56 { 57 throw e; 58 } 59 catch (Throwable t) 60 { 61 t.printStackTrace(); 62 fail("Unexpected error: " + t.toString()); 63 } 64 } 65 66 public void testHashCode() 67 throws Exception 68 { 69 MBeanFeatureInfo info1 = new MBeanFeatureInfo ("name", "description"); 70 MBeanFeatureInfo info2 = new MBeanFeatureInfo ("name", "description"); 71 72 assertTrue("Different instances with the same hashcode are equal", info1.hashCode() == info2.hashCode()); 73 } 74 75 public void testEquals() 76 throws Exception 77 { 78 MBeanFeatureInfo info = new MBeanFeatureInfo ("name", "description"); 79 80 assertTrue("Null should not be equal", info.equals(null) == false); 81 assertTrue("Only MBeanFeatureInfo should be equal", info.equals(new Object ()) == false); 82 83 MBeanFeatureInfo info2 = new MBeanFeatureInfo ("name", "description"); 84 85 assertTrue("Different instances of the same data are equal", info.equals(info2)); 86 assertTrue("Different instances of the same data are equal", info2.equals(info)); 87 88 info2 = new MBeanFeatureInfo ("name2", "description"); 89 90 assertTrue("Different instances with different names are not equal", info.equals(info2) == false); 91 assertTrue("Different instances with different names are not equal", info2.equals(info) == false); 92 93 info2 = new MBeanFeatureInfo ("name", "description2"); 94 95 assertTrue("Different instances with different descriptions are not equal", info.equals(info2) == false); 96 assertTrue("Different instances with different descritpions are not equal", info2.equals(info) == false); 97 } 98 } 99 | Popular Tags |