@Test public void testStopControlJvmSynchronously() throws InterruptedException { final Jvm mockJvm = mock(Jvm.class); when(mockJvm.getHostName()).thenReturn("mockJvmHost"); when(mockJvm.getState()).thenReturn(JvmState.JVM_STOPPED); when(Config.mockJvmPersistenceService.getJvm(any(Identifier.class))).thenReturn(mockJvm); when(Config.mockRemoteCommandExecutorService.executeCommand(any(RemoteExecCommand.class))).thenReturn(new RemoteCommandReturnInfo(0, "Success!", "")); when(Config.mockJvmCommandFactory.executeCommand(mockJvm, JvmControlOperation.STOP)).thenReturn(new RemoteCommandReturnInfo(0, "Success!", "")); final ControlJvmRequest controlJvmRequest = new ControlJvmRequest(new Identifier<Jvm>("1"), JvmControlOperation.STOP); final CommandOutput commandOutput = jvmControlService.controlJvmSynchronously(controlJvmRequest, 60000, new User("jedi")); assertTrue(commandOutput.getReturnCode().getWasSuccessful()); }
@Override public CommandOutput controlJvmSynchronously(final ControlJvmRequest controlJvmRequest, final long timeout, final User user) throws InterruptedException { final CommandOutput commandOutput = controlJvm(controlJvmRequest, user); if (commandOutput.getReturnCode().wasSuccessful()) { switch (controlJvmRequest.getControlOperation()) { case START: waitForState(controlJvmRequest, timeout, JvmState.JVM_STARTED); break; case STOP: waitForState(controlJvmRequest, timeout, JvmState.JVM_STOPPED, JvmState.FORCED_STOPPED); break; case BACK_UP: case CHANGE_FILE_MODE: case CHECK_FILE_EXISTS: case CREATE_DIRECTORY: case DELETE_SERVICE: case DEPLOY_JVM_ARCHIVE: case HEAP_DUMP: case INSTALL_SERVICE: case SCP: case THREAD_DUMP: throw new UnsupportedOperationException(); } } return commandOutput; }
JvmControlServiceImpl implements JvmControlService { @Override public CommandOutput controlJvmSynchronously(final ControlJvmRequest controlJvmRequest, final long timeout, final User user) throws InterruptedException { final CommandOutput commandOutput = controlJvm(controlJvmRequest, user); if (commandOutput.getReturnCode().wasSuccessful()) { switch (controlJvmRequest.getControlOperation()) { case START: waitForState(controlJvmRequest, timeout, JvmState.JVM_STARTED); break; case STOP: waitForState(controlJvmRequest, timeout, JvmState.JVM_STOPPED, JvmState.FORCED_STOPPED); break; case BACK_UP: case CHANGE_FILE_MODE: case CHECK_FILE_EXISTS: case CREATE_DIRECTORY: case DELETE_SERVICE: case DEPLOY_JVM_ARCHIVE: case HEAP_DUMP: case INSTALL_SERVICE: case SCP: case THREAD_DUMP: throw new UnsupportedOperationException(); } } return commandOutput; } }
JvmControlServiceImpl implements JvmControlService { @Override public CommandOutput controlJvmSynchronously(final ControlJvmRequest controlJvmRequest, final long timeout, final User user) throws InterruptedException { final CommandOutput commandOutput = controlJvm(controlJvmRequest, user); if (commandOutput.getReturnCode().wasSuccessful()) { switch (controlJvmRequest.getControlOperation()) { case START: waitForState(controlJvmRequest, timeout, JvmState.JVM_STARTED); break; case STOP: waitForState(controlJvmRequest, timeout, JvmState.JVM_STOPPED, JvmState.FORCED_STOPPED); break; case BACK_UP: case CHANGE_FILE_MODE: case CHECK_FILE_EXISTS: case CREATE_DIRECTORY: case DELETE_SERVICE: case DEPLOY_JVM_ARCHIVE: case HEAP_DUMP: case INSTALL_SERVICE: case SCP: case THREAD_DUMP: throw new UnsupportedOperationException(); } } return commandOutput; } JvmControlServiceImpl(final JvmPersistenceService jvmPersistenceService,
                                 final JvmStateService jvmStateService,
                                 final HistoryFacadeService historyFacadeService); }
