PluggableActivitiTestCase.java 2.2 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
/* Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.activiti5.engine.impl.test;

16 17 18
import org.activiti.engine.ActivitiException;
import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngines;
19 20 21
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

22 23

/** Base class for the activiti test cases.
24
 * 
25 26 27 28 29
 * The main reason not to use our own test support classes is that we need to 
 * run our test suite with various configurations, e.g. with and without spring,
 * standalone or on a server etc.  Those requirements create some complications 
 * so we think it's best to use a separate base class.  That way it is much easier 
 * for us to maintain our own codebase and at the same time provide stability 
30
 * on the test support classes that we offer as part of our api (in org.activiti5.engine.test).
31 32 33 34 35
 * 
 * @author Tom Baeyens
 * @author Joram Barrez
 */
public abstract class PluggableActivitiTestCase extends AbstractActivitiTestCase {
36
  
37
  private static Logger pluggableActivitiTestCaseLogger = LoggerFactory.getLogger(PluggableActivitiTestCase.class);
38
  
39
  protected static ProcessEngine cachedProcessEngine;
T
Tijs Rademakers 已提交
40

41 42
  protected void initializeProcessEngine() {
    if (cachedProcessEngine == null) {
43
      
44
      pluggableActivitiTestCaseLogger.info("No cached process engine found for test. Retrieving the default engine.");
45 46
      ProcessEngines.destroy(); // Just to be sure we're not getting any previously cached version
      
47
      cachedProcessEngine = ProcessEngines.getDefaultProcessEngine();
48
      if (cachedProcessEngine==null) {
49 50
        throw new ActivitiException("no default process engine available");
      }
51
    }
52 53
    processEngine = cachedProcessEngine;
  }
54
}