Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/java/rmi/activation/Activatable/lookupActivationSystem/LookupActivationSystem.java
38829 views
/*1* Copyright (c) 2005, 2012, 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*/2223/*24* @test25* @bug 624573326* @summary synopsis: rmid's registry's list operation doesn't include27* activation system28* @author Ann Wollrath29*30* @library ../../../testlibrary31* @build TestLibrary RMID ActivationLibrary32* @run main/othervm/timeout=240 LookupActivationSystem33*/3435import java.rmi.*;36import java.rmi.activation.*;37import java.rmi.registry.*;38import java.rmi.server.*;39import java.io.Serializable;4041public class LookupActivationSystem implements Remote, Serializable {4243private static final String NAME = ActivationSystem.class.getName();4445public static void main(String[] args) throws Exception {4647System.out.println("\nRegression test for bug 6245733\n");4849RMID rmid = null;5051try {52RMID.removeLog();53rmid = RMID.createRMID();54rmid.start();5556System.err.println("look up activation system");57Registry rmidRegistry =58LocateRegistry.getRegistry(rmid.getPort());59ActivationSystem system = (ActivationSystem)60rmidRegistry.lookup(NAME);6162if (system instanceof ActivationSystem) {63System.err.println("test1 passed: lookup succeeded");64}6566System.err.println("get list of rmid internal registry");67String[] list = rmidRegistry.list();68if (list.length == 1 && list[0].equals(NAME)) {69System.err.println(70"test2 passed: activation system found in list");71} else {72throw new RuntimeException("test2 FAILED");73}7475try {76rmidRegistry.bind(NAME, new LookupActivationSystem());77throw new RuntimeException("test3 FAILED: bind succeeded!");78} catch (ServerException e) {79if (e.getCause() instanceof AccessException) {80System.err.println(81"test3 passed: binding ActivationSystem " +82"failed as expected");83} else {84throw new RuntimeException(85"test3 FAILED: incorrect cause: " + e.getCause());86}8788}8990try {91rmidRegistry.rebind(NAME, new LookupActivationSystem());92throw new RuntimeException("test4 FAILED: rebind succeeded!");93} catch (ServerException e) {94if (e.getCause() instanceof AccessException) {95System.err.println(96"test4 passed: rebinding ActivationSystem " +97"failed as expected");98} else {99throw new RuntimeException(100"test4 FAILED: incorrect cause: " + e.getCause());101}102}103104try {105rmidRegistry.unbind(NAME);106throw new RuntimeException("test4 FAILED: unbind succeeded!");107} catch (ServerException e) {108if (e.getCause() instanceof AccessException) {109System.err.println(110"test5 passed: unbinding ActivationSystem " +111"failed as expected");112} else {113throw new RuntimeException(114"test5 FAILED: incorrect cause: " + e.getCause());115}116}117118119} finally {120ActivationLibrary.rmidCleanup(rmid);121}122}123}124125126