/** * (Tries to) execute the script with the given script path. * * @param scriptPath * - the abolute file path of the script to be executed * @param scriptOutputLogFilename * @throws ScriptExecutionException * - an exception if anything fails in the execution * process. */ private void executeScript(String scriptPath, String scriptOutputLogFilename) throws ScriptExecutionException { if (scriptPath != null) { runSystemCall(scriptPath, scriptOutputLogFilename); log.info(scriptPath + " was excuted successfully."); } else { throw new ScriptExecutionException( "Undefined script path", REASON.NOTAVAILABLE); } }
throw new ScriptExecutionException( sb.toString().trim().isEmpty() ? "exit value = " + p.exitValue() throw new ScriptExecutionException( "Script execution interrupted", REASON.GENERIC, e); throw new ScriptExecutionException( "Could not execute systemcall", REASON.GENERIC, e); throw new ScriptExecutionException( "Could not close logOutput Writer", REASON.GENERIC, e);
+ " could not be set"; log.log(Level.WARNING, message); throw new ScriptExecutionException(message, REASON.PERMISSION);
@Test public void executeDeployment_ScriptExecutionException() throws ScriptExecutionException { // given final ScriptExecutionException se = new ScriptExecutionException("error", REASON.EXECUTIONEXCEPTION); String folder = "folder"; GenerationResult result = new GenerationResult(); result.setDeployment(deployment); EnvironmentGenerationResult envResult = new EnvironmentGenerationResult(); NodeGenerationResult nodeResult = new NodeGenerationResult(); nodeResult.setFolderToExecute(folder); nodeResult.setNodeEnabled(true); envResult.addNodeGenerationResult(nodeResult); result.addEnvironmentGenerationResult(envResult); Mockito.doThrow(se).when(systemCallService).getAndExecuteScriptFromGeneratedConfig(folder, nodeResult.getDeploymentLogfilePath()); // when deploymentAsynchronousExecuter.executeDeployment(result, deployment, GenerationModus.DEPLOY); // then verify(deploymentExecutionResultHandlerService, times(0)).handleSuccessfulDeployment(any(GenerationModus.class), any(GenerationResult.class)); verify(deploymentExecutionResultHandlerService, times(1)).handleUnSuccessfulDeployment(GenerationModus.DEPLOY,deployment, result, se, DeploymentFailureReason.DEPLOYMENT_SCRIPT); }