1 /*
2 * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
73 * Verify that the subprocess had no System.out or System.err
74 * output.
75 */
76 String outString = out.toString();
77 String errString = err.toString();
78
79 System.err.println("-------- subprocess standard output: --------");
80 System.err.print(out);
81 System.err.println("-------- subprocess standard error: --------");
82 System.err.print(err);
83 System.err.println("---------------------------------------------");
84
85 if (outString.length() > 0 || errString.length() > 0) {
86 throw new Error("TEST FAILED: unexpected subprocess output");
87 }
88
89 System.err.println("TEST PASSED");
90 }
91
92 public static class DoRMIStuff {
93 private static final int PORT = 2020;
94 private interface Foo extends Remote {
95 Object echo(Object obj) throws RemoteException;
96 }
97 private static class FooImpl implements Foo {
98 FooImpl() { }
99 public Object echo(Object obj) { return obj; }
100 }
101 public static void main(String[] args) throws Exception {
102 LocateRegistry.createRegistry(PORT);
103 Registry reg = LocateRegistry.getRegistry("", PORT);
104 FooImpl fooimpl = new FooImpl();
105 UnicastRemoteObject.exportObject(fooimpl, 0);
106 reg.rebind("foo", fooimpl);
107 Foo foostub = (Foo) reg.lookup("foo");
108 FooImpl fooimpl2 = new FooImpl();
109 UnicastRemoteObject.exportObject(fooimpl2, 0);
110 foostub.echo(fooimpl2);
111 UnicastRemoteObject.unexportObject(fooimpl, true);
112 UnicastRemoteObject.unexportObject(fooimpl2, true);
113 }
114 }
115 }
|
1 /*
2 * Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
73 * Verify that the subprocess had no System.out or System.err
74 * output.
75 */
76 String outString = out.toString();
77 String errString = err.toString();
78
79 System.err.println("-------- subprocess standard output: --------");
80 System.err.print(out);
81 System.err.println("-------- subprocess standard error: --------");
82 System.err.print(err);
83 System.err.println("---------------------------------------------");
84
85 if (outString.length() > 0 || errString.length() > 0) {
86 throw new Error("TEST FAILED: unexpected subprocess output");
87 }
88
89 System.err.println("TEST PASSED");
90 }
91
92 public static class DoRMIStuff {
93 private interface Foo extends Remote {
94 Object echo(Object obj) throws RemoteException;
95 }
96 private static class FooImpl implements Foo {
97 FooImpl() { }
98 public Object echo(Object obj) { return obj; }
99 }
100 public static void main(String[] args) throws Exception {
101 Registry registry = TestLibrary.createRegistryOnUnusedPort();
102 int registryPort = TestLibrary.getRegistryPort(registry);
103 Registry reg = LocateRegistry.getRegistry("", registryPort);
104 FooImpl fooimpl = new FooImpl();
105 UnicastRemoteObject.exportObject(fooimpl, 0);
106 reg.rebind("foo", fooimpl);
107 Foo foostub = (Foo) reg.lookup("foo");
108 FooImpl fooimpl2 = new FooImpl();
109 UnicastRemoteObject.exportObject(fooimpl2, 0);
110 foostub.echo(fooimpl2);
111 UnicastRemoteObject.unexportObject(fooimpl, true);
112 UnicastRemoteObject.unexportObject(fooimpl2, true);
113 }
114 }
115 }
|