1 22 package org.jboss.test.jbossmx.compliance.standard; 23 24 import junit.framework.Test; 25 import junit.framework.TestSuite; 26 27 import org.jboss.test.jbossmx.compliance.TestCase; 28 29 import org.jboss.test.jbossmx.compliance.standard.support.Torture; 30 31 import javax.management.MBeanInfo ; 32 import javax.management.MBeanOperationInfo ; 33 34 40 public class InfoTortureTestCase 41 extends TestCase 42 { 43 private static int attributeTestCount = 0; 44 private static int operationTestCount = 0; 45 private static int constructorTestCount = 0; 46 47 public InfoTortureTestCase(String s) 48 { 49 super(s); 50 } 51 52 public static Test suite() 53 { 54 TestSuite testSuite = new TestSuite("All MBeanInfo Torture Tests for Standard MBeans"); 55 56 Object mbean = new Torture(); 57 MBeanInfo info = InfoUtil.getMBeanInfo(mbean, "test:type=mbeaninfo"); 58 59 addConstructorTest(testSuite, info, Torture.class.getName(), new String [0]); 61 addConstructorTest(testSuite, info, Torture.class.getName(), new String [] { String [][].class.getName() }); 62 63 testSuite.addTest(new TestCoverageTEST("Torture constructor list length", constructorTestCount, info.getConstructors().length)); 66 67 addSpuriousAttributeTest(testSuite, info, "peachy"); 69 addSpuriousAttributeTest(testSuite, info, "Peachy"); 70 addSpuriousAttributeTest(testSuite, info, "suer"); 71 addSpuriousAttributeTest(testSuite, info, "settlement"); 72 addSpuriousAttributeTest(testSuite, info, "Result"); 73 addSpuriousAttributeTest(testSuite, info, "Multi"); 74 75 addAttributeTest(testSuite, info, "NiceString", String .class.getName(), true, true, false); 78 addAttributeTest(testSuite, info, "NiceBoolean", boolean.class.getName(), true, true, true); 79 addAttributeTest(testSuite, info, "Something", String .class.getName(), false, true, false); 80 addAttributeTest(testSuite, info, "Int", int.class.getName(), false, true, false); 81 addAttributeTest(testSuite, info, "IntArray", int[].class.getName(), false, true, false); 82 addAttributeTest(testSuite, info, "NestedIntArray", int[][][].class.getName(), false, true, false); 83 addAttributeTest(testSuite, info, "Integer", Integer .class.getName(), false, true, false); 84 addAttributeTest(testSuite, info, "IntegerArray", Integer [].class.getName(), false, true, false); 85 addAttributeTest(testSuite, info, "NestedIntegerArray", Integer [][][].class.getName(), false, true, false); 86 addAttributeTest(testSuite, info, "Myinteger", int.class.getName(), true, false, false); 87 addAttributeTest(testSuite, info, "MyintegerArray", int[].class.getName(), true, false, false); 88 addAttributeTest(testSuite, info, "MyNestedintegerArray", int[][][].class.getName(), true, false, false); 89 addAttributeTest(testSuite, info, "MyInteger", Integer .class.getName(), true, false, false); 90 addAttributeTest(testSuite, info, "MyIntegerArray", Integer [].class.getName(), true, false, false); 91 addAttributeTest(testSuite, info, "MyNestedIntegerArray", Integer [][][].class.getName(), true, false, false); 92 addAttributeTest(testSuite, info, "ready", boolean.class.getName(), true, false, true); 93 94 97 testSuite.addTest(new TestCoverageTEST("Torture attribute list length", attributeTestCount, info.getAttributes().length)); 100 101 addOperationTest(testSuite, info, "settlement", MBeanOperationInfo.UNKNOWN, int.class.getName(), new String [] { String .class.getName() }); 104 addOperationTest(testSuite, info, "getSomething", MBeanOperationInfo.UNKNOWN, Void.TYPE.getName(), new String [0]); 105 addOperationTest(testSuite, info, "ispeachy", MBeanOperationInfo.UNKNOWN, boolean.class.getName(), new String [] { int.class.getName() }); 106 addOperationTest(testSuite, info, "isPeachy", MBeanOperationInfo.UNKNOWN, Boolean .class.getName(), new String [] { int.class.getName() }); 107 addOperationTest(testSuite, info, "setMulti", MBeanOperationInfo.UNKNOWN, Void.TYPE.getName(), new String [] { String .class.getName(), Integer .class.getName() }); 108 addOperationTest(testSuite, info, "getResult", MBeanOperationInfo.UNKNOWN, String .class.getName(), new String [] { String .class.getName() }); 109 addOperationTest(testSuite, info, "setNothing", MBeanOperationInfo.UNKNOWN, Void.TYPE.getName(), new String [0]); 110 addOperationTest(testSuite, info, "getNothing", MBeanOperationInfo.UNKNOWN, Void.TYPE.getName(), new String [0]); 111 addOperationTest(testSuite, info, "doSomethingCrazy", MBeanOperationInfo.UNKNOWN, String [][].class.getName(), new String [] { Object [].class.getName(), String [].class.getName(), int[][][].class.getName() }); 112 addOperationTest(testSuite, info, "issuer", MBeanOperationInfo.UNKNOWN, String .class.getName(), new String [0]); 116 117 addOperationTest(testSuite, info, "isReady", MBeanOperationInfo.UNKNOWN, Boolean .class.getName(), new String [0]); 119 120 testSuite.addTest(new TestCoverageTEST("Torture operation list length", operationTestCount, info.getOperations().length)); 123 124 return testSuite; 125 } 126 127 public static void addConstructorTest(TestSuite testSuite, MBeanInfo info, String name, String [] signature) 128 { 129 testSuite.addTest(new ConstructorInfoTEST("InfoTortureSUITE constructor", info, name, signature)); 130 constructorTestCount++; 131 } 132 133 public static void addSpuriousAttributeTest(TestSuite testSuite, MBeanInfo info, String name) 134 { 135 testSuite.addTest(new SpuriousAttributeTEST("InfoTortureSUITE spuriousAttribute", info, name)); 136 } 137 138 public static void addAttributeTest(TestSuite testSuite, MBeanInfo info, String name, String type, boolean read, boolean write, boolean is) 139 { 140 testSuite.addTest(new AttributeInfoTEST("InfoTortureSUITE attribute", info, name, type, read, write, is)); 141 attributeTestCount++; 142 } 143 144 public static void addOperationTest(TestSuite testSuite, MBeanInfo info, String name, int impact, String returnType, String [] signature) 145 { 146 testSuite.addTest(new OperationInfoTEST("InfoTortureSUITE operation", info, name, impact, returnType, signature)); 147 operationTestCount++; 148 } 149 150 public static class TestCoverageTEST 151 extends TestCase 152 { 153 private String msg; 154 private int expected; 155 private int got; 156 157 public TestCoverageTEST(String msg, int expected, int got) 158 { 159 super("testAdequateCoverage"); 160 this.msg = msg; 161 this.expected = expected; 162 this.got = got; 163 } 164 165 public void testAdequateCoverage() 166 { 167 assertEquals(msg, expected, got); 168 } 169 } 170 171 } 172 | Popular Tags |