0739e679bfb4989edc935bc13f78caef35dca4e5
[appc.git] /
1 package org.onap.appc.adapter.ssh.sshd;
2
3 import org.junit.Before;
4 import org.junit.Test;
5 import org.onap.appc.adapter.ssh.SshConnectionDetails;
6 import org.onap.ccsdk.sli.core.dblib.DbLibService;
7
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;
15
16 import static org.junit.Assert.assertEquals;
17
18 public class SshdDataAccessServiceTest {
19
20     private SshdDataAccessService sshdDataAccessService;
21     private DbLibService db;
22     @Before
23     public void setUp() {
24         sshdDataAccessService = new SshdDataAccessService();
25         db = new DbLibService() {
26             @Override
27             public CachedRowSet getData(String s, ArrayList<String> arrayList, String s1) throws SQLException {
28                 return null;
29             }
30
31             @Override
32             public boolean writeData(String s, ArrayList<String> arrayList, String s1) throws SQLException {
33                 return false;
34             }
35
36             @Override
37             public boolean isActive() {
38                 return false;
39             }
40
41             @Override
42             public Connection getConnection() throws SQLException {
43                 return null;
44             }
45
46             @Override
47             public Connection getConnection(String username, String password) throws SQLException {
48                 return null;
49             }
50
51             @Override
52             public <T> T unwrap(Class<T> iface) throws SQLException {
53                 return null;
54             }
55
56             @Override
57             public boolean isWrapperFor(Class<?> iface) throws SQLException {
58                 return false;
59             }
60
61             @Override
62             public PrintWriter getLogWriter() throws SQLException {
63                 return null;
64             }
65
66             @Override
67             public void setLogWriter(PrintWriter out) throws SQLException {
68
69             }
70
71             @Override
72             public void setLoginTimeout(int seconds) throws SQLException {
73
74             }
75
76             @Override
77             public int getLoginTimeout() throws SQLException {
78                 return 0;
79             }
80
81             @Override
82             public Logger getParentLogger() throws SQLFeatureNotSupportedException {
83                 return null;
84             }
85         };
86     }
87
88     @Test
89     public void testSetSchema() {
90         sshdDataAccessService.setSchema("test");
91         assertEquals("test", sshdDataAccessService.getSchema());
92     }
93
94     @Test
95     public void testSetDbLibService() {
96         sshdDataAccessService.setDbLibService(db);
97         assertEquals(false, sshdDataAccessService.getDbLibService().isActive());
98     }
99
100     @Test(expected = NullPointerException.class)
101     public void testRetrieveConnectionDetails() {
102         SshConnectionDetails connectionDetails = new SshConnectionDetails();
103         sshdDataAccessService.retrieveConnectionDetails("test", connectionDetails);
104     }
105
106     @Test(expected = NullPointerException.class)
107     public void testRetrieveConfigFileName() {
108         SshConnectionDetails connectionDetails = new SshConnectionDetails();
109         sshdDataAccessService.retrieveConfigFileName("test");
110     }
111 }