4483N/A/*
5266N/A * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
4483N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4483N/A *
4483N/A * This code is free software; you can redistribute it and/or modify it
4483N/A * under the terms of the GNU General Public License version 2 only, as
4483N/A * published by the Free Software Foundation.
4483N/A *
4483N/A * This code is distributed in the hope that it will be useful, but WITHOUT
4483N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
4483N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
4483N/A * version 2 for more details (a copy is included in the LICENSE file that
4483N/A * accompanied this code).
4483N/A *
4483N/A * You should have received a copy of the GNU General Public License version
4483N/A * 2 along with this work; if not, write to the Free Software Foundation,
4483N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
4483N/A *
4483N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
4483N/A * or visit www.oracle.com if you need additional information or have any
4483N/A * questions.
4483N/A */
4483N/A
4483N/Aimport java.lang.ProcessBuilder;
4483N/Aimport java.rmi.registry.Registry;
4483N/Aimport java.rmi.registry.LocateRegistry;
4483N/Aimport java.rmi.RemoteException;
4483N/Aimport java.rmi.server.UnicastRemoteObject;
4483N/A
4483N/Apublic class readTest {
4483N/A
4483N/A public static void main(String args[]) throws Exception {
4483N/A try {
4483N/A testPkg.Server obj = new testPkg.Server();
4483N/A testPkg.Hello stub = (testPkg.Hello) UnicastRemoteObject.exportObject(obj, 0);
4483N/A // Bind the remote object's stub in the registry
5266N/A Registry registry =
5266N/A LocateRegistry.getRegistry(TestLibrary.READTEST_REGISTRY_PORT);
4483N/A registry.bind("Hello", stub);
4483N/A
4483N/A System.err.println("Server ready");
4483N/A
4483N/A // now, let's test client
5266N/A testPkg.Client client =
5266N/A new testPkg.Client(TestLibrary.READTEST_REGISTRY_PORT);
4483N/A String testStubReturn = client.testStub();
4483N/A if(!testStubReturn.equals(obj.hello)) {
4483N/A throw new RuntimeException("Test Fails : unexpected string from stub call");
4483N/A } else {
4483N/A System.out.println("Test passed");
4483N/A }
4483N/A registry.unbind("Hello");
4483N/A
4483N/A } catch (Exception e) {
4483N/A System.err.println("Server exception: " + e.toString());
4483N/A e.printStackTrace();
4483N/A }
4483N/A
4483N/A }
4483N/A}