Search in sources :

Example 6 with SakuliCheckedException

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 + ")");
}
Also used : TestSuite(org.sakuli.datamodel.TestSuite) SakuliCheckedException(org.sakuli.exceptions.SakuliCheckedException) Date(java.util.Date) TestSuiteExampleBuilder(org.sakuli.builder.TestSuiteExampleBuilder) Test(org.testng.annotations.Test)

Example 7 with SakuliCheckedException

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()));
}
Also used : TestCase(org.sakuli.datamodel.TestCase) TreeSet(java.util.TreeSet) TestCaseExampleBuilder(org.sakuli.builder.TestCaseExampleBuilder) SakuliCheckedException(org.sakuli.exceptions.SakuliCheckedException) ScreenshotDiv(org.sakuli.services.forwarder.ScreenshotDiv) DateTime(org.joda.time.DateTime) SakuliCheckedException(org.sakuli.exceptions.SakuliCheckedException) IOException(java.io.IOException) TestCaseStepExampleBuilder(org.sakuli.builder.TestCaseStepExampleBuilder) Test(org.testng.annotations.Test) IntegrationTest(org.sakuli.integration.IntegrationTest) BaseTest(org.sakuli.BaseTest)

Example 8 with SakuliCheckedException

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");
}
Also used : TestSuite(org.sakuli.datamodel.TestSuite) TestCaseExampleBuilder(org.sakuli.builder.TestCaseExampleBuilder) SakuliCheckedException(org.sakuli.exceptions.SakuliCheckedException) TestSuiteExampleBuilder(org.sakuli.builder.TestSuiteExampleBuilder) Test(org.testng.annotations.Test)

Example 9 with SakuliCheckedException

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");
}
Also used : TestSuite(org.sakuli.datamodel.TestSuite) TestCaseExampleBuilder(org.sakuli.builder.TestCaseExampleBuilder) SakuliCheckedException(org.sakuli.exceptions.SakuliCheckedException) TestSuiteExampleBuilder(org.sakuli.builder.TestSuiteExampleBuilder) Test(org.testng.annotations.Test)

Example 10 with SakuliCheckedException

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");
}
Also used : TestSuite(org.sakuli.datamodel.TestSuite) TestCaseExampleBuilder(org.sakuli.builder.TestCaseExampleBuilder) SakuliCheckedException(org.sakuli.exceptions.SakuliCheckedException) TestSuiteExampleBuilder(org.sakuli.builder.TestSuiteExampleBuilder) Test(org.testng.annotations.Test)

Aggregations

SakuliCheckedException (org.sakuli.exceptions.SakuliCheckedException)19 Test (org.testng.annotations.Test)13 TestCaseExampleBuilder (org.sakuli.builder.TestCaseExampleBuilder)8 TestSuiteExampleBuilder (org.sakuli.builder.TestSuiteExampleBuilder)7 TestCaseStepExampleBuilder (org.sakuli.builder.TestCaseStepExampleBuilder)6 TestSuite (org.sakuli.datamodel.TestSuite)6 IOException (java.io.IOException)4 DateTime (org.joda.time.DateTime)4 BaseTest (org.sakuli.BaseTest)4 IntegrationTest (org.sakuli.integration.IntegrationTest)4 ScreenshotDiv (org.sakuli.services.forwarder.ScreenshotDiv)4 TestCase (org.sakuli.datamodel.TestCase)3 Path (java.nio.file.Path)2 Date (java.util.Date)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 FileNotFoundException (java.io.FileNotFoundException)1 ConnectException (java.net.ConnectException)1 TreeSet (java.util.TreeSet)1 Report (net.sf.sahi.ant.Report)1 TestRunner (net.sf.sahi.test.TestRunner)1