summaryrefslogtreecommitdiffstats
path: root/adaptors
diff options
context:
space:
mode:
Diffstat (limited to 'adaptors')
-rw-r--r--adaptors/ssh-adaptor/ssh-adaptor-bundle/src/test/java/org/onap/ccsdk/sli/adaptors/ssh/DbLibServiceMock.java77
-rw-r--r--adaptors/ssh-adaptor/ssh-adaptor-bundle/src/test/java/org/onap/ccsdk/sli/adaptors/ssh/SshdDataAccessServiceTest.java91
2 files changed, 168 insertions, 0 deletions
diff --git a/adaptors/ssh-adaptor/ssh-adaptor-bundle/src/test/java/org/onap/ccsdk/sli/adaptors/ssh/DbLibServiceMock.java b/adaptors/ssh-adaptor/ssh-adaptor-bundle/src/test/java/org/onap/ccsdk/sli/adaptors/ssh/DbLibServiceMock.java
new file mode 100644
index 000000000..08b2bac06
--- /dev/null
+++ b/adaptors/ssh-adaptor/ssh-adaptor-bundle/src/test/java/org/onap/ccsdk/sli/adaptors/ssh/DbLibServiceMock.java
@@ -0,0 +1,77 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : CCSDK
+ * ================================================================================
+ * Copyright (C) 2022 Samsung Electronics
+ * =============================================================================
+ * 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.ccsdk.sli.adaptors.ssh;
+
+import org.mockito.Mockito;
+import org.onap.ccsdk.sli.core.dblib.DbLibService;
+
+import javax.sql.rowset.CachedRowSet;
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.util.ArrayList;
+
+public abstract class DbLibServiceMock implements DbLibService {
+
+ @Override
+ public CachedRowSet getData(String statement,ArrayList<String> arguments, String preferredDS) throws SQLException{
+ CachedRowSet rowset = Mockito.mock(CachedRowSet.class);
+ return rowset;
+ }
+
+ @Override
+ public boolean writeData(String statement, ArrayList<String> arguments, String preferredDS)
+ throws SQLException {
+ return true;
+ }
+
+ @Override
+ public boolean isActive() {
+ return true;
+ }
+
+ @Override
+ public Connection getConnection() throws SQLException {
+ return null;
+ }
+
+ @Override
+ public Connection getConnection(String username, String password) throws SQLException{
+ return null;
+ }
+
+ @Override
+ public java.io.PrintWriter getLogWriter() throws SQLException{
+ return null;
+ }
+
+ @Override
+ public void setLogWriter(java.io.PrintWriter out) throws SQLException{}
+
+ @Override
+ public void setLoginTimeout(int seconds) throws SQLException{}
+
+ @Override
+ public int getLoginTimeout() throws SQLException{
+ return 1;
+ }
+
+
+}
diff --git a/adaptors/ssh-adaptor/ssh-adaptor-bundle/src/test/java/org/onap/ccsdk/sli/adaptors/ssh/SshdDataAccessServiceTest.java b/adaptors/ssh-adaptor/ssh-adaptor-bundle/src/test/java/org/onap/ccsdk/sli/adaptors/ssh/SshdDataAccessServiceTest.java
new file mode 100644
index 000000000..d8c22dbb8
--- /dev/null
+++ b/adaptors/ssh-adaptor/ssh-adaptor-bundle/src/test/java/org/onap/ccsdk/sli/adaptors/ssh/SshdDataAccessServiceTest.java
@@ -0,0 +1,91 @@
+/*
+ * ============LICENSE_START=======================================================
+ * ONAP : CCSDK
+ * ================================================================================
+ * Copyright (C) 2022 Samsung Electronics
+ * ================================================================================
+ * 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.ccsdk.sli.adaptors.ssh;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.onap.ccsdk.sli.adaptors.ssh.sshd.SshdDataAccessService;
+import org.onap.ccsdk.sli.core.dblib.DbLibService;
+
+import javax.sql.rowset.CachedRowSet;
+import javax.sql.rowset.RowSetProvider;
+import java.io.PrintWriter;
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.sql.SQLFeatureNotSupportedException;
+import java.util.logging.Logger;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+public class SshdDataAccessServiceTest {
+
+ private SshdDataAccessService sshdDataAccessService;
+ private DbLibService db;
+ CachedRowSet rowset;
+ @Before
+ public void setUp() throws SQLException {
+ sshdDataAccessService = new SshdDataAccessService();
+ DbLibServiceMock dbLibServiceMock = new DbLibServiceMock() {
+ @Override
+ public <T> T unwrap(Class<T> iface) throws SQLException {
+ return null;
+ }
+
+ @Override
+ public boolean isWrapperFor(Class<?> iface) throws SQLException {
+ return false;
+ }
+
+ @Override
+ public Logger getParentLogger() throws SQLFeatureNotSupportedException {
+ return null;
+ }
+ };
+ sshdDataAccessService.setDbLibService(db);
+ }
+
+ @Test
+ public void testSetSchema() {
+ sshdDataAccessService.setSchema("test");
+ assertEquals("test", sshdDataAccessService.getSchema());
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testSetDbLibService() {
+ sshdDataAccessService.setDbLibService(db);
+ assertEquals(false, sshdDataAccessService.getDbLibService().isActive());
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testRetrieveConnectionDetails() {
+ SshConnectionDetails connectionDetails = new SshConnectionDetails();
+ sshdDataAccessService.setDbLibService(db);
+ assertTrue(sshdDataAccessService.retrieveConnectionDetails("test", connectionDetails));
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testRetrieveConfigFileName() {
+ assertEquals(null, sshdDataAccessService.retrieveConfigFileName("test"));
+ }
+}