use of org.sakuli.exceptions.SakuliCheckedException in project sakuli by ConSol.
the class GearmanTestCaseTemplateOutputBuilderIntegrationTest method testException.
@Test
public void testException() throws Exception {
TestCase testCase = new TestCaseExampleBuilder().withState(TestCaseState.ERRORS).withWarningTime(20).withCriticalTime(30).withStartDate(new DateTime(1970, 1, 1, 10, 36, 10).toDate()).withStopDate(new DateTime(1970, 1, 1, 10, 36, 23, 550).toDate()).withId("case2").withTestCaseSteps(Arrays.asList(new TestCaseStepExampleBuilder().withState(TestCaseStepState.ERRORS).withName("Test_Sahi_landing_page_(case2)").withWarningTime(5).withStartDate(new DateTime(1970, 1, 1, 10, 36, 0).toDate()).withStopDate(new DateTime(1970, 1, 1, 10, 36, 1, 50).toDate()).withException(new SakuliCheckedException("_highlight(_link(\"xSL Manager\")); TypeError: el is undefined Sahi.prototype._highlight@http://sahi.example.com/_s_/spr/concat.js:1210:9 @http://sahi.example.com/_s_/spr/concat.js line 3607 > eval:1:1 Sahi.prototype.ex@http://sahi.example.com/_s_/spr/concat.js:3607:9 Sahi.prototype.ex@http://sahi.example.com/_s_/spr/sakuli/inject.js:46:12 @http://sahi.example.com/_s_/spr/concat.js:3373:5 <a href='/_s_/dyn/Log_getBrowserScript?href=/root/sakuli/example_test_suites/example_xfce/case2/sakuli_demo.js&n=1210'><b>Click for browser script</b></a>")).buildExample(), new TestCaseStepExampleBuilder().withState(TestCaseStepState.OK).withName("Calculation_(case2)").withWarningTime(10).withStartDate(new DateTime(1970, 1, 1, 10, 36, 10).toDate()).withStopDate(new DateTime(1970, 1, 1, 10, 36, 17, 30).toDate()).buildExample(), new TestCaseStepExampleBuilder().withState(TestCaseStepState.OK).withName("Editor_(case2)").withWarningTime(10).withStartDate(new DateTime(1970, 1, 1, 10, 36, 20).toDate()).withStopDate(new DateTime(1970, 1, 1, 10, 36, 21, 390).toDate()).buildExample())).buildExample();
ScreenshotDiv screenshotDiv = new ScreenshotDiv();
screenshotDiv.setId("sakuli_screenshot243575009");
screenshotDiv.setFormat("jpg");
screenshotDiv.setBase64screenshot("/9j/4AAQSkZJRgABAgAAAQABAAD9k=");
doReturn(screenshotDiv).when(screenshotDivConverter).convert(notNull(Exception.class));
String output = testling.createOutput(testCase);
Assert.assertEquals(output, loadExpectedOutput(TestCaseState.ERRORS.name()));
}
use of org.sakuli.exceptions.SakuliCheckedException in project sakuli by ConSol.
the class Application method killAppPID.
private Application killAppPID(Integer pid) throws SakuliCheckedException {
try {
String cmd = String.format(Settings.isWindows() ? "Taskkill /PID %d /F" : "kill -9 %d", pid);
CommandExecutorHelper.execute(cmd, 0);
} catch (Exception e) {
throw new SakuliCheckedException(e, String.format("could not kill application with PID '%d'.", pid));
}
return this;
}
use of org.sakuli.exceptions.SakuliCheckedException in project sakuli by ConSol.
the class TestSuiteTest method testGetExceptionMessage.
@Test
public void testGetExceptionMessage() {
TestSuite testSuite = new TestSuite();
String message = "suite-exception";
testSuite.addException(new SakuliCheckedException(message));
assertEquals(testSuite.getExceptionMessages(false), message);
assertEquals(testSuite.getExceptionMessages(true), message);
TestCase tc1 = new TestCase("case1", "case1");
String messageCase = "case-exception";
tc1.addException(new SakuliCheckedException(messageCase));
testSuite.addTestCase(tc1.getId(), tc1);
assertEquals(testSuite.getExceptionMessages(false), message + "\n" + "CASE \"" + tc1.getId() + "\": " + messageCase);
assertEquals(testSuite.getExceptionMessages(true), message + " -- CASE \"" + tc1.getId() + "\": " + messageCase);
}
use of org.sakuli.exceptions.SakuliCheckedException in project sakuli by ConSol.
the class TestSuiteTest method testGetExceptionMessageWithErrorInStep.
@Test
public void testGetExceptionMessageWithErrorInStep() {
TestSuite testSuite = new TestSuite();
String message = "suite-exception";
testSuite.addException(new SakuliCheckedException(message));
assertEquals(testSuite.getExceptionMessages(false), message);
assertEquals(testSuite.getExceptionMessages(true), message);
TestCase tc1 = new TestCase("case1", "case1");
String messageCase = "case-exception";
tc1.addException(new SakuliCheckedException(messageCase));
testSuite.addTestCase(tc1.getId(), tc1);
TestCaseStep step1 = new TestCaseStepBuilder("step1").build();
String messageStep = "step-exception";
step1.addException(new SakuliCheckedException(messageStep));
tc1.addStep(step1);
assertEquals(testSuite.getExceptionMessages(false), message + "\n" + "CASE \"" + tc1.getId() + "\": " + messageCase + "\n\tSTEP \"" + step1.getId() + "\": " + messageStep);
assertEquals(testSuite.getExceptionMessages(true), message + " -- CASE \"" + tc1.getId() + "\": " + messageCase + " - STEP \"" + step1.getId() + "\": " + messageStep);
tc1.exception = null;
assertEquals(testSuite.getExceptionMessages(false), message + "\n" + "CASE \"" + tc1.getId() + "\": " + "\n\tSTEP \"" + step1.getId() + "\": " + messageStep);
assertEquals(testSuite.getExceptionMessages(true), message + " -- CASE \"" + tc1.getId() + "\": " + "STEP \"" + step1.getId() + "\": " + messageStep);
testSuite.exception = null;
assertEquals(testSuite.getExceptionMessages(false), "CASE \"" + tc1.getId() + "\": " + "\n\tSTEP \"" + step1.getId() + "\": " + messageStep);
assertEquals(testSuite.getExceptionMessages(true), "CASE \"" + tc1.getId() + "\": " + "STEP \"" + step1.getId() + "\": " + messageStep);
}
use of org.sakuli.exceptions.SakuliCheckedException in project sakuli by ConSol.
the class BaseActionLoaderTest method testInitNoSahiSession.
@SuppressWarnings("ThrowableResultOfMethodCallIgnored")
@Test
public void testInitNoSahiSession() throws Exception {
String testCaseId = "xyz";
when(testSuite.getTestCase(testCaseId)).thenReturn(new TestCase("Test", testCaseId));
when(rhinoScriptRunner.getSession()).thenReturn(null);
when(sakuliProperties.isLoadJavaScriptEngine()).thenReturn(true);
ArgumentCaptor<SakuliCheckedException> ac = ArgumentCaptor.forClass(SakuliCheckedException.class);
testling.init(testCaseId, ".");
verify(exceptionHandler).handleException(ac.capture());
assertEquals(ac.getValue().getMessage(), "cannot init rhino script runner with sakuli custom delay variable 'sakuli-delay-active'");
verify(session, never()).setVariable(anyString(), anyString());
}
Aggregations