mirror of
https://github.com/openjdk/jdk.git
synced 2026-02-10 10:28:37 +00:00
8171076: improve rmi tests by replacing TestLibrary.createRegistryOnUnusedPort, getUnusedRandomPort
Reviewed-by: rriggs
This commit is contained in:
parent
af3e320415
commit
213a2bc257
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2001, 2016, 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
|
||||
@ -45,7 +45,7 @@ public class LookupNameWithColon {
|
||||
"multiple:colons:in:name"
|
||||
};
|
||||
|
||||
Registry reg = TestLibrary.createRegistryOnUnusedPort();
|
||||
Registry reg = TestLibrary.createRegistryOnEphemeralPort();
|
||||
int port = TestLibrary.getRegistryPort(reg);
|
||||
|
||||
for (int i = 0; i < names.length; i++) {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2002, 2016, 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
|
||||
@ -49,7 +49,7 @@ public class RmiIsNoScheme implements Remote, Serializable {
|
||||
System.err.println("\nRegression test for bug 4626311\n");
|
||||
|
||||
try {
|
||||
Registry registry = TestLibrary.createRegistryOnUnusedPort();
|
||||
Registry registry = TestLibrary.createRegistryOnEphemeralPort();
|
||||
int registryPort = TestLibrary.getRegistryPort(registry);
|
||||
Naming.rebind("//:" + registryPort + "/RmiIsNoScheme",
|
||||
new RmiIsNoScheme());
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2005, 2016, 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
|
||||
@ -80,7 +80,7 @@ public class UnderscoreHost extends UnicastRemoteObject implements Remote {
|
||||
try {
|
||||
HostVerifyingSocketFactory hvf = new HostVerifyingSocketFactory();
|
||||
RMISocketFactory.setSocketFactory(hvf);
|
||||
Registry r = TestLibrary.createRegistryOnUnusedPort();
|
||||
Registry r = TestLibrary.createRegistryOnEphemeralPort();
|
||||
int port = TestLibrary.getRegistryPort(r);
|
||||
t = new UnderscoreHost();
|
||||
r.rebind(NAME, t);
|
||||
|
||||
@ -85,7 +85,7 @@ public class StubClassesPermitted
|
||||
try {
|
||||
TestLibrary.suggestSecurityManager("java.lang.SecurityManager");
|
||||
|
||||
registry = TestLibrary.createRegistryOnUnusedPort();
|
||||
registry = TestLibrary.createRegistryOnEphemeralPort();
|
||||
registryPort = TestLibrary.getRegistryPort(registry);
|
||||
|
||||
// must run with java.lang.SecurityManager or the test
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2000, 2016, 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
|
||||
@ -38,7 +38,7 @@ import java.rmi.server.RemoteObject;
|
||||
|
||||
public class EmptyName {
|
||||
public static void main(String[] args) throws Exception {
|
||||
Registry impl = TestLibrary.createRegistryOnUnusedPort();
|
||||
Registry impl = TestLibrary.createRegistryOnEphemeralPort();
|
||||
Registry stub = (Registry) RemoteObject.toStub(impl);
|
||||
stub.bind("", stub);
|
||||
stub.lookup("");
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 2016, 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
|
||||
@ -313,7 +313,7 @@ public class AppleUserImpl extends UnicastRemoteObject implements AppleUser {
|
||||
|
||||
synchronized (user) {
|
||||
// create new registry and bind new AppleUserImpl in registry
|
||||
Registry registry = TestLibrary.createRegistryOnUnusedPort();
|
||||
Registry registry = TestLibrary.createRegistryOnEphemeralPort();
|
||||
registryPort = TestLibrary.getRegistryPort(registry);
|
||||
LocateRegistry.getRegistry(registryPort).rebind("AppleUser",
|
||||
user);
|
||||
|
||||
@ -43,7 +43,7 @@ import java.rmi.*;
|
||||
import java.rmi.registry.*;
|
||||
|
||||
public class UseCustomSocketFactory {
|
||||
static final int REGISTRY_PORT = TestLibrary.getUnusedRandomPort();
|
||||
static int registryPort = -1;
|
||||
|
||||
static String[] protocol = new String[] { "", "compress", "xor" };
|
||||
|
||||
@ -54,7 +54,8 @@ public class UseCustomSocketFactory {
|
||||
TestLibrary.suggestSecurityManager("java.rmi.RMISecurityManager");
|
||||
|
||||
try {
|
||||
LocateRegistry.createRegistry(REGISTRY_PORT);
|
||||
Registry reg = LocateRegistry.createRegistry(0);
|
||||
registryPort = TestLibrary.getRegistryPort(reg);
|
||||
} catch (RemoteException e) {
|
||||
TestLibrary.bomb("creating registry", e);
|
||||
}
|
||||
@ -90,7 +91,7 @@ public class UseCustomSocketFactory {
|
||||
"-Djava.security.policy=" +
|
||||
TestParams.defaultPolicy +
|
||||
" -Drmi.registry.port=" +
|
||||
REGISTRY_PORT +
|
||||
registryPort +
|
||||
" -Djava.rmi.activation.port=" +
|
||||
rmidPort,
|
||||
protocol[i]);
|
||||
@ -108,7 +109,7 @@ public class UseCustomSocketFactory {
|
||||
long stopTime = System.currentTimeMillis() + 24000;
|
||||
do {
|
||||
try {
|
||||
echo[i] = (Echo) Naming.lookup("//:" + REGISTRY_PORT +
|
||||
echo[i] = (Echo) Naming.lookup("//:" + registryPort +
|
||||
"/EchoServer");
|
||||
break;
|
||||
} catch (NotBoundException e) {
|
||||
@ -138,7 +139,7 @@ public class UseCustomSocketFactory {
|
||||
} finally {
|
||||
serverVM.destroy();
|
||||
try {
|
||||
Naming.unbind("//:" + REGISTRY_PORT + "/EchoServer");
|
||||
Naming.unbind("//:" + registryPort + "/EchoServer");
|
||||
} catch (RemoteException | NotBoundException | MalformedURLException e) {
|
||||
TestLibrary.bomb("unbinding EchoServer", e);
|
||||
}
|
||||
|
||||
@ -20,6 +20,13 @@ grant {
|
||||
permission java.util.PropertyPermission "java.security.policy", "read";
|
||||
permission java.util.PropertyPermission "java.security.manager", "read";
|
||||
|
||||
// used by TestLibrary to get the RMI Registry port
|
||||
permission java.lang.RuntimePermission "accessClassInPackage.sun.rmi.registry";
|
||||
permission java.lang.RuntimePermission "accessClassInPackage.sun.rmi.server";
|
||||
permission java.lang.RuntimePermission "accessClassInPackage.sun.rmi.transport";
|
||||
permission java.lang.RuntimePermission "accessClassInPackage.sun.rmi.transport.proxy";
|
||||
permission java.lang.RuntimePermission "accessClassInPackage.sun.rmi.transport.tcp";
|
||||
|
||||
// used by TestLibrary to determine test environment
|
||||
permission java.util.PropertyPermission "test.*", "read";
|
||||
permission java.util.PropertyPermission "user.dir", "read";
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1998, 2016, 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
|
||||
@ -58,7 +58,7 @@ public class UseCustomSocketFactory {
|
||||
System.out.println("\nRegression test for bug 4148850\n");
|
||||
|
||||
TestLibrary.suggestSecurityManager("java.rmi.RMISecurityManager");
|
||||
int registryPort = TestLibrary.getUnusedRandomPort();
|
||||
int registryPort = -1;
|
||||
|
||||
try {
|
||||
impl = new HelloImpl();
|
||||
@ -68,9 +68,10 @@ public class UseCustomSocketFactory {
|
||||
* allow the rmiregistry to be secure.
|
||||
*/
|
||||
registry = LocateRegistry.
|
||||
createRegistry(registryPort,
|
||||
createRegistry(0,
|
||||
new Compress.CompressRMIClientSocketFactory(),
|
||||
new Compress.CompressRMIServerSocketFactory());
|
||||
registryPort = TestLibrary.getRegistryPort(registry);
|
||||
registry.rebind("/HelloServer", impl);
|
||||
checkStub(registry, "RMIServerSocket");
|
||||
|
||||
|
||||
@ -22,6 +22,13 @@ grant {
|
||||
permission java.util.PropertyPermission "java.security.policy", "read";
|
||||
permission java.util.PropertyPermission "java.security.manager", "read";
|
||||
|
||||
// used by TestLibrary to get the RMI Registry port
|
||||
permission java.lang.RuntimePermission "accessClassInPackage.sun.rmi.registry";
|
||||
permission java.lang.RuntimePermission "accessClassInPackage.sun.rmi.server";
|
||||
permission java.lang.RuntimePermission "accessClassInPackage.sun.rmi.transport";
|
||||
permission java.lang.RuntimePermission "accessClassInPackage.sun.rmi.transport.proxy";
|
||||
permission java.lang.RuntimePermission "accessClassInPackage.sun.rmi.transport.tcp";
|
||||
|
||||
// test needs to export rmid and communicate with objects on arbitrary ports
|
||||
permission java.net.SocketPermission "*:1024-", "connect,accept,listen";
|
||||
};
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1998, 2016, 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
|
||||
@ -55,7 +55,7 @@ public class UseCustomSocketFactory {
|
||||
TestLibrary.suggestSecurityManager("java.rmi.RMISecurityManager");
|
||||
|
||||
try {
|
||||
Registry registry = TestLibrary.createRegistryOnUnusedPort();
|
||||
Registry registry = TestLibrary.createRegistryOnEphemeralPort();
|
||||
registryPort = TestLibrary.getRegistryPort(registry);
|
||||
} catch (RemoteException e) {
|
||||
TestLibrary.bomb("creating registry", e);
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2001, 2016, 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
|
||||
@ -80,7 +80,7 @@ public class KeepAliveDuringCall implements ShutdownMonitor {
|
||||
UnicastRemoteObject.exportObject(obj);
|
||||
System.err.println("exported shutdown monitor");
|
||||
|
||||
Registry localRegistry = TestLibrary.createRegistryOnUnusedPort();
|
||||
Registry localRegistry = TestLibrary.createRegistryOnEphemeralPort();
|
||||
int registryPort = TestLibrary.getRegistryPort(localRegistry);
|
||||
System.err.println("created local registry");
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2000, 2016, 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
|
||||
@ -49,7 +49,7 @@ public class UnexportLeak implements Ping {
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
System.err.println("\nRegression test for bug 4331349\n");
|
||||
Registry registry = TestLibrary.createRegistryOnUnusedPort();
|
||||
Registry registry = TestLibrary.createRegistryOnEphemeralPort();
|
||||
int registryPort = TestLibrary.getRegistryPort(registry);
|
||||
Remote obj = new UnexportLeak();
|
||||
WeakReference wr = new WeakReference(obj);
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1998, 2016, 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
|
||||
@ -81,7 +81,7 @@ public class FiniteGCLatency implements Remote, Unreferenced {
|
||||
try {
|
||||
UnicastRemoteObject.exportObject(obj);
|
||||
System.err.println("exported remote object");
|
||||
Registry registry1 = TestLibrary.createRegistryOnUnusedPort();
|
||||
Registry registry1 = TestLibrary.createRegistryOnEphemeralPort();
|
||||
int port = TestLibrary.getRegistryPort(registry1);
|
||||
System.err.println("created registry");
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1998, 2016, 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
|
||||
@ -122,7 +122,7 @@ public class UnreferencedContext implements Remote, Unreferenced, Runnable {
|
||||
UnicastRemoteObject.exportObject(obj);
|
||||
System.err.println("exported remote object");
|
||||
|
||||
Registry registry1 = TestLibrary.createRegistryOnUnusedPort();
|
||||
Registry registry1 = TestLibrary.createRegistryOnEphemeralPort();
|
||||
int port = TestLibrary.getRegistryPort(registry1);
|
||||
System.err.println("created registry");
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1998, 2016, 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
|
||||
@ -81,7 +81,7 @@ public class CheckFQDN extends UnicastRemoteObject
|
||||
System.err.println
|
||||
("\nRegression test for bug/rfe 4115683\n");
|
||||
|
||||
Registry registry = TestLibrary.createRegistryOnUnusedPort();
|
||||
Registry registry = TestLibrary.createRegistryOnEphemeralPort();
|
||||
REGISTRY_PORT = TestLibrary.getRegistryPort(registry);
|
||||
registry.bind("CheckFQDN", checkFQDN);
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1998, 2016, 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
|
||||
@ -30,6 +30,7 @@
|
||||
* @library ../../testlibrary
|
||||
* @modules java.rmi/sun.rmi.registry
|
||||
* java.rmi/sun.rmi.server
|
||||
* java.rmi/sun.rmi.transport:open
|
||||
* java.rmi/sun.rmi.transport
|
||||
* java.rmi/sun.rmi.transport.tcp
|
||||
* @build TestLibrary CheckLeaseLeak_Stub LeaseLeakClient LeaseLeak
|
||||
@ -90,7 +91,7 @@ public class CheckLeaseLeak extends UnicastRemoteObject implements LeaseLeak {
|
||||
|
||||
try {
|
||||
Registry registry =
|
||||
TestLibrary.createRegistryOnUnusedPort();
|
||||
TestLibrary.createRegistryOnEphemeralPort();
|
||||
int registryPort = TestLibrary.getRegistryPort(registry);
|
||||
|
||||
leakServer = new CheckLeaseLeak();
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2005, 2016, 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
|
||||
@ -44,7 +44,6 @@ import java.rmi.Remote;
|
||||
import java.rmi.server.UnicastRemoteObject;
|
||||
|
||||
public class RapidExportUnexport {
|
||||
private static final int PORT = TestLibrary.getUnusedRandomPort();
|
||||
private static final int REPS = 100;
|
||||
private static final long TIMEOUT = 60000;
|
||||
|
||||
@ -55,7 +54,7 @@ public class RapidExportUnexport {
|
||||
long start = System.currentTimeMillis();
|
||||
for (int i = 0; i < REPS; i++) {
|
||||
System.err.println(i);
|
||||
UnicastRemoteObject.exportObject(impl, PORT);
|
||||
UnicastRemoteObject.exportObject(impl, 0);
|
||||
UnicastRemoteObject.unexportObject(impl, true);
|
||||
Thread.sleep(1); // work around BindException (bug?)
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 2016, 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
|
||||
@ -253,7 +253,7 @@ public class AppleUserImpl
|
||||
int port = -1;
|
||||
// create new registry and bind new AppleUserImpl in registry
|
||||
try {
|
||||
Registry registry = TestLibrary.createRegistryOnUnusedPort();
|
||||
Registry registry = TestLibrary.createRegistryOnEphemeralPort();
|
||||
port = TestLibrary.getRegistryPort(registry);
|
||||
Naming.rebind("rmi://localhost:" + port + "/AppleUser",user);
|
||||
} catch (RemoteException e) {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2001, 2016, 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
|
||||
@ -103,7 +103,7 @@ public class CheckLogging {
|
||||
private static Registry registry;
|
||||
static {
|
||||
try {
|
||||
registry = TestLibrary.createRegistryOnUnusedPort();
|
||||
registry = TestLibrary.createRegistryOnEphemeralPort();
|
||||
REGISTRY_PORT = TestLibrary.getRegistryPort(registry);
|
||||
LOCATION = "rmi://localhost:" + REGISTRY_PORT + "/";
|
||||
} catch (Exception e) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user