01: /*
02: * Copyright (C) The MX4J Contributors.
03: * All rights reserved.
04: *
05: * This software is distributed under the terms of the MX4J License version 1.0.
06: * See the terms of the MX4J License in the documentation provided with this software.
07: */
08:
09: package test.javax.management.remote.compliance.signature;
10:
11: import java.io.Serializable;
12: import java.lang.reflect.Modifier;
13:
14: import test.javax.management.compliance.signature.support.NotCompliantException;
15: import test.javax.management.compliance.signature.support.NotCompliantWarningException;
16: import test.javax.management.compliance.signature.support.SignatureVerifier;
17: import test.javax.management.remote.compliance.RemoteJMXComplianceTestCase;
18:
19: /**
20: * @version $Revision: 1.4 $
21: */
22: public class RemoteJMXSignatureTest extends RemoteJMXComplianceTestCase {
23: public RemoteJMXSignatureTest(String s) {
24: super (s);
25: }
26:
27: protected boolean skipClassName(String className) {
28: boolean isStub = className.endsWith("_Stub");
29: return isStub;
30: }
31:
32: protected boolean skipClass(Class cls) {
33: // Exclude implementation classes in javax.management.remote package
34:
35: int modifiers = cls.getModifiers();
36: boolean isPublic = Modifier.isPublic(modifiers);
37: boolean isProtected = Modifier.isProtected(modifiers);
38: boolean isPackage = !Modifier.isPrivate(modifiers)
39: && !isProtected && !isPublic;
40: boolean isSerializable = Serializable.class
41: .isAssignableFrom(cls);
42:
43: if (isPublic || isProtected || (isPackage && isSerializable))
44: return false;
45: return true;
46: }
47:
48: protected void checkCompliance(String className) throws Exception {
49: ClassLoader jmxriLoader = createRemoteJMXRIWithTestsClassLoader();
50: ClassLoader mx4jLoader = createRemoteMX4JWithTestsClassLoader();
51:
52: SignatureVerifier verifier = new SignatureVerifier();
53:
54: try {
55: verifier
56: .verifySignature(className, jmxriLoader, mx4jLoader);
57: } catch (NotCompliantException x) {
58: fail(x.getMessage());
59: } catch (NotCompliantWarningException x) {
60: System.out.println("WARNING: " + x.getMessage());
61: }
62: }
63: }
|