use of com.checkmarx.flow.exception.ExitThrowable in project cx-flow by checkmarx-ltd.
the class ThresholdsSteps method validateExitCode.
@Then("cxflow should exit with the correct {}")
public void validateExitCode(int expectedExitCode) {
Throwable exception = testContext.getCxFlowExecutionException();
Assert.assertNotNull("Expected an exception to be thrown.", exception);
Assert.assertEquals(InvocationTargetException.class, exception.getClass());
Throwable targetException = ((InvocationTargetException) exception).getTargetException();
Assert.assertTrue(targetException instanceof ExitThrowable);
int actualExitCode = ((ExitThrowable) targetException).getExitCode();
Assert.assertEquals("The expected exist code did not match", expectedExitCode, actualExitCode);
}
use of com.checkmarx.flow.exception.ExitThrowable in project cx-flow by checkmarx-ltd.
the class ScaThresholdsSteps method validateExitCode.
@Then("cxflow SCA should exit with the correct {}")
public void validateExitCode(int expectedExitCode) {
Throwable exception = testContext.getCxFlowExecutionException();
Assert.assertNotNull("Expected an exception to be thrown.", exception);
Assert.assertEquals(InvocationTargetException.class, exception.getClass());
Throwable targetException = ((InvocationTargetException) exception).getTargetException();
Assert.assertTrue(targetException instanceof ExitThrowable);
int actualExitCode = ((ExitThrowable) targetException).getExitCode();
Assert.assertEquals("The expected exist code did not match", expectedExitCode, actualExitCode);
}
use of com.checkmarx.flow.exception.ExitThrowable in project cx-flow by checkmarx-ltd.
the class AstCliSteps method validateExitCode.
@Then("run should exit with exit code {}")
public void validateExitCode(int expectedExitCode) {
Assert.assertNotNull("Expected an exception to be thrown.", cxFlowExecutionException);
Assert.assertEquals(InvocationTargetException.class, cxFlowExecutionException.getClass());
Throwable targetException = ((InvocationTargetException) cxFlowExecutionException).getTargetException();
Assert.assertTrue(targetException instanceof ExitThrowable);
int actualExitCode = ((ExitThrowable) targetException).getExitCode();
Assert.assertEquals("The expected exit code did not match", expectedExitCode, actualExitCode);
}
use of com.checkmarx.flow.exception.ExitThrowable in project cx-flow by checkmarx-ltd.
the class CxFlowRunner method run.
@Override
public void run(ApplicationArguments args) throws InvocationTargetException {
if (!args.getOptionNames().isEmpty()) {
try {
if (args.containsOption("web")) {
log.debug("Running web mode");
} else {
log.debug("Running cmd mode. Parameters: {}", String.join(" ", args.getSourceArgs()));
commandLineRunner(args);
}
} catch (ExitThrowable ee) {
log.info("Finished with exit code: {}", ee.getExitCode());
if (args.containsOption(THROW_INSTEAD_OF_EXIT_OPTION)) {
throw new InvocationTargetException(ee);
}
System.exit(ee.getExitCode());
} finally {
if (executors != null && (args.containsOption("scan") || args.containsOption(PARSE_OPTION) || args.containsOption(BATCH_OPTION))) {
executors.forEach(ThreadPoolTaskExecutor::shutdown);
}
}
}
}
use of com.checkmarx.flow.exception.ExitThrowable in project cx-flow by checkmarx-ltd.
the class RunningCxFlowSteps method cxflowExitsWithStatusCodeStatusCode.
@Then("CxFlow exits with exit code {}")
public void cxflowExitsWithStatusCodeStatusCode(int expectedExitCode) {
Throwable exception = testContext.getCxFlowExecutionException();
Assert.assertNotNull("Expected an exception to be thrown.", exception);
Assert.assertEquals(InvocationTargetException.class, exception.getClass());
Throwable targetException = ((InvocationTargetException) exception).getTargetException();
Assert.assertTrue(targetException instanceof ExitThrowable);
int actualExitCode = ((ExitThrowable) targetException).getExitCode();
Assert.assertEquals(expectedExitCode, actualExitCode);
}
Aggregations