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.core.nosqldb;
23 import org.openecomp.core.nosqldb.api.NoSqlDb;
26 public class NoSqlDbTest {
28 private NoSqlDb noSqlDb;
32 public void testNoSqlDbFactoryFactoryInit() {
33 this.noSqlDb = NoSqlDbFactory.getInstance().createInterface();
34 Assert.assertNotNull(this.noSqlDb);
35 Assert.assertEquals(this.noSqlDb.getClass().getName(),
36 "org.openecomp.core.nosqldb.impl.cassandra.CassandraNoSqlDbImpl");
39 @Test(dependsOnMethods = {"testNoSqlDbFactoryFactoryInit"})
40 public void testCreateTable() {
41 this.noSqlDb.execute("test.drop", null);
42 this.noSqlDb.execute("test.create", null);
45 @Test(dependsOnMethods = {"testCreateTable"})
46 public void testInsertTable() {
48 .insert("test", new String[]{"name", "value"}, new String[]{"TestName", "testValue"});
49 this.noSqlDb.execute("test.insert", new String[]{"TestName2", "testValue2"});
52 @Test(dependsOnMethods = {"testInsertTable"})
53 public void gettestSelectTable() {
54 ResultSet result = this.noSqlDb.execute("test.select.all", null);
55 List<Row> rows = result.all();
56 Assert.assertEquals(rows.size(), 2);
57 for (Row row : rows) {
58 System.out.format("%s %s\n", row.getString("name"), row.getString("value"));