Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/sun/management/jmxremote/bootstrap/RmiRegistrySslTest.java
38867 views
/*1* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223import java.rmi.registry.LocateRegistry;24import java.rmi.registry.Registry;25import javax.rmi.ssl.SslRMIClientSocketFactory;2627public class RmiRegistrySslTest {2829static final String ok = "OK: Found jmxrmi entry in RMIRegistry!";30static final String ko = "KO: Did not find jmxrmi entry in RMIRegistry!";31static final String ko2 = "KO: Did not get expected exception!";32static final String okException = "OK: Got expected exception!";33static final String koException = "KO: Got unexpected exception!";3435public static void main(String args[]) throws Exception {3637System.out.println("RmiRegistry lookup...");3839String testID = System.getProperty("testID");4041if ("Test1".equals(testID)) {42try {43Registry registry = LocateRegistry.getRegistry(4444);44String[] list = registry.list();45if ("jmxrmi".equals(list[0])) {46System.out.println(ok);47} else {48System.out.println(ko);49throw new IllegalArgumentException(ko);50}51} catch (Exception e) {52System.out.println(koException);53e.printStackTrace(System.out);54throw e;55}56}5758if ("Test2".equals(testID)) {59try {60Registry registry = LocateRegistry.getRegistry(4444);61String[] list = registry.list();62throw new IllegalArgumentException(ko2);63} catch (Exception e) {64System.out.println(okException);65e.printStackTrace(System.out);66return;67}68}6970if ("Test3".equals(testID)) {71try {72Registry registry = LocateRegistry.getRegistry(73null, 4444, new SslRMIClientSocketFactory());74String[] list = registry.list();75if ("jmxrmi".equals(list[0])) {76System.out.println(ok);77} else {78System.out.println(ko);79throw new IllegalArgumentException(ko);80}81} catch (Exception e) {82System.out.println(koException);83e.printStackTrace(System.out);84throw e;85}86}87}88}899091