KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > javax > management > compliance > signature > JMXSignatureTest


1 /*
2  * Copyright (C) The MX4J Contributors.
3  * All rights reserved.
4  *
5  * This software is distributed under the terms of the MX4J License version 1.0.
6  * See the terms of the MX4J License in the documentation provided with this software.
7  */

8
9 package test.javax.management.compliance.signature;
10
11 import java.io.Serializable JavaDoc;
12 import java.lang.reflect.Modifier JavaDoc;
13
14 import test.javax.management.compliance.JMXComplianceTestCase;
15 import test.javax.management.compliance.signature.support.NotCompliantException;
16 import test.javax.management.compliance.signature.support.NotCompliantWarningException;
17 import test.javax.management.compliance.signature.support.SignatureVerifier;
18
19 /**
20  * Test that verifies that the signature of the classes in JMXRI are equal to MX4J classes.
21  * It resembles a small TCK, for signatures of the JMX classes only.
22  *
23  * @version $Revision: 1.3 $
24  */

25 public class JMXSignatureTest extends JMXComplianceTestCase
26 {
27    public JMXSignatureTest(String JavaDoc s)
28    {
29       super(s);
30    }
31
32    protected boolean skipClassName(String JavaDoc className)
33    {
34       return "javax.management.MBeanServerPermissionCollection".equals(className);
35    }
36
37    protected boolean skipClass(Class JavaDoc cls)
38    {
39       // Exclude implementation classes in javax.management package
40
// Do not exclude classes that are package private but serializable
41
// like for example the QueryExp and ValueExp implementations (unless some exception)
42

43       int modifiers = cls.getModifiers();
44       boolean isPublic = Modifier.isPublic(modifiers);
45       boolean isProtected = Modifier.isProtected(modifiers);
46       boolean isPackage = !Modifier.isPrivate(modifiers) && !isProtected && !isPublic;
47       boolean isSerializable = Serializable JavaDoc.class.isAssignableFrom(cls);
48
49       if (isPublic || isProtected || (isPackage && isSerializable)) return false;
50       return true;
51    }
52
53    protected void checkCompliance(String JavaDoc className) throws Exception JavaDoc
54    {
55       ClassLoader JavaDoc jmxriLoader = createJMXRIWithTestsClassLoader();
56       ClassLoader JavaDoc mx4jLoader = createMX4JWithTestsClassLoader();
57
58       SignatureVerifier verifier = new SignatureVerifier();
59
60       try
61       {
62          verifier.verifySignature(className, jmxriLoader, mx4jLoader);
63       }
64       catch (NotCompliantException x)
65       {
66          fail(x.getMessage());
67       }
68       catch (NotCompliantWarningException x)
69       {
70          System.out.println("WARNING: " + x.getMessage());
71       }
72    }
73 }
74
Popular Tags