c9954a6909df81897dfb5b4deb4e1acb9b80588b
[portal.git] / ecomp-portal-BE-common-test / src / main / java / org / openecomp / portalapp / portal / test / core / RemoveSampleTestData.java
1 /*-
2  * ================================================================================
3  * ECOMP Portal
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
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
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  * ================================================================================
19  */
20 package org.openecomp.portalapp.portal.test.core;
21
22 import java.sql.Connection;
23 import java.sql.SQLException;
24
25 import javax.sql.DataSource;
26
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;
34
35 public class RemoveSampleTestData extends ApplicationCommonContextTestSuite {
36         @Autowired
37         DataSource dataSource;
38
39         public static int count = 0;
40
41         @After
42         public void removeTestData() throws SQLException {
43                 String sql = "RemoveTestData.sql";
44                 createConnection(sql);
45         }
46
47         public void createConnection(String sql) {
48                 Connection connection = null;
49                 ResourceDatabasePopulator populator = new ResourceDatabasePopulator();
50                 populator.addScript(new ClassPathResource(sql));
51                 try {
52                         connection = DataSourceUtils.getConnection(dataSource);
53                         populator.populate(connection);
54                 } finally {
55                         if (connection != null) {
56                                 DataSourceUtils.releaseConnection(connection, dataSource);
57                         }
58                 }
59         }
60
61         @Test
62         public void removeTest() {
63                 assert (true);
64         }
65 }