use of org.sakuli.services.forwarder.gearman.GearmanProperties in project sakuli by ConSol.
the class NagiosOutputBuilderTest method testFormatTestCaseTableStateMessageWithScreenshotTestCase.
@Test
public void testFormatTestCaseTableStateMessageWithScreenshotTestCase() 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)).withTestCaseSteps(Collections.singletonList(new TestCaseStepExampleBuilder().withState(TestCaseStepState.ERRORS).withException(new SakuliExceptionWithScreenshot("STEP-EXCEPTION-MESSAGE", screenshotPath)).buildExample())).buildExample();
String regex = String.format(htmlTemplate, "serviceCRITICAL", "\\[CRIT\\] case \"case-error\" EXCEPTION: EXCEPTION-MESSAGE" + " - STEP \"step_for_unit_test\": STEP-EXCEPTION-MESSAGE" + "<div.* src=\"data:image\\/png;base64,.*><\\/div>" + "<div.* src=\"data:image\\/png;base64,.*><\\/div>");
BaseTest.assertRegExMatch(testling.formatTestCaseTableStateMessage(testCase, properties.lookUpTemplate(testCase.getState())), regex);
}
use of org.sakuli.services.forwarder.gearman.GearmanProperties in project sakuli by ConSol.
the class NagiosOutputBuilderTest method testFormatTestCaseTableStateMessage.
@Test
public void testFormatTestCaseTableStateMessage() throws Exception {
String htmlTemplate = "<tr valign=\"top\"><td class=\"%s\">%s</td></tr>";
GearmanProperties properties = MonitoringPropertiesTestHelper.initMock(mock(GearmanProperties.class));
TestCase testCase = new TestCaseExampleBuilder().withState(TestCaseState.OK).withId("case-ok").buildExample();
assertEquals(testling.formatTestCaseTableStateMessage(testCase, properties.lookUpTemplate(testCase.getState())), String.format(htmlTemplate, "serviceOK", "[OK] case \"case-ok\" ran in 3.00s - ok"));
Date startDate = new Date();
testCase = new TestCaseExampleBuilder().withId("case-warning").withState(TestCaseState.WARNING).withStartDate(startDate).withStopDate(DateUtils.addMilliseconds(startDate, 5500)).withWarningTime(5).buildExample();
assertEquals(testling.formatTestCaseTableStateMessage(testCase, properties.lookUpTemplate(testCase.getState())), String.format(htmlTemplate, "serviceWARNING", "[WARN] case \"case-warning\" over runtime (5.50s/warn at 5s)"));
testCase = new TestCaseExampleBuilder().withState(TestCaseState.WARNING_IN_STEP).withId("case-warning").withTestCaseSteps(Arrays.asList(new TestCaseStepExampleBuilder().withName("step-name").withState(TestCaseStepState.WARNING).withStartDate(startDate).withStopDate(DateUtils.addMilliseconds(startDate, 3154)).withWarningTime(3).buildExample(), new TestCaseStepExampleBuilder().withName("step-name2").withState(TestCaseStepState.WARNING).withStartDate(DateUtils.addMilliseconds(startDate, 4000)).withStopDate(DateUtils.addMilliseconds(startDate, 4154)).withWarningTime(1).buildExample())).buildExample();
assertEquals(testling.formatTestCaseTableStateMessage(testCase, properties.lookUpTemplate(testCase.getState())), String.format(htmlTemplate, "serviceWARNING", "[WARN] case \"case-warning\" (3.00s) ok, step \"step-name\" over runtime (3.15s/warn at 3s), " + "step \"step-name2\" over runtime (0.15s/warn at 1s)"));
testCase = new TestCaseExampleBuilder().withState(TestCaseState.CRITICAL).withId("case-critical").withStartDate(startDate).withStopDate(DateUtils.addMilliseconds(startDate, 8888)).withCriticalTime(7).buildExample();
assertEquals(testling.formatTestCaseTableStateMessage(testCase, properties.lookUpTemplate(testCase.getState())), String.format(htmlTemplate, "serviceCRITICAL", "[CRIT] case \"case-critical\" over runtime (8.89s/crit at 7s)"));
testCase = new TestCaseExampleBuilder().withState(TestCaseState.ERRORS).withId("case-error").withException(new SakuliException("EXCEPTION-MESSAGE")).buildExample();
assertEquals(testling.formatTestCaseTableStateMessage(testCase, properties.lookUpTemplate(testCase.getState())), String.format(htmlTemplate, "serviceCRITICAL", "[CRIT] case \"case-error\" EXCEPTION: EXCEPTION-MESSAGE"));
}
use of org.sakuli.services.forwarder.gearman.GearmanProperties in project sakuli by ConSol.
the class NagiosOutputBuilderTest method testFormatTestCaseTableStateMessageWithScreenshotOnylInTestCase.
@Test
public void testFormatTestCaseTableStateMessageWithScreenshotOnylInTestCase() 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").withTestCaseSteps(Collections.singletonList(new TestCaseStepExampleBuilder().withState(TestCaseStepState.ERRORS).withException(new SakuliExceptionWithScreenshot("STEP-EXCEPTION-MESSAGE", screenshotPath)).buildExample())).buildExample();
String regex = String.format(htmlTemplate, "serviceCRITICAL", "\\[CRIT\\] case \"case-error\" EXCEPTION: " + "STEP \"step_for_unit_test\": STEP-EXCEPTION-MESSAGE" + "<div.* src=\"data:image\\/png;base64,.*><\\/div>");
BaseTest.assertRegExMatch(testling.formatTestCaseTableStateMessage(testCase, properties.lookUpTemplate(testCase.getState())), regex);
}
use of org.sakuli.services.forwarder.gearman.GearmanProperties 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);
}
Aggregations