0N/A/*
2362N/A * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
0N/A * published by the Free Software Foundation.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/A/*
0N/A * @test
0N/A * @bug 6231888
0N/A * @summary Test that all the JMX Remote API classes that define
0N/A * the method "void close() throws IOException;" extend
0N/A * or implement the java.io.Closeable interface.
0N/A * @author Luis-Miguel Alventosa
0N/A * @run clean CloseableTest
0N/A * @run build CloseableTest
0N/A * @run main CloseableTest
0N/A */
0N/A
0N/Aimport java.io.Closeable;
0N/Aimport javax.management.remote.JMXConnector;
0N/Aimport javax.management.remote.rmi.RMIConnection;
0N/Aimport javax.management.remote.rmi.RMIConnectionImpl;
0N/Aimport javax.management.remote.rmi.RMIConnectionImpl_Stub;
0N/Aimport javax.management.remote.rmi.RMIConnector;
0N/Aimport javax.management.remote.rmi.RMIIIOPServerImpl;
0N/Aimport javax.management.remote.rmi.RMIJRMPServerImpl;
0N/Aimport javax.management.remote.rmi.RMIServerImpl;
0N/Aimport org.omg.stub.javax.management.remote.rmi._RMIConnection_Stub;
0N/A
0N/Apublic class CloseableTest {
0N/A private static final Class closeArray[] = {
0N/A JMXConnector.class,
0N/A RMIConnector.class,
0N/A RMIConnection.class,
0N/A RMIConnectionImpl.class,
0N/A RMIConnectionImpl_Stub.class,
0N/A _RMIConnection_Stub.class,
0N/A RMIServerImpl.class,
0N/A RMIIIOPServerImpl.class,
0N/A RMIJRMPServerImpl.class
0N/A };
0N/A public static void main(String[] args) throws Exception {
0N/A System.out.println("Test that all the JMX Remote API classes that " +
0N/A "define\nthe method \"void close() throws " +
0N/A "IOException;\" extend\nor implement the " +
0N/A "java.io.Closeable interface.");
0N/A int error = 0;
0N/A for (Class c : closeArray) {
0N/A System.out.println("\nTest " + c);
0N/A if (Closeable.class.isAssignableFrom(c)) {
0N/A System.out.println("Test passed!");
0N/A } else {
0N/A error++;
0N/A System.out.println("Test failed!");
0N/A }
0N/A }
0N/A if (error > 0) {
0N/A final String msg = "\nTest FAILED! Got " + error + " error(s)";
0N/A System.out.println(msg);
0N/A throw new IllegalArgumentException(msg);
0N/A } else {
0N/A System.out.println("\nTest PASSED!");
0N/A }
0N/A }
0N/A}