Search in sources :

Example 21 with TestCaseExampleBuilder

use of org.sakuli.builder.TestCaseExampleBuilder in project sakuli by ConSol.

the class DaoTestCaseImplTest method testGetScreenshotAsSqlLobValue.

@Test
public void testGetScreenshotAsSqlLobValue() throws Exception {
    Path screenshotPath = Paths.get(this.getClass().getResource("computer.png").toURI());
    TestCase testCase = new TestCaseExampleBuilder().withException(new SakuliExceptionWithScreenshot("test-exception", screenshotPath)).buildExample();
    SqlLobValue result = testling.getScreenshotAsSqlLobValue(testCase);
    assertNotNull(result);
}
Also used : Path(java.nio.file.Path) SqlLobValue(org.springframework.jdbc.core.support.SqlLobValue) TestCase(org.sakuli.datamodel.TestCase) SakuliExceptionWithScreenshot(org.sakuli.exceptions.SakuliExceptionWithScreenshot) TestCaseExampleBuilder(org.sakuli.builder.TestCaseExampleBuilder) Test(org.testng.annotations.Test)

Example 22 with TestCaseExampleBuilder

use of org.sakuli.builder.TestCaseExampleBuilder in project sakuli by ConSol.

the class NagiosOutputBuilderTest method testFormatTestCaseTableStateMessageWithScreenshot.

@Test
public void testFormatTestCaseTableStateMessageWithScreenshot() throws Exception {
    Path screenshotPath = Paths.get(NagiosOutputBuilder.class.getResource("computer.png").toURI());
    String htmlTemplate = "<tr valign=\"top\"><td class=\"%s\">%s<\\/td><\\/tr>";
    GearmanProperties properties = MonitoringPropertiesTestHelper.initMock(mock(GearmanProperties.class));
    TestCase testCase = new TestCaseExampleBuilder().withState(TestCaseState.ERRORS).withId("case-error").withException(new SakuliExceptionWithScreenshot("EXCEPTION-MESSAGE", screenshotPath)).buildExample();
    String regex = String.format(htmlTemplate, "serviceCRITICAL", "\\[CRIT\\] case \"case-error\" EXCEPTION: EXCEPTION-MESSAGE" + "<div.* src=\"data:image\\/png;base64,.*><\\/div>");
    BaseTest.assertRegExMatch(testling.formatTestCaseTableStateMessage(testCase, properties.lookUpTemplate(testCase.getState())), regex);
}
Also used : Path(java.nio.file.Path) GearmanProperties(org.sakuli.services.forwarder.gearman.GearmanProperties) TestCase(org.sakuli.datamodel.TestCase) SakuliExceptionWithScreenshot(org.sakuli.exceptions.SakuliExceptionWithScreenshot) TestCaseExampleBuilder(org.sakuli.builder.TestCaseExampleBuilder) Test(org.testng.annotations.Test) BaseTest(org.sakuli.BaseTest)

Example 23 with TestCaseExampleBuilder

use of org.sakuli.builder.TestCaseExampleBuilder in project sakuli by ConSol.

the class Icinga2OutputBuilderTest method testBuildOk.

@Test
public void testBuildOk() throws Exception {
    TestSuite testSuite = new TestSuiteExampleBuilder().withState(TestSuiteState.OK).withId("TEST-SUITE-ID").withTestCases(Collections.singletonList(new TestCaseExampleBuilder().withId("TEST-CASE-ID").buildExample())).buildExample();
    ReflectionTestUtils.setField(testling, "testSuite", testSuite);
    Assert.assertEquals(testling.build(), "[OK] Sakuli suite \"TEST-SUITE-ID\" ok (120.00s). (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) TestSuiteExampleBuilder(org.sakuli.builder.TestSuiteExampleBuilder) Test(org.testng.annotations.Test)

Example 24 with TestCaseExampleBuilder

use of org.sakuli.builder.TestCaseExampleBuilder in project sakuli by ConSol.

the class Icinga2OutputBuilderTest method testBuildCritical.

@Test
public void testBuildCritical() throws Exception {
    TestSuite testSuite = new TestSuiteExampleBuilder().withState(TestSuiteState.CRITICAL_IN_SUITE).withCriticalTime(100).withId("TEST-SUITE-ID").withTestCases(Collections.singletonList(new TestCaseExampleBuilder().withId("TEST-CASE-ID").withState(TestCaseState.OK).buildExample())).buildExample();
    ReflectionTestUtils.setField(testling, "testSuite", testSuite);
    Assert.assertEquals(testling.build(), "[CRIT] Sakuli suite \"TEST-SUITE-ID\" critical (120.00s/crit at 100s). (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) TestSuiteExampleBuilder(org.sakuli.builder.TestSuiteExampleBuilder) Test(org.testng.annotations.Test)

Example 25 with TestCaseExampleBuilder

use of org.sakuli.builder.TestCaseExampleBuilder in project sakuli by ConSol.

the class Icinga2OutputBuilderTest method testBuildWarningInCase.

@Test
public void testBuildWarningInCase() throws Exception {
    TestSuite testSuite = new TestSuiteExampleBuilder().withState(TestSuiteState.WARNING_IN_CASE).withId("TEST-SUITE-ID").withTestCases(Collections.singletonList(new TestCaseExampleBuilder().withId("TEST-CASE-ID").withState(TestCaseState.WARNING).buildExample())).buildExample();
    ReflectionTestUtils.setField(testling, "testSuite", testSuite);
    Assert.assertEquals(testling.build(), "[WARN] Sakuli suite \"TEST-SUITE-ID\" warning in case, case \"Unit Test Case\" over runtime (3.00s/warn at 4s). (Last suite run: 17.08.14 14:02:00)\n" + "[WARN] case \"TEST-CASE-ID\" over runtime (3.00s/warn at 4s)");
}
Also used : TestSuite(org.sakuli.datamodel.TestSuite) TestCaseExampleBuilder(org.sakuli.builder.TestCaseExampleBuilder) TestSuiteExampleBuilder(org.sakuli.builder.TestSuiteExampleBuilder) Test(org.testng.annotations.Test)

Aggregations

TestCaseExampleBuilder (org.sakuli.builder.TestCaseExampleBuilder)29 Test (org.testng.annotations.Test)29 TestCaseStepExampleBuilder (org.sakuli.builder.TestCaseStepExampleBuilder)17 BaseTest (org.sakuli.BaseTest)15 TestSuiteExampleBuilder (org.sakuli.builder.TestSuiteExampleBuilder)15 TestSuite (org.sakuli.datamodel.TestSuite)15 TestCase (org.sakuli.datamodel.TestCase)14 TreeSet (java.util.TreeSet)7 DateTime (org.joda.time.DateTime)7 SakuliException (org.sakuli.exceptions.SakuliException)7 Path (java.nio.file.Path)6 SakuliExceptionWithScreenshot (org.sakuli.exceptions.SakuliExceptionWithScreenshot)5 GearmanProperties (org.sakuli.services.forwarder.gearman.GearmanProperties)4 Date (java.util.Date)2 SqlLobValue (org.springframework.jdbc.core.support.SqlLobValue)2 Future (java.util.concurrent.Future)1 GearmanJobServerConnection (org.gearman.common.GearmanJobServerConnection)1 LoggerTest (org.sakuli.LoggerTest)1 TestCaseStepBuilder (org.sakuli.datamodel.builder.TestCaseStepBuilder)1 TestCaseStepState (org.sakuli.datamodel.state.TestCaseStepState)1