2 * ================================================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property
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 * ================================================================================
20 package org.openecomp.portalapp.portal.test.core;
22 import java.sql.Connection;
23 import java.sql.SQLException;
25 import javax.sql.DataSource;
27 import org.junit.After;
28 import org.junit.Test;
29 import org.openecomp.portalapp.test.framework.ApplicationCommonContextTestSuite;
30 import org.springframework.beans.factory.annotation.Autowired;
31 import org.springframework.core.io.ClassPathResource;
32 import org.springframework.jdbc.datasource.DataSourceUtils;
33 import org.springframework.jdbc.datasource.init.ResourceDatabasePopulator;
35 public class RemoveSampleTestData extends ApplicationCommonContextTestSuite {
37 DataSource dataSource;
39 public static int count = 0;
42 public void removeTestData() throws SQLException {
43 String sql = "RemoveTestData.sql";
44 createConnection(sql);
47 public void createConnection(String sql) {
48 Connection connection = null;
49 ResourceDatabasePopulator populator = new ResourceDatabasePopulator();
50 populator.addScript(new ClassPathResource(sql));
52 connection = DataSourceUtils.getConnection(dataSource);
53 populator.populate(connection);
55 if (connection != null) {
56 DataSourceUtils.releaseConnection(connection, dataSource);
62 public void removeTest() {