< prev index next >
test/jdk/jshell/UserJDIUserRemoteTest.java
Print this page
rev 3613 : imported patch 8131023
*** 35,45 ****
import static jdk.jshell.Snippet.Status.OVERWRITTEN;
import static jdk.jshell.Snippet.Status.VALID;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
- import java.io.ObjectOutputStream;
import java.net.ServerSocket;
import java.util.ArrayList;
import java.util.List;
import com.sun.jdi.VMDisconnectedException;
import com.sun.jdi.VirtualMachine;
--- 35,44 ----
*** 60,70 ****
import jdk.jshell.spi.ExecutionControl.ExecutionControlException;
import jdk.jshell.spi.ExecutionEnv;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.fail;
import static jdk.jshell.execution.Util.forwardExecutionControlAndIO;
! import static jdk.jshell.execution.Util.remoteInput;
@Test
public class UserJDIUserRemoteTest extends ExecutionControlTestBase {
ExecutionControl currentEC;
--- 59,69 ----
import jdk.jshell.spi.ExecutionControl.ExecutionControlException;
import jdk.jshell.spi.ExecutionEnv;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.fail;
import static jdk.jshell.execution.Util.forwardExecutionControlAndIO;
! import static jdk.jshell.execution.Util.remoteInputOutput;
@Test
public class UserJDIUserRemoteTest extends ExecutionControlTestBase {
ExecutionControl currentEC;
*** 144,154 ****
* @param env the context passed by
* {@link jdk.jshell.spi.ExecutionControl#start(jdk.jshell.spi.ExecutionEnv) }
* @return the channel
* @throws IOException if there are errors in set-up
*/
! static MyExecutionControl make(ExecutionEnv env, UserJDIUserRemoteTest test) throws IOException {
try (final ServerSocket listener = new ServerSocket(0)) {
// timeout after 60 seconds
listener.setSoTimeout(60000);
int port = listener.getLocalPort();
--- 143,153 ----
* @param env the context passed by
* {@link jdk.jshell.spi.ExecutionControl#start(jdk.jshell.spi.ExecutionEnv) }
* @return the channel
* @throws IOException if there are errors in set-up
*/
! static ExecutionControl make(ExecutionEnv env, UserJDIUserRemoteTest test) throws IOException {
try (final ServerSocket listener = new ServerSocket(0)) {
// timeout after 60 seconds
listener.setSoTimeout(60000);
int port = listener.getLocalPort();
*** 173,189 ****
// Set-up the commands/reslts on the socket. Piggy-back snippet
// output.
Socket socket = listener.accept();
// out before in -- match remote creation so we don't hang
! ObjectOutput cmdout = new ObjectOutputStream(socket.getOutputStream());
! Map<String, OutputStream> io = new HashMap<>();
! io.put("out", env.userOut());
! io.put("err", env.userErr());
! io.put("aux", test.auxStream);
! ObjectInput cmdin = remoteInput(socket.getInputStream(), io);
! MyExecutionControl myec = new MyExecutionControl(cmdout, cmdin, vm, process, deathListeners);
test.currentEC = myec;
return myec;
}
}
--- 172,189 ----
// Set-up the commands/reslts on the socket. Piggy-back snippet
// output.
Socket socket = listener.accept();
// out before in -- match remote creation so we don't hang
! OutputStream out = socket.getOutputStream();
! Map<String, OutputStream> outputs = new HashMap<>();
! outputs.put("out", env.userOut());
! outputs.put("err", env.userErr());
! outputs.put("aux", test.auxStream);
! Map<String, InputStream> input = new HashMap<>();
! input.put("in", env.userIn());
! ExecutionControl myec = remoteInputOutput(socket.getInputStream(), out, outputs, input, (objIn, objOut) -> new MyExecutionControl(objOut, objIn, vm, process, deathListeners));
test.currentEC = myec;
return myec;
}
}
*** 253,267 ****
try {
String loopBack = null;
Socket socket = new Socket(loopBack, Integer.parseInt(args[0]));
InputStream inStream = socket.getInputStream();
OutputStream outStream = socket.getOutputStream();
! Map<String, Consumer<OutputStream>> chans = new HashMap<>();
! chans.put("out", st -> System.setOut(new PrintStream(st, true)));
! chans.put("err", st -> System.setErr(new PrintStream(st, true)));
! chans.put("aux", st -> { auxPrint = new PrintStream(st, true); });
! forwardExecutionControlAndIO(new MyRemoteExecutionControl(), inStream, outStream, chans);
} catch (Throwable ex) {
throw ex;
}
}
--- 253,269 ----
try {
String loopBack = null;
Socket socket = new Socket(loopBack, Integer.parseInt(args[0]));
InputStream inStream = socket.getInputStream();
OutputStream outStream = socket.getOutputStream();
! Map<String, Consumer<OutputStream>> outputs = new HashMap<>();
! outputs.put("out", st -> System.setOut(new PrintStream(st, true)));
! outputs.put("err", st -> System.setErr(new PrintStream(st, true)));
! outputs.put("aux", st -> { auxPrint = new PrintStream(st, true); });
! Map<String, Consumer<InputStream>> input = new HashMap<>();
! input.put("in", st -> System.setIn(st));
! forwardExecutionControlAndIO(new MyRemoteExecutionControl(), inStream, outStream, outputs, input);
} catch (Throwable ex) {
throw ex;
}
}
< prev index next >