J. Duke | 319a3b9 | 2007-12-01 00:00:00 +0000 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright 1999 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
| 20 | * CA 95054 USA or visit www.sun.com if you need additional information or |
| 21 | * have any questions. |
| 22 | */ |
| 23 | |
| 24 | /* @test |
| 25 | * @bug 4151966 |
| 26 | * @summary rmiregistry error message obsure; internationalize rmiregistry |
| 27 | * @author Laird Dornin |
| 28 | * |
| 29 | * @library ../../testlibrary |
| 30 | * @build TestLibrary JavaVM CheckUsage |
| 31 | * @run main/othervm CheckUsage |
| 32 | */ |
| 33 | |
| 34 | import java.io.ByteArrayOutputStream; |
| 35 | |
| 36 | /** |
| 37 | * Make sure that the rmiregistry prints out a correct usage statement |
| 38 | * when run with an incorrect command line; test written to conform to |
| 39 | * new tighter bug fix/regression test guidelines. |
| 40 | */ |
| 41 | public class CheckUsage { |
| 42 | public static void main(String[] args) { |
| 43 | |
| 44 | System.err.println("\nregression test for 4151966\n"); |
| 45 | |
| 46 | JavaVM registryVM = null; |
| 47 | |
| 48 | try { |
| 49 | // make sure the registry exits with a proper usage statement |
| 50 | ByteArrayOutputStream berr = new ByteArrayOutputStream(); |
| 51 | |
| 52 | // run a VM to start the registry |
| 53 | registryVM = new JavaVM("sun.rmi.registry.RegistryImpl", |
| 54 | "", "foo", |
| 55 | System.out, berr); |
| 56 | System.err.println("starting registry"); |
| 57 | registryVM.start(); |
| 58 | |
| 59 | // wait for registry exit |
| 60 | System.err.println(" registry exited with status: " + |
| 61 | registryVM.getVM().waitFor()); |
| 62 | try { |
| 63 | Thread.sleep(7000); |
| 64 | } catch (InterruptedException ie) { |
| 65 | } |
| 66 | |
| 67 | String usage = new String(berr.toByteArray()); |
| 68 | |
| 69 | System.err.println("rmiregistry usage: " + usage); |
| 70 | |
| 71 | if (usage.indexOf("-J") < 0) { |
| 72 | TestLibrary.bomb("rmiregistry has incorrect usage statement"); |
| 73 | } else { |
| 74 | System.err.println("test passed"); |
| 75 | } |
| 76 | } catch (Exception e) { |
| 77 | TestLibrary.bomb(e); |
| 78 | } finally { |
| 79 | registryVM.destroy(); |
| 80 | registryVM = null; |
| 81 | } |
| 82 | } |
| 83 | } |