diff options
author | 2018-11-26 22:42:22 -0500 | |
---|---|---|
committer | 2018-11-26 22:43:36 -0500 | |
commit | 76d8bc46fdf9b36548dff46b9d1c91bf7c56f6ac (patch) | |
tree | c6fce094636967a40b80d5075464265758392069 /mdbc-server/src/test | |
parent | 73c29e3fd2cd218906744987e6ae683d77b092b9 (diff) |
MySQL JUnit test
and code cleanup, renaming variable for clarity, updating stale interfaces
Change-Id: I766267c442b7b037b41fe9f2f33092a1c01669ca
Issue-ID: MUSIC-205
Signed-off-by: Tschaen, Brendan <ctschaen@att.com>
Diffstat (limited to 'mdbc-server/src/test')
-rw-r--r-- | mdbc-server/src/test/java/org/onap/music/mdbc/MySQLMixinTest.java | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/mdbc-server/src/test/java/org/onap/music/mdbc/MySQLMixinTest.java b/mdbc-server/src/test/java/org/onap/music/mdbc/MySQLMixinTest.java new file mode 100644 index 0000000..458f70f --- /dev/null +++ b/mdbc-server/src/test/java/org/onap/music/mdbc/MySQLMixinTest.java @@ -0,0 +1,80 @@ +/* + * ============LICENSE_START==================================================== + * org.onap.music.mdbc + * ============================================================================= + * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. + * ============================================================================= + * 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. + * ============LICENSE_END====================================================== + */ +package org.onap.music.mdbc; + +import static org.junit.Assert.*; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.SQLException; + +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.onap.music.mdbc.mixins.MySQLMixin; + +import ch.vorburger.mariadb4j.DB; + +public class MySQLMixinTest { + + public static final String DATABASE = "mdbcTest"; + public static final String TABLE= "Persons"; + public static final String CREATE_TABLE = "CREATE TABLE IF NOT EXISTS " + TABLE + " (\n" + + " PersonID int,\n" + + " LastName varchar(255),\n" + + " FirstName varchar(255),\n" + + " Address varchar(255),\n" + + " City varchar(255),\n" + + " PRIMARY KEY (PersonID,LastName)" + + ");"; + + + Connection conn; + MySQLMixin mysqlMixin; + + + + @BeforeClass + public static void init() throws Exception { + Class.forName("org.mariadb.jdbc.Driver"); + //start embedded mariadb + DB db = DB.newEmbeddedDB(13306); + db.start(); + db.createDB(DATABASE); + } + + @AfterClass + public static void close() throws Exception { + + } + + @Before + public void beforeTest() throws SQLException { + this.conn = DriverManager.getConnection("jdbc:mariadb://localhost:13306/"+DATABASE, "root", ""); + this.mysqlMixin = new MySQLMixin(null, "localhost:13306/"+DATABASE, conn, null); + } + + @Test + public void testGetDataBaseName() throws SQLException { + assertEquals(DATABASE, mysqlMixin.getDatabaseName()); + } + +} |