@Test
public void testProcessContextAttach() throws Exception {

	ProcessChannel<String> processChannel = _localProcessExecutor.execute(
		_createJPDAProcessConfig(_JPDA_OPTIONS1),
		Operations.asControllable(Operations.SLEEP));
	Future<Controller> future = processChannel.write(
		Operations.GET_CONTROLLER);
	Controller parentController = future.get();
	Assert.assertTrue(parentController.isAlive());
	Controller childController = parentController.invoke(
		Operations.asNewJVM(_JPDA_OPTIONS2, Operations.SLEEP));
	Assert.assertTrue(childController.isAlive());
	// Initially not attached
	Assert.assertFalse(childController.invoke(Operations.IS_ATTACHED));
	// Detach is not doing anything
	Assert.assertEquals("DONE", childController.invoke(Operations.DETACH));
	Assert.assertFalse(childController.invoke(Operations.IS_ATTACHED));
	// Attach child to parent
	Assert.assertTrue(
		childController.invoke(
			Operations.attach(ShutdownHooks.TERMINATE_SHUTDOWN_HOOK)));
	Assert.assertTrue(childController.invoke(Operations.IS_ATTACHED));
	// Double attach is rejected
	Assert.assertFalse(
		childController.invoke(
			Operations.attach(ShutdownHooks.TERMINATE_SHUTDOWN_HOOK)));
	// Detach
	Assert.assertEquals("DONE", childController.invoke(Operations.DETACH));
	Assert.assertFalse(childController.invoke(Operations.IS_ATTACHED));
	// Reattach
	Assert.assertTrue(
		childController.invoke(
			Operations.attach(ShutdownHooks.TERMINATE_SHUTDOWN_HOOK)));
	Assert.assertTrue(childController.invoke(Operations.IS_ATTACHED));
	// Kill parent
	parentController.invoke(Operations.TERMINATE);
	Assert.assertFalse(parentController.isAlive());
	NoticeableFuture<String> noticeableFuture =
		processChannel.getProcessNoticeableFuture();
	Assert.assertEquals("DONE", noticeableFuture.get());
	// Time wait 10 minutes to assert child is dead
	_timeWaitAssertFalse(
		"The child process is still alive", childController::isAlive, 10,
		TimeUnit.MINUTES);
}