Search in sources :

Example 1 with AbstractCondition

use of com.consol.citrus.condition.AbstractCondition in project camelinaction2 by camelinaction.

the class CitrusIT method stopAndWaitForGracefulShutdown.

/**
 * Stop and wait for graceful shutdown of Camel context before closing the test.
 */
private void stopAndWaitForGracefulShutdown() {
    // stop the Camel context with custom test action.
    action(new AbstractTestAction() {

        @Override
        public void doExecute(TestContext context) {
            try {
                orderService.stop();
            } catch (Exception e) {
                throw new CitrusRuntimeException("Failed to stop Camel context");
            }
        }
    });
    waitFor().condition(new AbstractCondition() {

        @Override
        public boolean isSatisfied(TestContext context) {
            return orderService.isStopped();
        }

        @Override
        public String getSuccessMessage(TestContext context) {
            return "Successfully stopped Camel context";
        }

        @Override
        public String getErrorMessage(TestContext context) {
            return "Failed to stop Camel context";
        }
    });
}
Also used : AbstractTestAction(com.consol.citrus.actions.AbstractTestAction) TestContext(com.consol.citrus.context.TestContext) CitrusRuntimeException(com.consol.citrus.exceptions.CitrusRuntimeException) AbstractCondition(com.consol.citrus.condition.AbstractCondition) CitrusRuntimeException(com.consol.citrus.exceptions.CitrusRuntimeException)

Aggregations

AbstractTestAction (com.consol.citrus.actions.AbstractTestAction)1 AbstractCondition (com.consol.citrus.condition.AbstractCondition)1 TestContext (com.consol.citrus.context.TestContext)1 CitrusRuntimeException (com.consol.citrus.exceptions.CitrusRuntimeException)1