aboutsummaryrefslogtreecommitdiffstats
path: root/dblib/provider/src/test/java/org/onap/ccsdk/sli/core/dblib/TestDBResourceManager.java
blob: dca07921b78988b6ce44f3b6e67f6c23acaddd13 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package org.onap.ccsdk.sli.core.dblib;

import static org.junit.Assert.*;

import java.io.InputStream;
import java.net.URL;
import java.util.Properties;

import org.junit.Before;
import org.junit.Test;

import ch.vorburger.mariadb4j.DB;
import ch.vorburger.mariadb4j.DBConfigurationBuilder;

public class TestDBResourceManager {

	DbLibService dblibSvc;

	@Before
	public void setUp() throws Exception {
		URL propUrl = getClass().getResource("/dblib.properties");

		InputStream propStr = getClass().getResourceAsStream("/dblib.properties");

		Properties props = new Properties();

		props.load(propStr);


		// Start MariaDB4j database
		DBConfigurationBuilder config = DBConfigurationBuilder.newBuilder();
		config.setPort(0); // 0 => autom. detect free port
		DB db = DB.newEmbeddedDB(config.build());
		db.start();


		// Override jdbc URL and database name
		props.setProperty("org.onap.ccsdk.sli.jdbc.database", "test");
		props.setProperty("org.onap.ccsdk.sli.jdbc.url", config.getURL("test"));


		dblibSvc = new DBResourceManager(props);

		dblibSvc.writeData("CREATE TABLE DBLIB_TEST (name varchar(20));", null, null);
		dblibSvc.getData("SELECT * FROM DBLIB_TEST", null, null);

	}

	@Test
	public void test() {


	}

}