test/java/rmi/registry/multipleRegistries/MultipleRegistries.java

Print this page

        

*** 1,7 **** /* ! * Copyright (c) 2003, 2008, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. --- 1,7 ---- /* ! * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation.
*** 24,33 **** --- 24,35 ---- /* @test * @bug 4267864 * @summary Can't run multiple registries in the same VM * @author Ann Wollrath * + * @library ../../testlibrary + * @build TestLibrary * @build MultipleRegistries * @run main/othervm/timeout=240 MultipleRegistries */ import java.rmi.Remote;
*** 56,71 **** (RemoteInterface) UnicastRemoteObject.exportObject(server, 0); System.err.println("proxy = " + proxy); System.err.println("export registries"); ! Registry registryImpl1 = LocateRegistry.createRegistry(2030); ! Registry registryImpl2 = LocateRegistry.createRegistry(2040); ! System.err.println("bind remote object in registries"); ! Registry registry1 = LocateRegistry.getRegistry(2030); ! Registry registry2 = LocateRegistry.getRegistry(2040); registry1.bind(NAME, proxy); registry2.bind(NAME, proxy); System.err.println("lookup remote object in registries"); --- 58,77 ---- (RemoteInterface) UnicastRemoteObject.exportObject(server, 0); System.err.println("proxy = " + proxy); System.err.println("export registries"); ! Registry registryImpl1 = TestLibrary.createRegistryOnUnusedPort(); ! int port1 = TestLibrary.getRegistryPort(registryImpl1); ! // Need to get a random port for the second registry as calling ! // TestLibrary.createRegistryOnUnusedPort in the same VM once a ! // registry has been created will fail. ! Registry registryImpl2 = TestLibrary.createRegistryOnUnusedPort(); ! int port2 = TestLibrary.getRegistryPort(registryImpl2); System.err.println("bind remote object in registries"); ! Registry registry1 = LocateRegistry.getRegistry(port1); ! Registry registry2 = LocateRegistry.getRegistry(port2); registry1.bind(NAME, proxy); registry2.bind(NAME, proxy); System.err.println("lookup remote object in registries");