JvmControlServiceImpl implements JvmControlService { @Override public CommandOutput controlJvmSynchronously(final ControlJvmRequest controlJvmRequest, final long timeout, final User user) throws InterruptedException { final CommandOutput commandOutput = controlJvm(controlJvmRequest, user); if (commandOutput.getReturnCode().wasSuccessful()) { switch (controlJvmRequest.getControlOperation()) { case START: waitForState(controlJvmRequest, timeout, JvmState.JVM_STARTED); break; case STOP: waitForState(controlJvmRequest, timeout, JvmState.JVM_STOPPED, JvmState.FORCED_STOPPED); break; case BACK_UP: case CHANGE_FILE_MODE: case CHECK_FILE_EXISTS: case CREATE_DIRECTORY: case DELETE_SERVICE: case DEPLOY_JVM_ARCHIVE: case HEAP_DUMP: case INSTALL_SERVICE: case SCP: case THREAD_DUMP: throw new UnsupportedOperationException(); } } return commandOutput; } JvmControlServiceImpl(final JvmPersistenceService jvmPersistenceService,
                                 final JvmStateService jvmStateService,
                                 final HistoryFacadeService historyFacadeService); @Override CommandOutput controlJvm(final ControlJvmRequest controlJvmRequest, final User aUser); @Override CommandOutput controlJvmSynchronously(final ControlJvmRequest controlJvmRequest, final long timeout,
                                                 final User user); @Override CommandOutput secureCopyFile(final ControlJvmRequest secureCopyRequest, final String sourcePath,
                                        final String destPath, String userId, boolean overwrite); @Override CommandOutput executeChangeFileModeCommand(final Jvm jvm, final String modifiedPermissions, final String targetAbsoluteDir, final String targetFile); @Override CommandOutput executeCreateDirectoryCommand(final Jvm jvm, final String dirAbsolutePath); @Override CommandOutput executeCheckFileExistsCommand(final Jvm jvm, final String filename); @Override CommandOutput executeBackUpCommand(final Jvm jvm, final String filename); void setJvmCommandFactory(JvmCommandFactory jvmCommandFactory); }
JvmControlServiceImpl implements JvmControlService { @Override public CommandOutput controlJvmSynchronously(final ControlJvmRequest controlJvmRequest, final long timeout, final User user) throws InterruptedException { final CommandOutput commandOutput = controlJvm(controlJvmRequest, user); if (commandOutput.getReturnCode().wasSuccessful()) { switch (controlJvmRequest.getControlOperation()) { case START: waitForState(controlJvmRequest, timeout, JvmState.JVM_STARTED); break; case STOP: waitForState(controlJvmRequest, timeout, JvmState.JVM_STOPPED, JvmState.FORCED_STOPPED); break; case BACK_UP: case CHANGE_FILE_MODE: case CHECK_FILE_EXISTS: case CREATE_DIRECTORY: case DELETE_SERVICE: case DEPLOY_JVM_ARCHIVE: case HEAP_DUMP: case INSTALL_SERVICE: case SCP: case THREAD_DUMP: throw new UnsupportedOperationException(); } } return commandOutput; } JvmControlServiceImpl(final JvmPersistenceService jvmPersistenceService,
                                 final JvmStateService jvmStateService,
                                 final HistoryFacadeService historyFacadeService); @Override CommandOutput controlJvm(final ControlJvmRequest controlJvmRequest, final User aUser); @Override CommandOutput controlJvmSynchronously(final ControlJvmRequest controlJvmRequest, final long timeout,
                                                 final User user); @Override CommandOutput secureCopyFile(final ControlJvmRequest secureCopyRequest, final String sourcePath,
                                        final String destPath, String userId, boolean overwrite); @Override CommandOutput executeChangeFileModeCommand(final Jvm jvm, final String modifiedPermissions, final String targetAbsoluteDir, final String targetFile); @Override CommandOutput executeCreateDirectoryCommand(final Jvm jvm, final String dirAbsolutePath); @Override CommandOutput executeCheckFileExistsCommand(final Jvm jvm, final String filename); @Override CommandOutput executeBackUpCommand(final Jvm jvm, final String filename); void setJvmCommandFactory(JvmCommandFactory jvmCommandFactory);  }