/* 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.camunda.bpm.engine.impl.test;

import java.util.Map;

import org.camunda.bpm.engine.ProcessEngine;
import org.camunda.bpm.engine.ProcessEngineConfiguration;


/** Base class for the process engine test cases.
 * 
 * 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 
 * on the test support classes that we offer as part of our api (in org.camunda.bpm.engine.test).
 * 
 * @author Tom Baeyens
 * @author Joram Barrez
 */
public class PluggableProcessEngineTestCase extends AbstractProcessEngineTestCase {
  
  protected static ProcessEngine cachedProcessEngine;

  protected void initializeProcessEngine() {    
    processEngine = getOrInitializeCachedProcessEngine();
    Map<String, Long> tableCount = processEngine.getManagementService().getTableCount();
    if(tableCount.get("ACT_GE_PROPERTY") == 3) {
      throw new RuntimeException(processEngine.getManagementService().getProperties().toString());
    }
  }

  private static ProcessEngine getOrInitializeCachedProcessEngine() {
    if (cachedProcessEngine == null) {
      cachedProcessEngine = ProcessEngineConfiguration
              .createProcessEngineConfigurationFromResource("activiti.cfg.xml")
              .buildProcessEngine();
    }
    return cachedProcessEngine;
  }
  
  public static ProcessEngine getProcessEngine() {
    return getOrInitializeCachedProcessEngine();
  }
  
  
}
@@ -603,31 +603,8 @@
 t;%0A%0A
-import java.util.Map;%0A%0A
 impo
@@ -1568,251 +1568,8 @@
 ();%0A
-    Map%3CString, Long%3E tableCount = processEngine.getManagementService().getTableCount();%0A    if(tableCount.get(%22ACT_GE_PROPERTY%22) == 3) %7B%0A      throw new RuntimeException(processEngine.getManagementService().getProperties().toString());%0A    %7D%0A
   %7D%0A

remove unnecessary check