Search in sources :

Example 16 with SakuliCheckedException

use of org.sakuli.exceptions.SakuliCheckedException in project sakuli by ConSol.

the class CacheHandlingServiceImplTest method init.

@BeforeMethod
public void init() {
    testSuite = new TestSuiteExampleBuilder().withId("LOG_TEST_SUITE").withState(TestSuiteState.ERRORS).withException(new SakuliCheckedException("TEST")).buildExample();
    MockitoAnnotations.initMocks(this);
}
Also used : SakuliCheckedException(org.sakuli.exceptions.SakuliCheckedException) TestSuiteExampleBuilder(org.sakuli.builder.TestSuiteExampleBuilder) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 17 with SakuliCheckedException

use of org.sakuli.exceptions.SakuliCheckedException in project sakuli by ConSol.

the class Icinga2OutputBuilderTest method testBuildErrorInStep.

@Test
public void testBuildErrorInStep() 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).withTestCaseSteps(Collections.singletonList(new TestCaseStepExampleBuilder().withState(TestCaseStepState.ERRORS).withException(new SakuliCheckedException("MY-TEST-ERROR-IN-STEP")).buildExample())).buildExample())).buildExample();
    ReflectionTestUtils.setField(testling, "testSuite", testSuite);
    Assert.assertEquals(testling.build(), "[CRIT] Sakuli suite \"TEST-SUITE-ID\" (120.00s) EXCEPTION: 'CASE \"TEST-CASE-ID\": STEP \"step_for_unit_test\": MY-TEST-ERROR-IN-STEP'. (Last suite run: 17.08.14 14:02:00)\n" + "[CRIT] case \"TEST-CASE-ID\" EXCEPTION: STEP \"step_for_unit_test\": MY-TEST-ERROR-IN-STEP");
}
Also used : TestSuite(org.sakuli.datamodel.TestSuite) TestCaseExampleBuilder(org.sakuli.builder.TestCaseExampleBuilder) SakuliCheckedException(org.sakuli.exceptions.SakuliCheckedException) TestSuiteExampleBuilder(org.sakuli.builder.TestSuiteExampleBuilder) TestCaseStepExampleBuilder(org.sakuli.builder.TestCaseStepExampleBuilder) Test(org.testng.annotations.Test)

Example 18 with SakuliCheckedException

use of org.sakuli.exceptions.SakuliCheckedException in project sakuli by ConSol.

the class GearmanTemplateOutputBuilderIntegrationTest method testException.

@Test
public void testException() throws Exception {
    testSuite.setState(TestSuiteState.ERRORS);
    testSuite.setWarningTime(300);
    testSuite.setCriticalTime(400);
    testSuite.setStartDate(new DateTime(1970, 1, 1, 10, 36, 0).toDate());
    testSuite.setStopDate(new DateTime(1970, 1, 1, 10, 36, 44, 800).toDate());
    testSuite.addTestCase(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());
    testSuite.addTestCase(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(testSuite);
    Assert.assertEquals(output, loadExpectedOutput(TestSuiteState.ERRORS.name()));
}
Also used : 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 19 with SakuliCheckedException

use of org.sakuli.exceptions.SakuliCheckedException in project sakuli by ConSol.

the class GearmanTestStepTemplateOutputBuilderIntegrationTest method testException.

@Test
public void testException() throws Exception {
    TestCaseStep testStep = new TestCaseStepExampleBuilder().withState(TestCaseStepState.ERRORS).withName("Test_Sahi_landing_page").withWarningTime(5).withWarningTime(10).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();
    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(testStep);
    Assert.assertEquals(output, loadExpectedOutput(TestCaseStepState.ERRORS.name()));
}
Also used : SakuliCheckedException(org.sakuli.exceptions.SakuliCheckedException) TestCaseStep(org.sakuli.datamodel.TestCaseStep) 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)

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