BAEL-7259

This commit is contained in:
parthiv39731 2023-11-27 10:27:27 +05:30
parent 7284c7462c
commit 1a63be9035
3 changed files with 89 additions and 104 deletions

View File

@ -14,17 +14,20 @@ import java.io.IOException;
import java.util.Base64; import java.util.Base64;
public class HarperDBApiService { public class HarperDBApiService {
private static final Logger LOGGER = LoggerFactory.getLogger(HarperDBApiService.class);
private String url; private String url;
private String base64auth; private String base64auth;
public HarperDBApiService(String url, String user, String password) { public HarperDBApiService(String url, String user, String password) {
this.url = url; this.url = url;
this.base64auth = Base64.getEncoder() this.base64auth = Base64.getEncoder()
.encodeToString(new StringBuilder().append(user).append(":").append(password).toString().getBytes()); .encodeToString(new StringBuilder().append(user)
.append(":")
.append(password)
.toString()
.getBytes());
} }
private static final Logger LOGGER = LoggerFactory.getLogger(HarperDBApiService.class);
public void createSchema(String schema) throws IOException { public void createSchema(String schema) throws IOException {
String requestBody = "{\"operation\":\"create_schema\", \"" + "schema\":\"" + schema + "\"" + "}"; String requestBody = "{\"operation\":\"create_schema\", \"" + "schema\":\"" + schema + "\"" + "}";
executeHttpPostRequest(requestBody); executeHttpPostRequest(requestBody);
@ -32,18 +35,18 @@ public class HarperDBApiService {
public void createTable(String schema, String table, String ... attributes) throws IOException { public void createTable(String schema, String table, String ... attributes) throws IOException {
String createTableReq = "{\"operation\":\"create_table\"," String createTableReq = "{\"operation\":\"create_table\","
+ "\"schema\":\"" + schema + "\"schema\":\"" + schema
+ "\",\"table\":\"" + table + "\",\"table\":\"" + table
+ "\",\"hash_attribute\":\"id\"" + "\",\"hash_attribute\":\"id\""
+ "}"; + "}";
executeHttpPostRequest(createTableReq); executeHttpPostRequest(createTableReq);
LOGGER.info("created table:" + table); LOGGER.info("created table:" + table);
for (String attribute : attributes) { for (String attribute : attributes) {
String createAttrReq = "{\"operation\":\"create_attribute\",\"schema\":\"" String createAttrReq = "{\"operation\":\"create_attribute\",\"schema\":\""
+ schema + "\",\"table\":\"" + schema + "\",\"table\":\""
+ table + "\",\"attribute\":\"" + table + "\",\"attribute\":\""
+ attribute + "\"" + attribute + "\""
+ "}"; + "}";
executeHttpPostRequest(createAttrReq); executeHttpPostRequest(createAttrReq);
LOGGER.info("created attribute:" + attribute + " in table:" + table); LOGGER.info("created attribute:" + attribute + " in table:" + table);
} }
@ -51,24 +54,25 @@ public class HarperDBApiService {
public void insertRecords(String schema, String table, String records) throws IOException { public void insertRecords(String schema, String table, String records) throws IOException {
String requestBody = "{\"table\":" + "\"" + table + "\"," String requestBody = "{\"table\":" + "\"" + table + "\","
+ "\"schema\":" + "\"" + schema + "\"" + "," + "\"schema\":" + "\"" + schema + "\"" + ","
+ "\"operation\":" + "\"" + "insert" + "\"" + "," + "\"operation\":" + "\"" + "insert" + "\"" + ","
+ "\"records\":" + records + "\"records\":" + records
+ "}"; + "}";
executeHttpPostRequest(requestBody); executeHttpPostRequest(requestBody);
} }
private void executeHttpPostRequest(String httpRequest) throws IOException { private void executeHttpPostRequest(String httpRequest) throws IOException {
LOGGER.info("Post request body:" + httpRequest); LOGGER.info("Post request body:" + httpRequest);
try (CloseableHttpClient closeableHttpClient = HttpClientBuilder.create().build()) { try (CloseableHttpClient closeableHttpClient = HttpClientBuilder.create()
.build()) {
HttpPost request = new HttpPost(this.url); HttpPost request = new HttpPost(this.url);
request.addHeader("Authorization", "Basic " + this.base64auth); request.addHeader("Authorization", "Basic " + this.base64auth);
request.addHeader("Content-Type", "application/json"); request.addHeader("Content-Type", "application/json");
request.setEntity((HttpEntity) new StringEntity(httpRequest)); request.setEntity((HttpEntity) new StringEntity(httpRequest));
CloseableHttpResponse response = closeableHttpClient.execute((ClassicHttpRequest) request); CloseableHttpResponse response = closeableHttpClient.execute((ClassicHttpRequest) request);
LOGGER.info("REST API response:" + response.toString()); LOGGER.info("REST API response:" + response.toString());
assert(200 == response.getCode()); assert (200 == response.getCode());
} }
} }
} }

View File

@ -1,42 +1,36 @@
package com.baledung.harperdb; package com.baledung.harperdb;
import java.util.Map;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.testcontainers.containers.GenericContainer; import org.testcontainers.containers.GenericContainer;
import java.util.Map;
public class HarperDBContainer { public class HarperDBContainer {
private final static Logger LOGGER = LoggerFactory.getLogger(HarperDBContainer.class); private final static Logger LOGGER = LoggerFactory.getLogger(HarperDBContainer.class);
private static final Map<String, String> DEFAULT_ENV_MAP = Map.of("HDB_ADMIN_USERNAME", "admin", "HDB_ADMIN_PASSWORD", "password",
"OPERATIONSAPI_NETWORK_PORT", "9925", "ROOTPATH", "/home/harperdb/hdb", "LOGGING_STDSTREAMS", "true");
private static final Integer[] DEFAULT_EXPOSED_PORTS = { 9925, 9926 };
private static final Map<String, String> DEFAULT_ENV_MAP = Map.of(
"HDB_ADMIN_USERNAME", "admin",
"HDB_ADMIN_PASSWORD", "password",
"OPERATIONSAPI_NETWORK_PORT", "9925",
"ROOTPATH", "/home/harperdb/hdb",
"LOGGING_STDSTREAMS", "true"
);
private static final Integer[] DEFAULT_EXPOSED_PORTS = {9925, 9926};
private static final String HARPER_DOCKER_IMAGE = "harperdb/harperdb:latest"; private static final String HARPER_DOCKER_IMAGE = "harperdb/harperdb:latest";
public void stop() { public void stop() {
harperDBContainer.stop(); harperDBContainer.stop();
} }
GenericContainer harperDBContainer; GenericContainer harperDBContainer;
public GenericContainer installHarperDB() { public GenericContainer installHarperDB() {
harperDBContainer = new GenericContainer(HARPER_DOCKER_IMAGE) harperDBContainer = new GenericContainer(HARPER_DOCKER_IMAGE).withEnv(DEFAULT_ENV_MAP)
.withEnv(DEFAULT_ENV_MAP) .withExposedPorts(DEFAULT_EXPOSED_PORTS);
.withExposedPorts(DEFAULT_EXPOSED_PORTS);
return harperDBContainer; return harperDBContainer;
} }
public GenericContainer installHarperDB(String dockerImgage, final Map<String, String> envMap, final Integer ... exposedPorts) { public GenericContainer installHarperDB(String dockerImgage, final Map<String, String> envMap, final Integer... exposedPorts) {
return new GenericContainer(dockerImgage) return new GenericContainer(dockerImgage).withEnv(envMap)
.withEnv(envMap) .withExposedPorts(exposedPorts);
.withExposedPorts(exposedPorts);
} }
} }

View File

@ -1,6 +1,7 @@
package com.baledung.harperdb; package com.baledung.harperdb;
import cdata.jdbc.harperdb.HarperDBConnectionPoolDataSource; import cdata.jdbc.harperdb.HarperDBConnectionPoolDataSource;
import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
@ -16,6 +17,7 @@ import java.util.Properties;
import static org.junit.jupiter.api.Assertions.*; import static org.junit.jupiter.api.Assertions.*;
public class HarperDBLiveTest { public class HarperDBLiveTest {
private static final Logger logger = LoggerFactory.getLogger(HarperDBLiveTest.class); private static final Logger logger = LoggerFactory.getLogger(HarperDBLiveTest.class);
private static String host; private static String host;
@ -61,40 +63,27 @@ public class HarperDBLiveTest {
} }
private static void insertSubjectRecords() throws IOException { private static void insertSubjectRecords() throws IOException {
String records = "[" String records = "[" + "{\"id\":1, \"name\":\"English\"}," + "{\"id\":2, \"name\":\"Maths\"}," + "{\"id\":3, \"name\":\"Science\"}" + "]";
+ "{\"id\":1, \"name\":\"English\"},"
+ "{\"id\":2, \"name\":\"Maths\"},"
+ "{\"id\":3, \"name\":\"Science\"}"
+ "]";
harperDbApiService.insertRecords("Demo", "Subject", records); harperDbApiService.insertRecords("Demo", "Subject", records);
} }
private static void insertTeacherRecords() throws IOException { private static void insertTeacherRecords() throws IOException {
String records = "[" + String records = "[" + "{\"id\":1, \"name\":\"Parthiv Pradhan\", \"joining_date\":\"04-05-2000\"}," +
"{\"id\":1, \"name\":\"Parthiv Pradhan\", \"joining_date\":\"04-05-2000\"}," "{\"id\":2, \"name\":\"David Martinez\", \"joining_date\":\"20-10-2005\"}," +
+ "{\"id\":2, \"name\":\"David Martinez\", \"joining_date\":\"20-10-2005\"}," "{\"id\":3, \"name\":\"Liam Williams\", \"joining_date\":\"04-06-1997\"}," +
+ "{\"id\":3, \"name\":\"Liam Williams\", \"joining_date\":\"04-06-1997\"}," "{\"id\":4, \"name\":\"Robin Williams\", \"joining_date\":\"01-01-2020\"}," +
+ "{\"id\":4, \"name\":\"Robin Williams\", \"joining_date\":\"01-01-2020\"}," "{\"id\":5, \"name\":\"Eric Martin\", \"joining_date\":\"04-05-2022\"}," +
+ "{\"id\":5, \"name\":\"Eric Martin\", \"joining_date\":\"04-05-2022\"}," "{\"id\":6, \"name\":\"Sajjan Nagendra\", \"joining_date\":\"02-02-1999\"}" + "]";
+ "{\"id\":6, \"name\":\"Sajjan Nagendra\", \"joining_date\":\"02-02-1999\"}"
+ "]";
harperDbApiService.insertRecords("Demo", "Teacher", records); harperDbApiService.insertRecords("Demo", "Teacher", records);
} }
private static void insertTeacherDetailsRecords() throws IOException { private static void insertTeacherDetailsRecords() throws IOException {
String records = "[" String records = "[" + "{\"id\":1, \"teacher_id\":1, \"subject_id\":1}," + "{\"id\":2, \"teacher_id\":1, \"subject_id\":2}," +
+ "{\"id\":1, \"teacher_id\":1, \"subject_id\":1}," "{\"id\":3, \"teacher_id\":2, \"subject_id\":3 }," + "{\"id\":4, \"teacher_id\":3, \"subject_id\":1}," +
+ "{\"id\":2, \"teacher_id\":1, \"subject_id\":2}," "{\"id\":5, \"teacher_id\":3, \"subject_id\":3}," + "{\"id\":6, \"teacher_id\":4, \"subject_id\":2}," +
+ "{\"id\":3, \"teacher_id\":2, \"subject_id\":3 }," "{\"id\":7, \"teacher_id\":5, \"subject_id\":3}," + "{\"id\":8, \"teacher_id\":6, \"subject_id\":1}," +
+ "{\"id\":4, \"teacher_id\":3, \"subject_id\":1}," "{\"id\":9, \"teacher_id\":6, \"subject_id\":2}," + "{\"id\":15, \"teacher_id\":6, \"subject_id\":3}" + "]";
+ "{\"id\":5, \"teacher_id\":3, \"subject_id\":3},"
+ "{\"id\":6, \"teacher_id\":4, \"subject_id\":2},"
+ "{\"id\":7, \"teacher_id\":5, \"subject_id\":3},"
+ "{\"id\":8, \"teacher_id\":6, \"subject_id\":1},"
+ "{\"id\":9, \"teacher_id\":6, \"subject_id\":2},"
+ "{\"id\":15, \"teacher_id\":6, \"subject_id\":3}"
+ "]";
harperDbApiService.insertRecords("Demo", "Teacher_Details", records); harperDbApiService.insertRecords("Demo", "Teacher_Details", records);
} }
@ -110,7 +99,8 @@ public class HarperDBLiveTest {
final String JDBC_URL = "jdbc:harperdb:Server=127.0.0.1:" + port + ";User=admin;Password=password;"; final String JDBC_URL = "jdbc:harperdb:Server=127.0.0.1:" + port + ";User=admin;Password=password;";
try (Connection connection = DriverManager.getConnection(JDBC_URL)) { try (Connection connection = DriverManager.getConnection(JDBC_URL)) {
connection.createStatement().executeQuery("select 1"); connection.createStatement()
.executeQuery("select 1");
logger.info("Connection Successful"); logger.info("Connection Successful");
} }
}); });
@ -125,7 +115,8 @@ public class HarperDBLiveTest {
prop.setProperty("Password", "password"); prop.setProperty("Password", "password");
try (Connection connection = DriverManager.getConnection("jdbc:harperdb:", prop)) { try (Connection connection = DriverManager.getConnection("jdbc:harperdb:", prop)) {
connection.createStatement().executeQuery("select 1"); connection.createStatement()
.executeQuery("select 1");
logger.info("Connection Successful"); logger.info("Connection Successful");
} }
}); });
@ -135,12 +126,13 @@ public class HarperDBLiveTest {
void whenConnectionPooling_thenConnectSuccess() throws SQLException { void whenConnectionPooling_thenConnectSuccess() throws SQLException {
assertDoesNotThrow(() -> { assertDoesNotThrow(() -> {
HarperDBConnectionPoolDataSource harperdbPoolDataSource = new HarperDBConnectionPoolDataSource(); HarperDBConnectionPoolDataSource harperdbPoolDataSource = new HarperDBConnectionPoolDataSource();
final String JDBC_URL = "jdbc:harperdb:UseConnectionPooling=true;PoolMaxSize=2;Server=127.0.0.1:" + port final String JDBC_URL = "jdbc:harperdb:UseConnectionPooling=true;PoolMaxSize=2;Server=127.0.0.1:" + port + ";User=admin;Password=password;";
+ ";User=admin;Password=password;";
harperdbPoolDataSource.setURL(JDBC_URL); harperdbPoolDataSource.setURL(JDBC_URL);
try(Connection connection = harperdbPoolDataSource.getPooledConnection().getConnection()) { try (Connection connection = harperdbPoolDataSource.getPooledConnection()
connection.createStatement().executeQuery("select 1"); .getConnection()) {
connection.createStatement()
.executeQuery("select 1");
logger.info("Connection Pool Successful"); logger.info("Connection Pool Successful");
} }
}); });
@ -155,7 +147,7 @@ public class HarperDBLiveTest {
void givenStatement_whenFetchRecord_thenSuccess() throws SQLException { void givenStatement_whenFetchRecord_thenSuccess() throws SQLException {
final String SQL_QUERY = "select id, name, grade from Demo.student"; final String SQL_QUERY = "select id, name, grade from Demo.student";
try(Connection connection = getConnection()) { try (Connection connection = getConnection()) {
Statement statement = connection.createStatement(); Statement statement = connection.createStatement();
ResultSet resultSet = statement.executeQuery(SQL_QUERY); ResultSet resultSet = statement.executeQuery(SQL_QUERY);
while (resultSet.next()) { while (resultSet.next()) {
@ -172,7 +164,7 @@ public class HarperDBLiveTest {
void givenStatement_whenInsertRecord_thenSuccess() throws SQLException { void givenStatement_whenInsertRecord_thenSuccess() throws SQLException {
final String INSERT_SQL = "insert into Demo.student(id, name, grade) values (10, 'Barak', 3)"; final String INSERT_SQL = "insert into Demo.student(id, name, grade) values (10, 'Barak', 3)";
try(Connection connection = getConnection()) { try (Connection connection = getConnection()) {
Statement statement = connection.createStatement(); Statement statement = connection.createStatement();
assertDoesNotThrow(() -> statement.execute(INSERT_SQL)); assertDoesNotThrow(() -> statement.execute(INSERT_SQL));
} }
@ -180,11 +172,11 @@ public class HarperDBLiveTest {
@Test @Test
void givenStatement_whenInsertRecordInTableWithoutAttributes_thenSuccess() throws SQLException { void givenStatement_whenInsertRecordInTableWithoutAttributes_thenSuccess() throws SQLException {
final String INSERT_SQL = "insert into Demo.teacher(id, name, joining_date) " final String INSERT_SQL =
+ "values (7, 'David Sirocco', '04-05-2004'), (8, 'Ali Azmat', '04-10-2000')"; "insert into Demo.teacher(id, name, joining_date) " + "values (7, 'David Sirocco', '04-05-2004'), (8, 'Ali Azmat', '04-10-2000')";
final String QUERY_SQL = "select name, joining_date from Demo.teacher where name = ?"; final String QUERY_SQL = "select name, joining_date from Demo.teacher where name = ?";
try(Connection connection = getConnection()) { try (Connection connection = getConnection()) {
Statement statement = connection.createStatement(); Statement statement = connection.createStatement();
assertDoesNotThrow(() -> statement.execute(INSERT_SQL)); assertDoesNotThrow(() -> statement.execute(INSERT_SQL));
PreparedStatement preparedStatement = connection.prepareStatement(QUERY_SQL); PreparedStatement preparedStatement = connection.prepareStatement(QUERY_SQL);
@ -204,7 +196,7 @@ public class HarperDBLiveTest {
void givenStatement_whenUpdateRecord_thenSuccess() throws SQLException { void givenStatement_whenUpdateRecord_thenSuccess() throws SQLException {
final String UPDATE_SQL = "update Demo.student set grade = 4 where id = 5"; final String UPDATE_SQL = "update Demo.student set grade = 4 where id = 5";
try(Connection connection = getConnection()) { try (Connection connection = getConnection()) {
Statement statement = connection.createStatement(); Statement statement = connection.createStatement();
assertDoesNotThrow(() -> statement.execute(UPDATE_SQL)); assertDoesNotThrow(() -> statement.execute(UPDATE_SQL));
assertEquals(1, statement.getUpdateCount()); assertEquals(1, statement.getUpdateCount());
@ -215,7 +207,7 @@ public class HarperDBLiveTest {
void givenStatement_whenDeleteRecord_thenSuccess() throws SQLException { void givenStatement_whenDeleteRecord_thenSuccess() throws SQLException {
final String DELETE_SQL = "delete from Demo.student where id = 3"; final String DELETE_SQL = "delete from Demo.student where id = 3";
try(Connection connection = getConnection()) { try (Connection connection = getConnection()) {
Statement statement = connection.createStatement(); Statement statement = connection.createStatement();
assertDoesNotThrow(() -> statement.execute(DELETE_SQL)); assertDoesNotThrow(() -> statement.execute(DELETE_SQL));
assertEquals(1, statement.getUpdateCount()); assertEquals(1, statement.getUpdateCount());
@ -226,27 +218,27 @@ public class HarperDBLiveTest {
void givenPreparedStatement_whenFetchRecord_thenSuccess() throws SQLException { void givenPreparedStatement_whenFetchRecord_thenSuccess() throws SQLException {
final String SQL_QUERY = "select id, name, grade from Demo.student where name = ? and grade = ?"; final String SQL_QUERY = "select id, name, grade from Demo.student where name = ? and grade = ?";
try(Connection connection = getConnection()) { try (Connection connection = getConnection()) {
PreparedStatement preparedStatement = connection.prepareStatement(SQL_QUERY); PreparedStatement preparedStatement = connection.prepareStatement(SQL_QUERY);
preparedStatement.setString(1, "Robin"); preparedStatement.setString(1, "Robin");
preparedStatement.setInt(2, 4); preparedStatement.setInt(2, 4);
ResultSet resultSet = preparedStatement.executeQuery(); ResultSet resultSet = preparedStatement.executeQuery();
while (resultSet.next()) { while (resultSet.next()) {
int id = resultSet.getInt("id"); int id = resultSet.getInt("id");
String name = resultSet.getString("name"); String name = resultSet.getString("name");
int grade = resultSet.getInt("grade"); int grade = resultSet.getInt("grade");
assertNotNull(Integer.valueOf(id)); assertNotNull(Integer.valueOf(id));
assertEquals("Robin", name); assertEquals("Robin", name);
logger.info("Student id:" + id + " Student Name:" + name + " grade:" + grade); logger.info("Student id:" + id + " Student Name:" + name + " grade:" + grade);
} }
} }
} }
@Test @Test
void givenPreparedStatement_whenDeleteRecord_thenSuccess() throws SQLException { void givenPreparedStatement_whenDeleteRecord_thenSuccess() throws SQLException {
final String DELETE_SQL = "delete from Demo.student where name = ?"; final String DELETE_SQL = "delete from Demo.student where name = ?";
try(Connection connection = getConnection()) { try (Connection connection = getConnection()) {
PreparedStatement preparedStatement = connection.prepareStatement(DELETE_SQL); PreparedStatement preparedStatement = connection.prepareStatement(DELETE_SQL);
preparedStatement.setString(1, "James"); preparedStatement.setString(1, "James");
assertDoesNotThrow(() -> preparedStatement.execute()); assertDoesNotThrow(() -> preparedStatement.execute());
@ -258,7 +250,7 @@ public class HarperDBLiveTest {
void givenPreparedStatement_whenUpdateRecord_thenSuccess() throws SQLException { void givenPreparedStatement_whenUpdateRecord_thenSuccess() throws SQLException {
final String UPDATE_SQL = "update Demo.student set grade = ? where id = ? and name = ?"; final String UPDATE_SQL = "update Demo.student set grade = ? where id = ? and name = ?";
try(Connection connection = getConnection()) { try (Connection connection = getConnection()) {
PreparedStatement preparedStatement = connection.prepareStatement(UPDATE_SQL); PreparedStatement preparedStatement = connection.prepareStatement(UPDATE_SQL);
preparedStatement.setInt(1, 5); preparedStatement.setInt(1, 5);
preparedStatement.setInt(2, 1); preparedStatement.setInt(2, 1);
@ -270,10 +262,9 @@ public class HarperDBLiveTest {
//@Test //@Test
void whenAddtoBatch_thenExecuteBatchIsSuccess() throws SQLException { void whenAddtoBatch_thenExecuteBatchIsSuccess() throws SQLException {
final String INSERT_SQL = "insert into Demo.teacher(id, name, joining_date, subject_id)" final String INSERT_SQL = "insert into Demo.teacher(id, name, joining_date, subject_id)" + "values(?, ?, ?, ?)";
+ "values(?, ?, ?, ?)";
try(Connection connection = getConnection()) { try (Connection connection = getConnection()) {
PreparedStatement preparedStatement = connection.prepareStatement(INSERT_SQL); PreparedStatement preparedStatement = connection.prepareStatement(INSERT_SQL);
preparedStatement.setInt(1, 9); preparedStatement.setInt(1, 9);
preparedStatement.setString(2, "Bret Lee"); preparedStatement.setString(2, "Bret Lee");
@ -292,23 +283,19 @@ public class HarperDBLiveTest {
} }
} }
@Test @Test
void whenExecuteJoinQuery_thenResultSuccess() throws SQLException { void whenExecuteJoinQuery_thenResultSuccess() throws SQLException {
final String JOIN_QUERY = "SELECT t.name as teacher_name, s.name as subject_name " + final String JOIN_QUERY =
"from Demo.teacher AS t INNER JOIN Demo.subject AS s ON t.subject_id = s.id"; "SELECT t.name as teacher_name, s.name as subject_name " + "from Demo.teacher AS t INNER JOIN Demo.subject AS s ON t.subject_id = s.id";
try(Connection connection = getConnection()) { try (Connection connection = getConnection()) {
Statement statement = connection.createStatement(); Statement statement = connection.createStatement();
ResultSet resultSet = statement.executeQuery(JOIN_QUERY); ResultSet resultSet = statement.executeQuery(JOIN_QUERY);
while (resultSet.next()) { while (resultSet.next()) {
logger.info("Teacher Name:" + resultSet.getString("teacher_name") + " Subject Name:" logger.info("Teacher Name:" + resultSet.getString("teacher_name") + " Subject Name:" + resultSet.getString("subject_name"));
+ resultSet.getString("subject_name"));
} }
} }
} }
@ -316,7 +303,7 @@ public class HarperDBLiveTest {
@Test @Test
void whenExecuteStoredToCreateTable_thenSuccess() throws SQLException { void whenExecuteStoredToCreateTable_thenSuccess() throws SQLException {
final String CREATE_TABLE_SQL = "CreateTable"; final String CREATE_TABLE_SQL = "CreateTable";
try(Connection connection = getConnection()) { try (Connection connection = getConnection()) {
CallableStatement callableStatement = connection.prepareCall(CREATE_TABLE_SQL); CallableStatement callableStatement = connection.prepareCall(CREATE_TABLE_SQL);
callableStatement.setString("SchemaName", "prod"); //schema gets created too callableStatement.setString("SchemaName", "prod"); //schema gets created too
@ -326,7 +313,7 @@ public class HarperDBLiveTest {
ResultSet resultSet = callableStatement.getResultSet(); ResultSet resultSet = callableStatement.getResultSet();
while(resultSet.next()) { while (resultSet.next()) {
String tableCreated = resultSet.getString("Success"); String tableCreated = resultSet.getString("Success");
assertEquals("true", tableCreated); assertEquals("true", tableCreated);
logger.info("result of the callable execute:" + tableCreated); logger.info("result of the callable execute:" + tableCreated);