use of java.rmi.registry.Registry in project geode by apache.
the class DUnitLauncher method launch.
private static void launch() throws URISyntaxException, AlreadyBoundException, IOException, InterruptedException, NotBoundException {
DUNIT_SUSPECT_FILE = new File(SUSPECT_FILENAME);
DUNIT_SUSPECT_FILE.delete();
DUNIT_SUSPECT_FILE.deleteOnExit();
// create an RMI registry and add an object to share our tests config
int namingPort = AvailablePortHelper.getRandomAvailableTCPPort();
Registry registry = LocateRegistry.createRegistry(namingPort);
System.setProperty(RMI_PORT_PARAM, "" + namingPort);
JUnit4DistributedTestCase.initializeBlackboard();
final ProcessManager processManager = new ProcessManager(namingPort, registry);
master = new Master(registry, processManager);
registry.bind(MASTER_PARAM, master);
// inhibit banners to make logs smaller
System.setProperty(InternalLocator.INHIBIT_DM_BANNER, "true");
// restrict membership ports to be outside of AvailablePort's range
System.setProperty(DistributionConfig.RESTRICT_MEMBERSHIP_PORT_RANGE, "true");
Runtime.getRuntime().addShutdownHook(new Thread() {
public void run() {
// System.out.println("shutting down DUnit JVMs");
// for (int i=0; i<NUM_VMS; i++) {
// try {
// processManager.getStub(i).shutDownVM();
// } catch (Exception e) {
// System.out.println("exception shutting down vm_"+i+": " + e);
// }
// }
// // TODO - hasLiveVMs always returns true
// System.out.print("waiting for JVMs to exit");
// long giveUp = System.currentTimeMillis() + 5000;
// while (giveUp > System.currentTimeMillis()) {
// if (!processManager.hasLiveVMs()) {
// return;
// }
// System.out.print(".");
// System.out.flush();
// try {
// Thread.sleep(1000);
// } catch (InterruptedException e) {
// break;
// }
// }
// System.out.println("\nkilling any remaining JVMs");
processManager.killVMs();
}
});
// Create a VM for the locator
processManager.launchVM(LOCATOR_VM_NUM);
// wait for the VM to start up
if (!processManager.waitForVMs(STARTUP_TIMEOUT)) {
throw new RuntimeException(STARTUP_TIMEOUT_MESSAGE);
}
locatorPort = startLocator(registry);
init(master);
// Launch an initial set of VMs
for (int i = 0; i < NUM_VMS; i++) {
processManager.launchVM(i);
}
// wait for the VMS to start up
if (!processManager.waitForVMs(STARTUP_TIMEOUT)) {
throw new RuntimeException(STARTUP_TIMEOUT_MESSAGE);
}
// populate the Host class with our stubs. The tests use this host class
DUnitHost host = new DUnitHost(InetAddress.getLocalHost().getCanonicalHostName(), processManager);
host.init(registry, NUM_VMS);
}
use of java.rmi.registry.Registry in project jdk8u_jdk by JetBrains.
the class EmptyName method main.
public static void main(String[] args) throws Exception {
Registry impl = TestLibrary.createRegistryOnUnusedPort();
Registry stub = (Registry) RemoteObject.toStub(impl);
stub.bind("", stub);
stub.lookup("");
stub.rebind("", stub);
stub.lookup("");
stub.unbind("");
}
use of java.rmi.registry.Registry in project jdk8u_jdk by JetBrains.
the class InterfaceHash method main.
public static void main(String[] args) throws Exception {
System.err.println("\nRegression test for bug 4472769");
System.err.println("\n=== verifying that J2SE registry's skeleton uses" + "\ncorrect interface hash and operation numbers:");
Registry testImpl = LocateRegistry.createRegistry(PORT);
System.err.println("created test registry on port " + PORT);
RemoteRef ref = new UnicastRef(new LiveRef(new ObjID(ObjID.REGISTRY_ID), new TCPEndpoint("", PORT), false));
Registry referenceStub = new ReferenceRegistryStub(ref);
System.err.println("created reference registry stub: " + referenceStub);
referenceStub.bind(NAME, referenceStub);
System.err.println("bound name \"" + NAME + "\" in registry");
String[] list = referenceStub.list();
System.err.println("list of registry contents: " + Arrays.asList(list));
if (list.length != 1 || !list[0].equals(NAME)) {
throw new RuntimeException("TEST FAILED: unexpected list contents");
}
Registry result = (Registry) referenceStub.lookup(NAME);
System.err.println("lookup of name \"" + NAME + "\" returned: " + result);
if (!result.equals(referenceStub)) {
throw new RuntimeException("TEST FAILED: unexpected lookup result");
}
referenceStub.rebind(NAME, referenceStub);
referenceStub.unbind(NAME);
System.err.println("unbound name \"" + NAME + "\"");
list = referenceStub.list();
System.err.println("list of registry contents: " + Arrays.asList(list));
if (list.length != 0) {
throw new RuntimeException("TEST FAILED: list not empty");
}
System.err.println("\n=== verifying that J2SE registry's stub uses" + "correct interface hash:");
class FakeRemoteRef implements RemoteRef {
long hash;
int opnum;
public RemoteCall newCall(RemoteObject obj, Operation[] op, int opnum, long hash) {
this.hash = hash;
this.opnum = opnum;
throw new UnsupportedOperationException();
}
public void invoke(RemoteCall call) {
}
public void done(RemoteCall call) {
}
public Object invoke(Remote obj, Method method, Object[] args, long hash) {
throw new UnsupportedOperationException();
}
public String getRefClass(java.io.ObjectOutput out) {
return "FakeRemoteRef";
}
public int remoteHashCode() {
return 1013;
}
public boolean remoteEquals(RemoteRef obj) {
return false;
}
public String remoteToString() {
return "FakeRemoteRef";
}
public void writeExternal(java.io.ObjectOutput out) {
}
public void readExternal(java.io.ObjectInput in) {
}
}
FakeRemoteRef f = new FakeRemoteRef();
Registry testRegistry = LocateRegistry.getRegistry(PORT);
System.err.println("created original test registry stub: " + testRegistry);
Class stubClass = testRegistry.getClass();
System.err.println("test registry stub class: " + stubClass);
Constructor cons = stubClass.getConstructor(new Class[] { RemoteRef.class });
Registry testStub = (Registry) cons.newInstance(new Object[] { f });
System.err.println("created new instrumented test registry stub: " + testStub);
System.err.println("invoking bind:");
try {
testStub.bind(NAME, referenceStub);
} catch (UnsupportedOperationException e) {
}
System.err.println("hash == " + f.hash + ", opnum == " + f.opnum);
if (f.hash != 4905912898345647071L) {
throw new RuntimeException("TEST FAILED: wrong interface hash");
} else if (f.opnum != 0) {
throw new RuntimeException("TEST FAILED: wrong operation number");
}
System.err.println("invoking list:");
try {
testStub.list();
} catch (UnsupportedOperationException e) {
}
System.err.println("hash == " + f.hash + ", opnum == " + f.opnum);
if (f.hash != 4905912898345647071L) {
throw new RuntimeException("TEST FAILED: wrong interface hash");
} else if (f.opnum != 1) {
throw new RuntimeException("TEST FAILED: wrong operation number");
}
System.err.println("invoking lookup:");
try {
testStub.lookup(NAME);
} catch (UnsupportedOperationException e) {
}
System.err.println("hash == " + f.hash + ", opnum == " + f.opnum);
if (f.hash != 4905912898345647071L) {
throw new RuntimeException("TEST FAILED: wrong interface hash");
} else if (f.opnum != 2) {
throw new RuntimeException("TEST FAILED: wrong operation number");
}
System.err.println("invoking rebind:");
try {
testStub.rebind(NAME, referenceStub);
} catch (UnsupportedOperationException e) {
}
System.err.println("hash == " + f.hash + ", opnum == " + f.opnum);
if (f.hash != 4905912898345647071L) {
throw new RuntimeException("TEST FAILED: wrong interface hash");
} else if (f.opnum != 3) {
throw new RuntimeException("TEST FAILED: wrong operation number");
}
System.err.println("invoking unbind:");
try {
testStub.unbind(NAME);
} catch (UnsupportedOperationException e) {
}
System.err.println("hash == " + f.hash + ", opnum == " + f.opnum);
if (f.hash != 4905912898345647071L) {
throw new RuntimeException("TEST FAILED: wrong interface hash");
} else if (f.opnum != 4) {
throw new RuntimeException("TEST FAILED: wrong operation number");
}
System.err.println("TEST PASSED");
}
use of java.rmi.registry.Registry in project jdk8u_jdk by JetBrains.
the class InheritedChannelNotServerSocket method main.
public static void main(String[] args) throws Exception {
System.err.println("\nRegression test for bug 6261402\n");
System.setProperty("java.rmi.activation.port", Integer.toString(TestLibrary.INHERITEDCHANNELNOTSERVERSOCKET_ACTIVATION_PORT));
RMID rmid = null;
Callback obj = null;
try {
/*
* Export callback object and bind in registry.
*/
System.err.println("export callback object and bind in registry");
obj = new CallbackImpl();
Callback proxy = (Callback) UnicastRemoteObject.exportObject(obj, 0);
Registry registry = LocateRegistry.createRegistry(TestLibrary.INHERITEDCHANNELNOTSERVERSOCKET_REGISTRY_PORT);
registry.bind("Callback", proxy);
/*
* Start rmid.
*/
System.err.println("start rmid with inherited channel");
RMID.removeLog();
rmid = RMID.createRMID(System.out, System.err, true, true, TestLibrary.INHERITEDCHANNELNOTSERVERSOCKET_ACTIVATION_PORT);
rmid.addOptions(new String[] { "-Djava.nio.channels.spi.SelectorProvider=" + "InheritedChannelNotServerSocket$SP" });
rmid.start();
/*
* Get activation system and wait to be notified via callback
* from rmid's selector provider.
*/
System.err.println("get activation system");
ActivationSystem system = ActivationGroup.getSystem();
System.err.println("ActivationSystem = " + system);
synchronized (lock) {
while (!notified) {
lock.wait();
}
}
System.err.println("TEST PASSED");
} finally {
if (obj != null) {
UnicastRemoteObject.unexportObject(obj, true);
}
ActivationLibrary.rmidCleanup(rmid);
}
}
use of java.rmi.registry.Registry in project jdk8u_jdk by JetBrains.
the class Callback method main.
public static void main(String[] args) throws Exception {
System.setProperty("java.rmi.activation.port", Integer.toString(TestLibrary.RMIDVIAINHERITEDCHANNEL_ACTIVATION_PORT));
RMID rmid = null;
Callback obj = null;
try {
/*
* Export callback object and bind in registry.
*/
System.err.println("export callback object and bind in registry");
obj = new RmidViaInheritedChannel();
Callback proxy = (Callback) UnicastRemoteObject.exportObject(obj, 0);
Registry registry = LocateRegistry.createRegistry(TestLibrary.RMIDVIAINHERITEDCHANNEL_REGISTRY_PORT);
registry.bind("Callback", proxy);
/*
* Start rmid.
*/
System.err.println("start rmid with inherited channel");
RMID.removeLog();
rmid = RMID.createRMID(System.out, System.err, true, false, TestLibrary.RMIDVIAINHERITEDCHANNEL_ACTIVATION_PORT);
rmid.addOptions(new String[] { "-Djava.nio.channels.spi.SelectorProvider=RmidViaInheritedChannel$RmidSelectorProvider" });
if (System.getProperty("os.name").startsWith("Windows") && System.getProperty("os.version").startsWith("5.")) {
/* Windows XP/2003 or older
* Need to expand ephemeral range to include RMI test ports
*/
rmid.addOptions(new String[] { "-Djdk.net.ephemeralPortRange.low=1024", "-Djdk.net.ephemeralPortRange.high=64000" });
}
rmid.start();
/*
* Get activation system and wait to be notified via callback
* from rmid's selector provider.
*/
System.err.println("get activation system");
ActivationSystem system = ActivationGroup.getSystem();
System.err.println("ActivationSystem = " + system);
synchronized (lock) {
while (!notified) {
lock.wait();
}
}
System.err.println("TEST PASSED");
} finally {
if (obj != null) {
UnicastRemoteObject.unexportObject(obj, true);
}
ActivationLibrary.rmidCleanup(rmid);
}
}
Aggregations