5266N/A * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 0N/A * published by the Free Software Foundation. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2362N/A * or visit www.oracle.com if you need additional information or have any 0N/A * @summary cannot set java.rmi.server.hostname on children of rmid in time 0N/A * @summary activation group should not overwrite system properties 0N/A * @summary activation groups should be able to control their JVM properties 0N/A * @author Adrian Colley 0N/A * @library ../../testlibrary 5551N/A * @build TestLibrary RMID ActivationLibrary 5551N/A * Eliza Retireable Doctor Doctor_Stub 5551N/A * -Djava.compiler=NONE SetChildEnv 0N/A // don't embed spaces in any of the test args/props, because 0N/A // they won't be parsed properly 5266N/A "sun.rmi.server.doSomething=true" },
0N/A // make a "watcher" which listens on a pipe and searches for 0N/A // the debugExec line while teeing to System.err 5266N/A true,
// debugExec turned on 0N/A //p.put("java.rmi.server.logCalls", "true"); 0N/A // create CommandEnvironment and ActivationGroupDesc 0N/A // create ActivationDesc 0N/A // register activatable object 0N/A // invoke a call with oh-so-humorous sample text 0N/A "HELP ME, DOCTOR. I FEEL VIOLENT TOWARDS PEOPLE " +
0N/A "WHO INQUIRE ABOUT MY PARENTS.";
0N/A //Runtime.getRuntime().traceMethodCalls(true); 0N/A //Runtime.getRuntime().traceMethodCalls(false); 0N/A // Get debugExec line, allowing 15 seconds for it to flush 0N/A // through the buffers and pipes. 0N/A "recognizable debugExec line");
0N/A // q: first double-quote after debugExec 0N/A // qe: last double-quote on debugExec line 0N/A "mangled debugExec line");
0N/A // split args by whitespace 0N/A // Now check off the requested args. Order isn't important, and 0N/A // any extra args are ignored, even if they're inconsistent or 0N/A // bargage, or duplicates. 0N/A super(
"DebugExecWatcher");
5266N/A /* During termination of distant rmid, StreamPipes will be broken when 5266N/A * distant vm terminates. A "Pipe broken" exception is expected because 5266N/A * DebugExecWatcher points to the same streams as StreamPipes used by RMID. 5266N/A * If we get this exception. We just terminate the thread. 0N/A // activation should have proceeded by writing a wrapper.out 0N/A // Read and check wrapper.out 0N/A BufferedReader r = new BufferedReader(new FileReader(wrapout)); 0N/A String[] realArgs = null; 0N/A while ( (line = r.readLine()) != null) { 0N/A StringTokenizer tkz = new StringTokenizer(line); 0N/A if (!tkz.nextToken().equals("actgrpwrapper")) { 0N/A // could throw an exception, but let's benignly 0N/A // assume that something unrelated is spewing. 0N/A String x; // writer's block 0N/A x = tkz.nextToken(); 0N/A if (x.equals("argc")) { 0N/A if (realArgs != null) { 0N/A throw new RuntimeException( 0N/A "SetChildEnv: two argc lines in wrapper.out"); 0N/A realArgs = new String[Integer.parseInt(tkz.nextToken())]; 0N/A } else if (x.equals("argv")) { 0N/A if (realArgs == null) 0N/A throw new RuntimeException("SetChildEnv: missing argc"); 0N/A int n = Integer.parseInt(tkz.nextToken()); 0N/A if (n < 1 || n > realArgs.length) { 0N/A throw new RuntimeException("SetChildEnv: argc=" + 0N/A realArgs.length + "; argv[" + n + "]"); 0N/A // Hack: manually skip the "actgrpwrapper argv 5 " 0N/A String remainder = line.substring( 0N/A 1 + line.indexOf(' ', 0N/A 1 + line.indexOf(' ', 0N/A 1 + line.indexOf(' ')))); 0N/A realArgs[n-1] = remainder; 0N/A throw new RuntimeException("SetChildEnv: bad token \"" + x + "\""); 0N/A private static void ensureLocalExecutable(String fname) 0N/A File target = new File(fname); 0N/A File source = new File(Dot, fname); 0N/A if (!target.exists()) { 0N/A System.err.println("Copying " + source.getPath() + 0N/A " to " + target.getPath()); 0N/A java.io.InputStream in = new java.io.FileInputStream(source); 0N/A java.io.OutputStream out = new java.io.FileOutputStream(target); 0N/A byte[] buf = new byte[512]; 0N/A while ((n = in.read(buf, 0, 512)) > 0) { 0N/A out.write(buf, 0, n); 0N/A Runtime.getRuntime().exec("/bin/chmod 755 " + fname).waitFor();