Class TestCaseRunner
java.lang.Object
ch.admin.bit.jeap.testorchestrator.testsupport.TestCaseRunner
- All Implemented Interfaces:
org.springframework.context.ApplicationEventPublisher
public class TestCaseRunner
extends Object
implements org.springframework.context.ApplicationEventPublisher
Support class for running test cases in unit tests. Test cases can be run without starting up a Spring context.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.context.ApplicationEventPublisherGet the ApplicationEventPublisher instance to be used by the test case instance run by this runner.Get the callback URL provided to the test case by the test runner.Get the the test id assigned to this test case run.booleanCheck if the test case run has finished.voidnotify(ch.admin.bit.jeap.testagent.api.notification.NotificationDto notificationDto) Publish the given notification as NotificationEvent to the test case run by this test case runner.voidnotifyAsync(ch.admin.bit.jeap.testagent.api.notification.NotificationDto notificationDto, long delay, TimeUnit unit) Publish the given notification asynchronously after the given delay as NotificationEvent to the test case run by this test case runner.voidpublishEvent(Object event) Spring application event publishing implementation provided to the test case run by this runner to receive the test case events.voidrun(TestCaseBaseInterface testCase) Run the given test case.runAsync(TestCaseBaseInterface testCase) Run the given test case asynchronously with support for asynchronous notifications.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.context.ApplicationEventPublisher
publishEvent
-
Constructor Details
-
TestCaseRunner
public TestCaseRunner()
-
-
Method Details
-
run
Run the given test case. Can only be called once on a TestCaseRunner instance. Does not support asynchronous notifications.- Parameters:
testCase- The test case to run.
-
runAsync
Run the given test case asynchronously with support for asynchronous notifications. Can only be called once on a TestCaseRunner instance. Use this run method if your tests needs asynchronous notifications.- Parameters:
testCase- The test case to run.
-
hasFinished
public boolean hasFinished()Check if the test case run has finished.- Returns:
trueif the test case run has finished,falseotherwise.
-
getTestId
Get the the test id assigned to this test case run.- Returns:
- the test id assigned to this test case run
-
getCallbackUrl
Get the callback URL provided to the test case by the test runner.- Returns:
- the callback URL provided to the test case by the test runner.
-
getApplicationEventPublisher
public org.springframework.context.ApplicationEventPublisher getApplicationEventPublisher()Get the ApplicationEventPublisher instance to be used by the test case instance run by this runner. Test cases communicate with the TestCaseService by publishing Spring application events. A test case run by this test case runner must use this ApplicationEventPublisher for the test case runner to be able to react on the events.- Returns:
- The ApplicationEventPublisher instance to be used by the test case instance run by this runner.
-
notify
public void notify(ch.admin.bit.jeap.testagent.api.notification.NotificationDto notificationDto) Publish the given notification as NotificationEvent to the test case run by this test case runner. Test cases listen to notification events initiated by the test agents. Use this method to simulate the test agent callbacks to the test orchestrator that result in such notification events.- Parameters:
notificationDto- The notification.
-
notifyAsync
public void notifyAsync(ch.admin.bit.jeap.testagent.api.notification.NotificationDto notificationDto, long delay, TimeUnit unit) Publish the given notification asynchronously after the given delay as NotificationEvent to the test case run by this test case runner.- Parameters:
notificationDto- The notification.- See Also:
-
publishEvent
Spring application event publishing implementation provided to the test case run by this runner to receive the test case events.- Specified by:
publishEventin interfaceorg.springframework.context.ApplicationEventPublisher
-