aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--dblib/provider/src/test/java/org/onap/ccsdk/sli/core/dblib/CachedDataSourceTest.java24
-rw-r--r--sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelperTest.java160
-rw-r--r--sli/recording/src/test/java/org/onap/ccsdk/sli/core/sli/recording/TestFileRecorder.java50
-rw-r--r--sliapi/provider/src/test/java/org/onap/ccsdk/sli/core/sliapi/SliapiHelperTest.java35
-rw-r--r--sliapi/provider/src/test/java/org/onap/ccsdk/sli/core/sliapi/TestSliapiProvider.java25
5 files changed, 192 insertions, 102 deletions
diff --git a/dblib/provider/src/test/java/org/onap/ccsdk/sli/core/dblib/CachedDataSourceTest.java b/dblib/provider/src/test/java/org/onap/ccsdk/sli/core/dblib/CachedDataSourceTest.java
index c463f38b..45268107 100644
--- a/dblib/provider/src/test/java/org/onap/ccsdk/sli/core/dblib/CachedDataSourceTest.java
+++ b/dblib/provider/src/test/java/org/onap/ccsdk/sli/core/dblib/CachedDataSourceTest.java
@@ -1,10 +1,12 @@
package org.onap.ccsdk.sli.core.dblib;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
+import java.sql.SQLException;
import java.sql.SQLFeatureNotSupportedException;
import java.util.Properties;
@@ -94,4 +96,26 @@ public class CachedDataSourceTest {
assertEquals("passw0rd", ((JdbcDBCachedDataSource) ds).getDbPasswd());
assertEquals("testdb01", ((JdbcDBCachedDataSource) ds).toString());
}
+
+ @Test
+ public void testIsInitialised() {
+ assertTrue(ds.isInitialized());
+ }
+
+ @Test
+ public void testIsWrapperFor() throws SQLException {
+ assertFalse(ds.isWrapperFor(CachedDataSource.class));
+ }
+
+ @Test
+ public void testGetSetNextErrorReportTime() throws SQLException {
+ ds.setNextErrorReportTime(1L);
+ assertEquals(1L, ds.getNextErrorReportTime());
+ }
+
+ @Test
+ public void testGetSetGlobalHostName() throws SQLException {
+ ds.setGlobalHostName("hostName");
+ assertEquals("hostName", ds.getGlobalHostName());
+ }
} \ No newline at end of file
diff --git a/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelperTest.java b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelperTest.java
index 307c69c7..d0ea4f55 100644
--- a/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelperTest.java
+++ b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelperTest.java
@@ -3,7 +3,9 @@
* ONAP : CCSDK
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights
- * reserved.
+ * reserved.
+ * ================================================================================
+ * Modifications Copyright (C) 2018 IBM.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,33 +23,26 @@
package org.onap.ccsdk.sli.core.sli.provider;
-import java.io.File;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
-import java.util.Map.Entry;
import java.util.Properties;
-import static org.junit.Assert.*;
-
import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ExecuteGraphInput.Mode;
-import org.onap.ccsdk.sli.core.sli.provider.MdsalHelper;
-import org.onap.ccsdk.sli.core.sli.SvcLogicGraph;
import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ExecuteGraphInputBuilder;
import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.execute.graph.input.SliParameter;
import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.execute.graph.input.SliParameterBuilder;
-import org.opendaylight.yang.gen.v1.test.CosModelType;
import org.opendaylight.yang.gen.v1.test.WrapperObj;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Dscp;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddressBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import junit.framework.TestCase;
-
public class MdsalHelperTest extends TestCase {
- private static final Logger LOG = LoggerFactory
- .getLogger(MdsalHelperTest.class);
+ private static final Logger LOG = LoggerFactory.getLogger(MdsalHelperTest.class);
public static final String pathToSdnPropertiesFile = "src/test/resources/l3sdn.properties";
public void testSdnProperties() {
@@ -56,8 +51,8 @@ public class MdsalHelperTest extends TestCase {
assertEquals("synccomplete", MdsalHelperTesterUtil.mapEnumeratedValue("request-status", "synccomplete"));
assertEquals("asynccomplete", MdsalHelperTesterUtil.mapEnumeratedValue("request-status", "asynccomplete"));
assertEquals("notifycomplete", MdsalHelperTesterUtil.mapEnumeratedValue("request-status", "notifycomplete"));
- assertEquals("service-configuration-operation", MdsalHelperTesterUtil.mapEnumeratedValue("rpc-name",
- "service-configuration-operation"));
+ assertEquals("service-configuration-operation",
+ MdsalHelperTesterUtil.mapEnumeratedValue("rpc-name", "service-configuration-operation"));
}
public void testNegativeSdnProperties() {
@@ -66,85 +61,82 @@ public class MdsalHelperTest extends TestCase {
public void testToProperties() {
- ExecuteGraphInputBuilder execBuilder = new ExecuteGraphInputBuilder();
- SliParameterBuilder parmBuilder = new SliParameterBuilder();
- List<SliParameter> params = new LinkedList<SliParameter>();
-
- parmBuilder.setParameterName("boolean-parm");
- parmBuilder.setBooleanValue(Boolean.TRUE);
- params.add(parmBuilder.build());
-
- parmBuilder.setParameterName("int-parm");
- parmBuilder.setBooleanValue(null);
- parmBuilder.setIntValue(1);
- params.add(parmBuilder.build());
-
- parmBuilder.setParameterName("str-parm");
- parmBuilder.setIntValue(null);
- parmBuilder.setStringValue("hello");
- params.add(parmBuilder.build());
+ ExecuteGraphInputBuilder execBuilder = new ExecuteGraphInputBuilder();
+ SliParameterBuilder parmBuilder = new SliParameterBuilder();
+ List<SliParameter> params = new LinkedList<SliParameter>();
- parmBuilder.setParameterName("ipaddress4-parm");
- parmBuilder.setStringValue(null);
- parmBuilder.setIpaddressValue(IpAddressBuilder.getDefaultInstance("127.0.0.1"));
- params.add(parmBuilder.build());
+ parmBuilder.setParameterName("boolean-parm");
+ parmBuilder.setBooleanValue(Boolean.TRUE);
+ params.add(parmBuilder.build());
- parmBuilder.setParameterName("ipaddress6-parm");
- parmBuilder.setIpaddressValue(IpAddressBuilder.getDefaultInstance("ef::1"));
- params.add(parmBuilder.build());
+ parmBuilder.setParameterName("int-parm");
+ parmBuilder.setBooleanValue(null);
+ parmBuilder.setIntValue(1);
+ params.add(parmBuilder.build());
+ parmBuilder.setParameterName("str-parm");
+ parmBuilder.setIntValue(null);
+ parmBuilder.setStringValue("hello");
+ params.add(parmBuilder.build());
- execBuilder.setMode(Mode.Sync);
- execBuilder.setModuleName("my-module");
- execBuilder.setRpcName("do-it-now");
- execBuilder.setSliParameter(params);
+ parmBuilder.setParameterName("ipaddress4-parm");
+ parmBuilder.setStringValue(null);
+ parmBuilder.setIpaddressValue(IpAddressBuilder.getDefaultInstance("127.0.0.1"));
+ params.add(parmBuilder.build());
+ parmBuilder.setParameterName("ipaddress6-parm");
+ parmBuilder.setIpaddressValue(IpAddressBuilder.getDefaultInstance("ef::1"));
+ params.add(parmBuilder.build());
- Properties props = new Properties();
+ execBuilder.setMode(Mode.Sync);
+ execBuilder.setModuleName("my-module");
+ execBuilder.setRpcName("do-it-now");
+ execBuilder.setSliParameter(params);
- MdsalHelperTesterUtil.toProperties(props, execBuilder);
+ Properties props = new Properties();
- LOG.info("Converted to properties");
- for (Map.Entry<Object, Object> e : props.entrySet()) {
- LOG.info(e.getKey().toString() + " = "+e.getValue().toString());
+ MdsalHelperTesterUtil.toProperties(props, execBuilder);
+ MdsalHelperTesterUtil.toProperties(props, "", execBuilder);
- }
+ LOG.info("Converted to properties");
+ for (Map.Entry<Object, Object> e : props.entrySet()) {
+ LOG.info(e.getKey().toString() + " = " + e.getValue().toString());
+ }
}
public void testToBuilder() {
- Properties props = new Properties();
-
- props.setProperty("execute-graph-input.mode", "Sync");
- props.setProperty("execute-graph-input.module", "my-module");
- props.setProperty("execute-graph-input.rpc", "do-it-now");
- props.setProperty("execute-graph-input.sli-parameter[0].parameter-name", "bool-parm");
- props.setProperty("execute-graph-input.sli-parameter[0].boolean-value", "true");
- props.setProperty("execute-graph-input,sli-parameter[1].parameter-name", "int-param");
- props.setProperty("execute-graph-input.sli-parameter[1].int-value", "1");
- props.setProperty("execute-graph-input.sli-parameter[2].parameter-name", "str-param");
- props.setProperty("execute-graph-input.sli-parameter[2].str-value", "hello");
- props.setProperty("execute-graph-input.sli-parameter[3].parameter-name", "ipv4address-param");
- props.setProperty("execute-graph-input.sli-parameter[3].ipaddress-value", "127.0.0.1");
- props.setProperty("execute-graph-input.sli-parameter[4].parameter-name", "ipv6address-param");
- props.setProperty("execute-graph-input.sli-parameter[4].ipaddress-value", "ef::1");
- ExecuteGraphInputBuilder execBuilder = new ExecuteGraphInputBuilder();
-
- MdsalHelperTesterUtil.toBuilder(props, execBuilder);
-
+ Properties props = new Properties();
+ props.setProperty("execute-graph-input.mode", "Sync");
+ props.setProperty("execute-graph-input.module", "my-module");
+ props.setProperty("execute-graph-input.rpc", "do-it-now");
+ props.setProperty("execute-graph-input.sli-parameter[0].parameter-name", "bool-parm");
+ props.setProperty("execute-graph-input.sli-parameter[0].boolean-value", "true");
+ props.setProperty("execute-graph-input,sli-parameter[1].parameter-name", "int-param");
+ props.setProperty("execute-graph-input.sli-parameter[1].int-value", "1");
+ props.setProperty("execute-graph-input.sli-parameter[2].parameter-name", "str-param");
+ props.setProperty("execute-graph-input.sli-parameter[2].str-value", "hello");
+ props.setProperty("execute-graph-input.sli-parameter[3].parameter-name", "ipv4address-param");
+ props.setProperty("execute-graph-input.sli-parameter[3].ipaddress-value", "127.0.0.1");
+ props.setProperty("execute-graph-input.sli-parameter[4].parameter-name", "ipv6address-param");
+ props.setProperty("execute-graph-input.sli-parameter[4].ipaddress-value", "ef::1");
+ ExecuteGraphInputBuilder execBuilder = new ExecuteGraphInputBuilder();
+
+ MdsalHelperTesterUtil.toBuilder(props, execBuilder);
}
- public void testToJavaEnum() throws Exception{
- assertEquals("_2018HelloWorld",MdsalHelper.toJavaEnum("2018Hello World"));
- assertEquals("SomethingElse",MdsalHelper.toJavaEnum("Something.Else"));
- assertEquals("MyTestString",MdsalHelper.toJavaEnum("my-test-string"));
+ public void testToJavaEnum() throws Exception {
+ assertEquals("_2018HelloWorld", MdsalHelper.toJavaEnum("2018Hello World"));
+ assertEquals("SomethingElse", MdsalHelper.toJavaEnum("Something.Else"));
+ assertEquals("MyTestString", MdsalHelper.toJavaEnum("my-test-string"));
}
-
- // During the default enumeration mapping no properties file is needed, the yang value is returned
+
+ // During the default enumeration mapping no properties file is needed, the
+ // yang value is returned
// by the java object
public void testDefaultEnumerationMapping() throws Exception {
Properties props = new Properties();
@@ -152,7 +144,8 @@ public class MdsalHelperTest extends TestCase {
assertEquals("4COS", props.getProperty("wrapper-obj.cos-model-type"));
}
- // When no properties file exists the default java value will be returned if legacy enumeration
+ // When no properties file exists the default java value will be returned if
+ // legacy enumeration
// mapping is enabled
public void testLegacyEnumerationMappingNoProperties() throws Exception {
Properties props = new Properties();
@@ -160,7 +153,8 @@ public class MdsalHelperTest extends TestCase {
assertEquals("_4COS", props.getProperty("wrapper-obj.cos-model-type"));
}
- // When a properties file exists & legacy enumeration mapping is enabled the value from the
+ // When a properties file exists & legacy enumeration mapping is enabled the
+ // value from the
// properties file should be returned
public void testLegacyEnumerationMappingWithProperties() throws Exception {
MdsalHelper.loadProperties("src/test/resources/EnumerationMapping.properties");
@@ -168,4 +162,22 @@ public class MdsalHelperTest extends TestCase {
MdsalHelper.toProperties(props, new WrapperObj(), true);
assertEquals("HelloWorld", props.getProperty("wrapper-obj.cos-model-type"));
}
+
+ public void testGetFullPropertiesPath() {
+ String fullPath = MdsalHelper.getFullPropertiesPath("testFile");
+ assertEquals("/opt/bvc/controller/configuration/testFile", fullPath);
+
+ }
+
+ public void testIsDscp() {
+
+ assertTrue(MdsalHelper.isDscp(Dscp.class));
+
+ }
+
+ public void testIsPortNumber() {
+
+ assertTrue(MdsalHelper.isPortNumber(PortNumber.class));
+
+ }
}
diff --git a/sli/recording/src/test/java/org/onap/ccsdk/sli/core/sli/recording/TestFileRecorder.java b/sli/recording/src/test/java/org/onap/ccsdk/sli/core/sli/recording/TestFileRecorder.java
index c879d8f6..d0cc8318 100644
--- a/sli/recording/src/test/java/org/onap/ccsdk/sli/core/sli/recording/TestFileRecorder.java
+++ b/sli/recording/src/test/java/org/onap/ccsdk/sli/core/sli/recording/TestFileRecorder.java
@@ -3,8 +3,11 @@
*/
package org.onap.ccsdk.sli.core.sli.recording;
-import static org.junit.Assert.*;
+import static org.junit.Assert.fail;
+
import java.util.HashMap;
+
+import org.junit.Before;
import org.junit.Test;
import org.onap.ccsdk.sli.core.sli.SvcLogicException;
@@ -13,23 +16,34 @@ import org.onap.ccsdk.sli.core.sli.SvcLogicException;
*
*/
public class TestFileRecorder {
+ private FileRecorder recorder;
+
+ @Before
+ public void setUp() {
+ recorder = new FileRecorder();
+ }
+
+ /**
+ * Test method for
+ * {@link org.onap.ccsdk.sli.core.sli.recording.FileRecorder#record(java.util.Map)}.
+ */
+ @Test
+ public void testRecord() {
+ HashMap<String, String> parms = new HashMap<>();
+ parms.put("file", "/dev/null");
+ parms.put("field1", "hi");
+ try {
+ recorder.record(parms);
+ } catch (SvcLogicException e) {
+ fail("Caught SvcLogicException : " + e.getMessage());
+ }
+ }
- /**
- * Test method for {@link org.onap.ccsdk.sli.core.sli.recording.FileRecorder#record(java.util.Map)}.
- */
- @Test
- public void testRecord() {
-
- FileRecorder recorder = new FileRecorder();
-
- HashMap<String,String> parms = new HashMap<>();
- parms.put("file", "/dev/null");
- parms.put("field1","hi");
- try {
- recorder.record(parms);
- } catch (SvcLogicException e) {
- fail("Caught SvcLogicException : "+e.getMessage());
- }
- }
+ @Test(expected = Exception.class)
+ public void testRecordForEmptyFileName() throws Exception {
+ HashMap<String, String> parms = new HashMap<>();
+ parms.put("field1", "hi");
+ recorder.record(parms);
+ }
}
diff --git a/sliapi/provider/src/test/java/org/onap/ccsdk/sli/core/sliapi/SliapiHelperTest.java b/sliapi/provider/src/test/java/org/onap/ccsdk/sli/core/sliapi/SliapiHelperTest.java
new file mode 100644
index 00000000..228f6127
--- /dev/null
+++ b/sliapi/provider/src/test/java/org/onap/ccsdk/sli/core/sliapi/SliapiHelperTest.java
@@ -0,0 +1,35 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : CCSDK
+ * ================================================================================
+ * Copyright (C) 2018 IBM. All rights reserved.
+ * ================================================================================
+ * 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.core.sliapi;
+
+import static org.junit.Assert.assertNotNull;
+
+import org.junit.Test;
+
+public class SliapiHelperTest {
+
+ @Test
+ public void TestSliapiHelper()
+ {
+ SliapiHelper sliapiHelper= new SliapiHelper();
+ assertNotNull(sliapiHelper);
+ }
+}
diff --git a/sliapi/provider/src/test/java/org/onap/ccsdk/sli/core/sliapi/TestSliapiProvider.java b/sliapi/provider/src/test/java/org/onap/ccsdk/sli/core/sliapi/TestSliapiProvider.java
index 38cbd40c..287f2f20 100644
--- a/sliapi/provider/src/test/java/org/onap/ccsdk/sli/core/sliapi/TestSliapiProvider.java
+++ b/sliapi/provider/src/test/java/org/onap/ccsdk/sli/core/sliapi/TestSliapiProvider.java
@@ -4,8 +4,12 @@
package org.onap.ccsdk.sli.core.sliapi;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
-import static org.mockito.Mockito.*;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
import java.io.InputStream;
import java.net.URL;
import java.util.HashMap;
@@ -13,6 +17,8 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Properties;
+import java.util.concurrent.Future;
+
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -86,7 +92,6 @@ public class TestSliapiProvider {
}
};
-
/**
* @throws java.lang.Exception
*/
@@ -95,10 +100,10 @@ public class TestSliapiProvider {
DataBroker dataBroker = mock(DataBroker.class);
NotificationPublishService notifyService = mock(NotificationPublishService.class);
RpcProviderRegistry rpcRegistry = mock(RpcProviderRegistry.class);
- BindingAwareBroker.RpcRegistration<SLIAPIService> rpcRegistration = (BindingAwareBroker.RpcRegistration<SLIAPIService>) mock(BindingAwareBroker.RpcRegistration.class);
+ BindingAwareBroker.RpcRegistration<SLIAPIService> rpcRegistration = (BindingAwareBroker.RpcRegistration<SLIAPIService>) mock(
+ BindingAwareBroker.RpcRegistration.class);
when(rpcRegistry.addRpcImplementation(any(Class.class), any(SLIAPIService.class))).thenReturn(rpcRegistration);
-
// Load svclogic.properties and get a SvcLogicStore
InputStream propStr = TestSliapiProvider.class.getResourceAsStream("/svclogic.properties");
Properties svcprops = new Properties();
@@ -111,7 +116,7 @@ public class TestSliapiProvider {
// Load the DG for the healthcheck api
URL testCaseUrl = TestSliapiProvider.class.getClassLoader().getResource(HEALTHCHECK_DG);
if (testCaseUrl == null) {
- fail("Cannot find "+HEALTHCHECK_DG);
+ fail("Cannot find " + HEALTHCHECK_DG);
}
SvcLogicParser.load(testCaseUrl.getPath(), store);
SvcLogicParser.activate("sli", "healthcheck", "1.0.0", "sync", store);
@@ -138,7 +143,8 @@ public class TestSliapiProvider {
}
/**
- * Test method for {@link org.onap.ccsdk.sli.core.sliapi.sliapiProvider#executeGraph(org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ExecuteGraphInput)}.
+ * Test method for
+ * {@link org.onap.ccsdk.sli.core.sliapi.sliapiProvider#executeGraph(org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ExecuteGraphInput)}.
*/
@Test
public void testExecuteGraph() {
@@ -154,14 +160,13 @@ public class TestSliapiProvider {
pList.add(pBuilder.build());
inputBuilder.setSliParameter(pList);
-
-
-
provider.executeGraph(inputBuilder.build());
+ assertTrue(provider.vlbcheck() instanceof Future<?>);
}
/**
- * Test method for {@link org.onap.ccsdk.sli.core.sliapi.sliapiProvider#healthcheck()}.
+ * Test method for
+ * {@link org.onap.ccsdk.sli.core.sliapi.sliapiProvider#healthcheck()}.
*/
@Test
public void testHealthcheck() {