use of org.sakuli.exceptions.SakuliCheckedException in project sakuli by ConSol.
the class AbstractOutputBuilderTest method testFormatTestSuiteStateMessageException.
@Test
public void testFormatTestSuiteStateMessageException() throws Exception {
Date startDate = new Date();
TestSuite testSuiteExample = new TestSuiteExampleBuilder().withId("sakuli-123").withState(TestSuiteState.ERRORS).withStartDate(startDate).withException(new SakuliCheckedException("TEST-ERROR")).withStopDate(DateUtils.addSeconds(startDate, 120)).buildExample();
String result = testling.formatTestSuiteSummaryStateMessage(testSuiteExample, properties.getTemplateSuiteSummary());
String lastRun = AbstractOutputBuilder.dateFormat.format(testSuiteExample.getStopDate());
assertEquals(result, "[CRIT] Sakuli suite \"sakuli-123\" (120.00s) EXCEPTION: 'TEST-ERROR'. (Last suite run: " + lastRun + ")");
}
use of org.sakuli.exceptions.SakuliCheckedException in project sakuli by ConSol.
the class CheckMKTemplateOutputBuilderIntegrationTest method testException.
@Test
public void testException() throws Exception {
doReturn("example_xfce").when(testSuite).getId();
doReturn(TestSuiteState.ERRORS).when(testSuite).getState();
doReturn(300).when(testSuite).getWarningTime();
doReturn(400).when(testSuite).getCriticalTime();
doReturn(44.80f).when(testSuite).getDuration();
doReturn(new DateTime(1970, 1, 1, 10, 36, 0).toDate()).when(testSuite).getStartDate();
doReturn(new DateTime(1970, 1, 1, 10, 36, 44, 800).toDate()).when(testSuite).getStopDate();
when(testSuite.getExceptionMessages(anyBoolean())).thenCallRealMethod();
when(testSuite.getException()).thenCallRealMethod();
SortedSet<TestCase> testCaseAsSortedSet = new TreeSet<>(Arrays.asList(new TestCaseExampleBuilder().withState(TestCaseState.OK).withWarningTime(20).withCriticalTime(30).withStartDate(new DateTime(1970, 1, 1, 10, 36, 0).toDate()).withStopDate(new DateTime(1970, 1, 1, 10, 36, 14, 200).toDate()).withId("case1").withTestCaseSteps(Arrays.asList(new TestCaseStepExampleBuilder().withState(TestCaseStepState.OK).withName("Test_Sahi_landing_page").withWarningTime(5).withStartDate(new DateTime(1970, 1, 1, 10, 36, 0).toDate()).withStopDate(new DateTime(1970, 1, 1, 10, 36, 1, 140).toDate()).buildExample(), new TestCaseStepExampleBuilder().withState(TestCaseStepState.OK).withName("Calculation").withWarningTime(10).withStartDate(new DateTime(1970, 1, 1, 10, 36, 0, 10).toDate()).withStopDate(new DateTime(1970, 1, 1, 10, 36, 7, 540).toDate()).buildExample(), new TestCaseStepExampleBuilder().withState(TestCaseStepState.OK).withName("Editor").withWarningTime(10).withStartDate(new DateTime(1970, 1, 1, 10, 36, 0, 20).toDate()).withStopDate(new DateTime(1970, 1, 1, 10, 36, 1, 470).toDate()).buildExample())).buildExample(), 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()));
doReturn(testCaseAsSortedSet).when(testSuite).getTestCasesAsSortedSet();
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(testSuite);
Assert.assertEquals(output, loadExpectedOutput(TestSuiteState.ERRORS.name()));
}
use of org.sakuli.exceptions.SakuliCheckedException in project sakuli by ConSol.
the class Icinga2OutputBuilderTest method testBuildErrorInSuite.
@Test
public void testBuildErrorInSuite() throws Exception {
TestSuite testSuite = new TestSuiteExampleBuilder().withState(TestSuiteState.ERRORS).withId("TEST-SUITE-ID").withTestCases(Collections.singletonList(new TestCaseExampleBuilder().withId("TEST-CASE-ID").withState(TestCaseState.OK).buildExample())).withException(new SakuliCheckedException("MY-TEST-ERROR-SUITE")).buildExample();
ReflectionTestUtils.setField(testling, "testSuite", testSuite);
Assert.assertEquals(testling.build(), "[CRIT] Sakuli suite \"TEST-SUITE-ID\" (120.00s) EXCEPTION: 'MY-TEST-ERROR-SUITE'. (Last suite run: 17.08.14 14:02:00)\n" + "[OK] case \"TEST-CASE-ID\" ran in 3.00s - ok");
}
use of org.sakuli.exceptions.SakuliCheckedException in project sakuli by ConSol.
the class Icinga2OutputBuilderTest method testBuildErrorInCase.
@Test
public void testBuildErrorInCase() throws Exception {
TestSuite testSuite = new TestSuiteExampleBuilder().withState(TestSuiteState.ERRORS).withId("TEST-SUITE-ID").withTestCases(Collections.singletonList(new TestCaseExampleBuilder().withId("TEST-CASE-ID").withState(TestCaseState.ERRORS).withException(new SakuliCheckedException("MY-TEST-ERROR-CASE")).buildExample())).buildExample();
ReflectionTestUtils.setField(testling, "testSuite", testSuite);
Assert.assertEquals(testling.build(), "[CRIT] Sakuli suite \"TEST-SUITE-ID\" (120.00s) EXCEPTION: 'CASE \"TEST-CASE-ID\": MY-TEST-ERROR-CASE'. (Last suite run: 17.08.14 14:02:00)\n" + "[CRIT] case \"TEST-CASE-ID\" EXCEPTION: MY-TEST-ERROR-CASE");
}
use of org.sakuli.exceptions.SakuliCheckedException in project sakuli by ConSol.
the class Icinga2OutputBuilderTest method testBuildErrorInCaseMaxLength.
@Test
public void testBuildErrorInCaseMaxLength() throws Exception {
TestSuite testSuite = new TestSuiteExampleBuilder().withState(TestSuiteState.ERRORS).withId("TEST-SUITE-ID").withTestCases(Collections.singletonList(new TestCaseExampleBuilder().withId("TEST-CASE-ID").withState(TestCaseState.ERRORS).withException(new SakuliCheckedException("MY-TEST-ERROR-CASE xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" + "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")).buildExample())).buildExample();
ReflectionTestUtils.setField(testling, "testSuite", testSuite);
Assert.assertEquals(testling.build(), "[CRIT] Sakuli suite \"TEST-SUITE-ID\" (120.00s) EXCEPTION: 'CASE \"TEST-CASE-ID\": MY-TEST-ERROR-CASE " + "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ...\n" + "[CRIT] case \"TEST-CASE-ID\" EXCEPTION: MY-TEST-ERROR-CASE " + "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
}
Aggregations