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.OptionalRemoteJMXComplianceTestCase;
18:
19: /**
20: * @version $Revision: 1.5 $
21: */
22: public class OptionalRemoteJMXSignatureTest extends
23: OptionalRemoteJMXComplianceTestCase {
24: public OptionalRemoteJMXSignatureTest(String s) {
25: super (s);
26: }
27:
28: protected boolean skipClassName(String className) {
29: // For now the optional JSR 160 part is not implemented
30: return true;
31: }
32:
33: protected boolean skipClass(Class cls) {
34: // Exclude implementation classes in javax.management.remote optional subpackages
35:
36: int modifiers = cls.getModifiers();
37: boolean isPublic = Modifier.isPublic(modifiers);
38: boolean isProtected = Modifier.isProtected(modifiers);
39: boolean isPackage = !Modifier.isPrivate(modifiers)
40: && !isProtected && !isPublic;
41: boolean isSerializable = Serializable.class
42: .isAssignableFrom(cls);
43:
44: if (isPublic || isProtected || (isPackage && isSerializable))
45: return false;
46: return true;
47: }
48:
49: protected void checkCompliance(String className) throws Exception {
50: ClassLoader jmxriLoader = createOptionalRemoteJMXRIWithTestsClassLoader();
51: ClassLoader mx4jLoader = createRemoteMX4JWithTestsClassLoader();
52:
53: SignatureVerifier verifier = new SignatureVerifier();
54:
55: try {
56: verifier
57: .verifySignature(className, jmxriLoader, mx4jLoader);
58: } catch (NotCompliantException x) {
59: fail(x.getMessage());
60: } catch (NotCompliantWarningException x) {
61: System.out.println("WARNING: " + x.getMessage());
62: }
63: }
64: }
|