Class FlowableAppRule

  • All Implemented Interfaces:
    org.junit.rules.TestRule

    public class FlowableAppRule
    extends Object
    implements org.junit.rules.TestRule
    Convenience for AppEngine and services initialization in the form of a JUnit rule.

    Usage:

     public class YourTest {
     
       @Rule
       public FlowableAppRule flowableRule = new FlowableAppRule();
       
       ...
     }
     

    The AppEngine and the services will be made available to the test class through the getters of the FlowableAppRule. The appEngine will be initialized by default with the flowable.cfg.xml resource on the classpath. To specify a different configuration file, pass the resource location in the appropriate constructor. App engines will be cached statically. Right before the first time the setUp is called for a given configuration resource, the app engine will be constructed.

    You can declare a deployment with the AppDeployment annotation. This base class will make sure that this deployment gets deployed before the setUp and cascade deleted after the tearDown.

    The FlowableRule also lets you set the current time used by the process engine. This can be handy to control the exact time that is used by the engine in order to verify e.g. due dates of timers. Or start, end and duration times in the history service. In the tearDown, the internal clock will automatically be reset to use the current system time rather then the time that was set during a test method.

    Author:
    Tom Baeyens
    • Constructor Detail

      • FlowableAppRule

        public FlowableAppRule()
      • FlowableAppRule

        public FlowableAppRule​(String configurationResource)
      • FlowableAppRule

        public FlowableAppRule​(AppEngine appEngine)
    • Method Detail

      • apply

        public org.junit.runners.model.Statement apply​(org.junit.runners.model.Statement base,
                                                       org.junit.runner.Description description)
        Implementation based on TestWatcher.
        Specified by:
        apply in interface org.junit.rules.TestRule
      • succeeded

        protected void succeeded​(org.junit.runner.Description description)
        Invoked when a test succeeds
      • failed

        protected void failed​(Throwable e,
                              org.junit.runner.Description description)
        Invoked when a test fails
      • skipped

        protected void skipped​(org.junit.internal.AssumptionViolatedException e,
                               org.junit.runner.Description description)
        Invoked when a test is skipped due to a failed assumption.
      • starting

        protected void starting​(org.junit.runner.Description description)
      • initializeAppEngine

        protected void initializeAppEngine()
      • initializeServices

        protected void initializeServices()
      • configureAppEngine

        protected void configureAppEngine()
      • finished

        protected void finished​(org.junit.runner.Description description)
      • setCurrentTime

        public void setCurrentTime​(Date currentTime)
      • getConfigurationResource

        public String getConfigurationResource()
      • setConfigurationResource

        public void setConfigurationResource​(String configurationResource)
      • getAppEngine

        public AppEngine getAppEngine()
      • setAppEngine

        public void setAppEngine​(AppEngine appEngine)