KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > javax > management > remote > compliance > signature > OptionalRemoteJMXSignatureTest


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.remote.compliance.signature;
10
11 import java.io.Serializable JavaDoc;
12 import java.lang.reflect.Modifier JavaDoc;
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 OptionalRemoteJMXComplianceTestCase
23 {
24    public OptionalRemoteJMXSignatureTest(String JavaDoc s)
25    {
26       super(s);
27    }
28
29    protected boolean skipClassName(String JavaDoc className)
30    {
31       // For now the optional JSR 160 part is not implemented
32
return true;
33    }
34
35    protected boolean skipClass(Class JavaDoc cls)
36    {
37       // Exclude implementation classes in javax.management.remote optional subpackages
38

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