use of org.sakuli.datamodel.TestCase in project sakuli by ConSol.
the class BaseActionLoaderTest method testInit.
@Test
public void testInit() throws Exception {
String testCaseId = "xyz";
when(testSuite.getTestCase(testCaseId)).thenReturn(new TestCase("Test", testCaseId));
when(sahiProxyProperties.isRequestDelayActive()).thenReturn(true);
when(sakuliProperties.isLoadJavaScriptEngine()).thenReturn(true);
testling.init(testCaseId, ".");
verify(exceptionHandler, never()).handleException(any(Exception.class));
verify(session).setVariable(SahiProxyProperties.SAHI_REQUEST_DELAY_ACTIVE_VAR, "true");
}
use of org.sakuli.datamodel.TestCase 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.datamodel.TestCase in project sakuli by ConSol.
the class TestSuiteHelperTest method testInit.
@Test
public void testInit() throws Throwable {
TestSuiteProperties testProps = TestSuitePropertiesTestUtils.getTestProps(this.getClass(), "valid", "suite_id_001");
HashMap<String, TestCase> result = TestSuiteHelper.loadTestCases(testProps);
assertEquals(1, result.size());
//tests if onyl the valid testcase are in the suite, with there right names
TestCase tc = result.values().iterator().next();
assertEquals("http://localhost:8080", tc.getStartUrl());
assertEquals(tc.getName(), "validTestCase");
assertEquals(tc.getId(), "validTestCase");
assertEquals(tc.getId(), result.keySet().iterator().next());
}
use of org.sakuli.datamodel.TestCase in project sakuli by ConSol.
the class SakuliExceptionHandlerTest method testContainsExceptionsStep.
@Test
public void testContainsExceptionsStep() throws Exception {
TestSuite ts = new TestSuite();
TestCase tc = new TestCase(null, null);
ts.addTestCase(tc);
TestCaseStep step = new TestCaseStep();
step.addException(new SakuliException("bla3"));
tc.addStep(step);
assertTrue(SakuliExceptionHandler.containsException(ts));
}
use of org.sakuli.datamodel.TestCase in project sakuli by ConSol.
the class TestCaseExampleBuilder method buildExample.
@Override
public TestCase buildExample() {
TestCase testCase = new TestCase(name, id);
testCase.setState(state);
testCase.setStartDate(startDate);
testCase.setStopDate(stopDate);
testCase.setWarningTime(warningTime);
testCase.setCriticalTime(criticalTime);
testCase.addException(exception);
testCase.setTcFile(testCaseFile);
testCase.setStartUrl(startURL);
testCase.setLastURL(lastURL);
testCase.setSteps(steps);
if (creationDate != null) {
testCase.setCreationDate(creationDate);
}
return testCase;
}
Aggregations