KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > compliance > standard > OperationInfoTEST


1 /*
2  * JBoss, the OpenSource J2EE webOS
3  *
4  * Distributable under LGPL license.
5  * See terms of license at gnu.org.
6  */

7
8 package test.compliance.standard;
9
10 import junit.framework.TestCase;
11
12 import javax.management.MBeanInfo;
13 import javax.management.MBeanOperationInfo;
14
15 /**
16  * @author <a HREF="mailto:trevor@protocool.com">Trevor Squires</a>.
17  */

18
19 public class OperationInfoTEST extends TestCase
20 {
21    private String failureHint;
22    private MBeanInfo info;
23    private String operationName;
24    private int impact;
25    private String returnType;
26    private String signatureString;
27
28    public OperationInfoTEST(String failureHint, MBeanInfo info, String operationName, int impact, String returnType, String[] signature)
29    {
30       super("testValidOperation");
31       this.failureHint = failureHint;
32       this.info = info;
33       this.operationName = operationName;
34       this.impact = impact;
35       this.returnType = returnType;
36       this.signatureString = InfoUtil.makeSignatureString(signature);
37    }
38
39    public void testValidOperation()
40    {
41       MBeanOperationInfo[] operations = info.getOperations();
42
43       MBeanOperationInfo foundOperation = null;
44
45       for (int i = 0; i < operations.length; i++)
46       {
47          if (operations[i].getName().equals(operationName))
48          {
49             if (signatureString.equals(InfoUtil.makeSignatureString(operations[i].getSignature())))
50             {
51                foundOperation = operations[i];
52                break;
53             }
54          }
55       }
56
57       assertNotNull(failureHint + ": " + info.getClassName() + "." + operationName + signatureString + " was not found", foundOperation);
58       assertEquals(failureHint + ": " + info.getClassName() + "." + operationName + signatureString + " impact", impact, foundOperation.getImpact());
59       assertEquals(failureHint + ": " + info.getClassName() + "." + operationName + signatureString + " returnType", returnType, foundOperation.getReturnType());
60    }
61 }
62
Popular Tags