2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.openecomp.mso.bpmn.test;
23 import java.sql.Connection;
24 import java.sql.DriverManager;
25 import java.sql.PreparedStatement;
26 import java.sql.SQLException;
29 * Sets up the unit test (H2) database for Camunda.
31 public class CamundaDBSetup {
32 private static boolean isDBConfigured = false;
34 public static synchronized void configure() throws SQLException {
39 System.out.println("Configuring the Camunda H2 database for MSO");
41 Connection connection = null;
42 PreparedStatement stmt = null;
45 connection = DriverManager.getConnection(
46 "jdbc:h2:mem:camunda;DB_CLOSE_DELAY=-1", "sa", "");
48 stmt = connection.prepareStatement("delete from ACT_HI_VARINST");
53 stmt = connection.prepareStatement("ALTER TABLE ACT_HI_VARINST alter column TEXT_ clob");
58 stmt = connection.prepareStatement("ALTER TABLE ACT_HI_VARINST alter column NAME_ clob");
63 stmt = connection.prepareStatement("delete from ACT_HI_DETAIL");
68 stmt = connection.prepareStatement("ALTER TABLE ACT_HI_DETAIL alter column TEXT_ clob");
73 stmt = connection.prepareStatement("ALTER TABLE ACT_HI_DETAIL alter column NAME_ clob");
78 stmt = connection.prepareStatement("ALTER TABLE ACT_RU_VARIABLE alter column TEXT_ clob");
86 isDBConfigured = true;
87 } catch (SQLException e) {
88 System.out.println("CamundaDBSetup caught " + e.getClass().getSimpleName());
94 } catch (Exception e) {
99 if (connection != null) {
102 } catch (Exception e) {