1 package org.onap.appc.adapter.ssh.sshd;
3 import org.junit.Before;
5 import org.onap.appc.adapter.ssh.SshConnectionDetails;
6 import org.onap.ccsdk.sli.core.dblib.DbLibService;
8 import javax.sql.rowset.CachedRowSet;
9 import java.io.PrintWriter;
10 import java.sql.Connection;
11 import java.sql.SQLException;
12 import java.sql.SQLFeatureNotSupportedException;
13 import java.util.ArrayList;
14 import java.util.logging.Logger;
16 import static org.junit.Assert.assertEquals;
18 public class SshdDataAccessServiceTest {
20 private SshdDataAccessService sshdDataAccessService;
21 private DbLibService db;
24 sshdDataAccessService = new SshdDataAccessService();
25 db = new DbLibService() {
27 public CachedRowSet getData(String s, ArrayList<String> arrayList, String s1) throws SQLException {
32 public boolean writeData(String s, ArrayList<String> arrayList, String s1) throws SQLException {
37 public boolean isActive() {
42 public Connection getConnection() throws SQLException {
47 public Connection getConnection(String username, String password) throws SQLException {
52 public <T> T unwrap(Class<T> iface) throws SQLException {
57 public boolean isWrapperFor(Class<?> iface) throws SQLException {
62 public PrintWriter getLogWriter() throws SQLException {
67 public void setLogWriter(PrintWriter out) throws SQLException {
72 public void setLoginTimeout(int seconds) throws SQLException {
77 public int getLoginTimeout() throws SQLException {
82 public Logger getParentLogger() throws SQLFeatureNotSupportedException {
89 public void testSetSchema() {
90 sshdDataAccessService.setSchema("test");
91 assertEquals("test", sshdDataAccessService.getSchema());
95 public void testSetDbLibService() {
96 sshdDataAccessService.setDbLibService(db);
97 assertEquals(false, sshdDataAccessService.getDbLibService().isActive());
100 @Test(expected = NullPointerException.class)
101 public void testRetrieveConnectionDetails() {
102 SshConnectionDetails connectionDetails = new SshConnectionDetails();
103 sshdDataAccessService.retrieveConnectionDetails("test", connectionDetails);
106 @Test(expected = NullPointerException.class)
107 public void testRetrieveConfigFileName() {
108 SshConnectionDetails connectionDetails = new SshConnectionDetails();
109 sshdDataAccessService.retrieveConfigFileName("test");