use of org.sakuli.exceptions.SakuliExceptionHandler in project sakuli by ConSol.
the class SahiCommandExecutionAspectTest method testCatchSahiCommandExcecutionErrors.
@Test
public void testCatchSahiCommandExcecutionErrors() throws Exception {
SakuliExceptionHandler exceptionHandler = BeanLoader.loadBean(SakuliExceptionHandler.class);
try {
Utils.executeAndGetProcess(new String[] { "testcommand", "arg1", "arg2" });
} catch (Exception e) {
//exception have nothing to with the test
}
verify(exceptionHandler).handleException(any(SakuliInitException.class));
}
use of org.sakuli.exceptions.SakuliExceptionHandler in project sakuli by ConSol.
the class SahiCommandExecutionAspectTest method testCatchSahiCommandExcecutionErrorsKeytool.
@Test
public void testCatchSahiCommandExcecutionErrorsKeytool() throws Exception {
SakuliExceptionHandler exceptionHandler = BeanLoader.loadBean(SakuliExceptionHandler.class);
try {
Utils.executeAndGetProcess(new String[] { "keytool", "arg1", "arg2" });
} catch (Exception e) {
//exception have nothing to with the test
}
verify(exceptionHandler, never()).handleException(any(SakuliInitException.class));
}
use of org.sakuli.exceptions.SakuliExceptionHandler in project sakuli by ConSol.
the class AopBaseTest method initMocks.
protected void initMocks() {
SakuliExceptionHandler sakuliExceptionHandler = BeanLoader.loadBean(SakuliExceptionHandler.class);
reset(sakuliExceptionHandler);
SahiScript sahiScriptMock = mock(SahiScript.class);
when(sahiScriptMock.jsString()).thenReturn("");
new RhinoScriptRunner(sahiScriptMock);
}
use of org.sakuli.exceptions.SakuliExceptionHandler in project sakuli by ConSol.
the class RhinoAspectTest method verifySahiReport.
private void verifySahiReport(ResultType resultTyp, int initialListSize) {
if (resultTyp != null) {
Report sahiReport2 = BeanLoader.loadBaseActionLoader().getSahiReport();
int newLisSize = sahiReport2.getListResult().size();
assertEquals(newLisSize, initialListSize + 1);
TestResult testResult = sahiReport2.getListResult().get(newLisSize - 1);
assertNotNull(testResult);
SakuliExceptionHandler sakuliExceptionHandler = BeanLoader.loadBean(SakuliExceptionHandler.class);
if (resultTyp.equals(ResultType.ERROR) || resultTyp.equals(ResultType.FAILURE)) {
verify(sakuliExceptionHandler).handleException(any(LogResult.class));
} else {
verify(sakuliExceptionHandler, never()).handleException(any(LogResult.class));
}
}
}
use of org.sakuli.exceptions.SakuliExceptionHandler in project sakuli by ConSol.
the class ExceptionHandlerAspect method processJavaException.
/**
* Throw the handled Exception after {@link SakuliExceptionHandler#processException(Throwable)} to stop the current
* test case execution of an JAVA test.
*/
@After("execution(* org.sakuli.exceptions.SakuliExceptionHandler.processException(..)) ")
public void processJavaException(JoinPoint joinPoint) throws Throwable {
Object[] args = joinPoint.getArgs();
if (args != null && args.length == 1) {
Object e = args[0];
SakuliExceptionHandler exceptionHandler = BeanLoader.loadBaseActionLoader().getExceptionHandler();
if (e instanceof SakuliException && exceptionHandler.resumeToTestExcecution((SakuliException) e)) {
return;
}
throw (Throwable) e;
}
}
Aggregations