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