summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTimoney, Dan (dt5972) <dt5972@att.com>2018-03-24 19:11:10 -0400
committerTimoney, Dan (dt5972) <dt5972@att.com>2018-03-27 14:58:43 -0400
commita0ab49e6c1ea41af18656d6e9efb3377051f2528 (patch)
treedc935417ffa4aac764aef2f1978c1ceecd68bd55
parent5e0f12e215d579b2adff145a8527cc6a225d8db9 (diff)
Add unit tests for sli
Added unit tests for ccsdk/sli/core/sli Change-Id: I0d2408c43b9e56a78f3e01e87985aedb6cad5953 Issue-ID: CCSDK-213 Signed-off-by: Timoney, Dan (dt5972) <dt5972@att.com>
-rwxr-xr-x.gitignore2
-rwxr-xr-xdblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/CachedDataSource.java7
-rwxr-xr-xfilters/provider/pom.xml8
-rw-r--r--filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/RequestResponseDbLoggingFilter.java5
-rw-r--r--filters/provider/src/test/java/org/onap/ccsdk/sli/core/filters/TestLogFilter.java71
-rw-r--r--filters/provider/src/test/java/org/onap/ccsdk/sli/core/filters/TestRequestResponseLoggingFilter.java129
-rwxr-xr-xsli/common/pom.xml12
-rw-r--r--sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/MessageWriter.java6
-rw-r--r--sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicDblibStore.java13
-rw-r--r--sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicJdbcStore.java1
-rw-r--r--sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicParser.java6
-rw-r--r--sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/ITCaseSvcLogicParser.java139
-rw-r--r--sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/PrintYangToPropTest.java22
-rw-r--r--sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/TestMetricLogger.java135
-rw-r--r--sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/TestSvcLogicLoader.java38
-rwxr-xr-xsli/common/src/test/resources/dblib.properties14
-rw-r--r--sli/common/src/test/resources/graphs/sliapi/graph.versions1
-rw-r--r--sli/common/src/test/resources/graphs/sliapi/sli_healthcheck.xml27
-rw-r--r--sli/common/src/test/resources/l3sdn_logic_v10.xml208
-rwxr-xr-xsli/common/src/test/resources/parser-good.tests1
-rw-r--r--sli/common/src/test/resources/svclogic.properties7
-rwxr-xr-xsli/common/src/test/resources/svclogic.xsd11
-rwxr-xr-xsli/provider/pom.xml96
-rw-r--r--sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/ITCaseSvcLogicGraphExecutor.java29
-rwxr-xr-xsli/provider/src/test/resources/executor.tests4
-rw-r--r--sli/provider/src/test/resources/l3sdn_logic_v10.xml23
-rw-r--r--sli/provider/src/test/resources/svclogic.properties4
-rwxr-xr-xsliapi/provider/pom.xml143
-rw-r--r--sliapi/provider/src/main/java/org/onap/ccsdk/sli/core/sliapi/sliapiProvider.java23
-rw-r--r--sliapi/provider/src/test/java/org/onap/ccsdk/sli/core/sliapi/TestSliapiProvider.java171
-rw-r--r--sliapi/provider/src/test/resources/sli_healthcheck.xml27
-rw-r--r--sliapi/provider/src/test/resources/svclogic.properties (renamed from sli/provider/src/main/resources/svclogic.properties)4
32 files changed, 1217 insertions, 170 deletions
diff --git a/.gitignore b/.gitignore
index a36bed32..a5a0d80e 100755
--- a/.gitignore
+++ b/.gitignore
@@ -44,3 +44,5 @@ sdnc-core_bdio.jsonld
blackDuckHubProjectName.txt
blackDuckHubProjectVersionName.txt
+# Derby log
+derby.log
diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/CachedDataSource.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/CachedDataSource.java
index 02cce3cf..97380f58 100755
--- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/CachedDataSource.java
+++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/CachedDataSource.java
@@ -342,11 +342,16 @@ public abstract class CachedDataSource implements DataSource, SQLExecutionMonito
}
protected boolean testConnection(boolean errorLevel) {
+
+ String testQuery = "SELECT @@global.read_only, @@global.hostname";
+ if (isDerby) {
+ testQuery = "SELECT 'false', 'localhost' FROM SYSIBM.SYSDUMMY1";
+ }
ResultSet rs = null;
try (Connection conn = this.getConnection(); Statement stmt = conn.createStatement()) {
Boolean readOnly;
String hostname;
- rs = stmt.executeQuery("SELECT @@global.read_only, @@global.hostname"); // ("SELECT 1 FROM DUAL"); //"select
+ rs = stmt.executeQuery(testQuery); // ("SELECT 1 FROM DUAL"); //"select
// BANNER from SYS.V_$VERSION"
while (rs.next()) {
readOnly = rs.getBoolean(1);
diff --git a/filters/provider/pom.xml b/filters/provider/pom.xml
index 4fdd8328..a60c0be0 100755
--- a/filters/provider/pom.xml
+++ b/filters/provider/pom.xml
@@ -19,6 +19,8 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <!-- Ignore deprecated classes in coverage counts -->
+ <sonar.coverage.exclusions>**/RequestResponseDbLoggingFilter.java</sonar.coverage.exclusions>
</properties>
<dependencies>
@@ -28,6 +30,12 @@
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
+
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-core</artifactId>
+ <scope>test</scope>
+ </dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
diff --git a/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/RequestResponseDbLoggingFilter.java b/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/RequestResponseDbLoggingFilter.java
index 8b67276b..35913656 100644
--- a/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/RequestResponseDbLoggingFilter.java
+++ b/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/RequestResponseDbLoggingFilter.java
@@ -8,9 +8,9 @@
* 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.
@@ -47,6 +47,7 @@ import org.onap.ccsdk.sli.core.sli.MessageWriter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+@Deprecated
public class RequestResponseDbLoggingFilter implements Filter {
private static Logger log = LoggerFactory.getLogger(RequestResponseDbLoggingFilter.class);
diff --git a/filters/provider/src/test/java/org/onap/ccsdk/sli/core/filters/TestLogFilter.java b/filters/provider/src/test/java/org/onap/ccsdk/sli/core/filters/TestLogFilter.java
new file mode 100644
index 00000000..a900b246
--- /dev/null
+++ b/filters/provider/src/test/java/org/onap/ccsdk/sli/core/filters/TestLogFilter.java
@@ -0,0 +1,71 @@
+/**
+ *
+ */
+package org.onap.ccsdk.sli.core.filters;
+
+import static org.junit.Assert.*;
+import org.apache.commons.codec.binary.Base64;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import static org.mockito.Mockito.*;
+import java.io.IOException;
+import java.util.UUID;
+import javax.servlet.FilterChain;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * @author dt5972
+ *
+ */
+public class TestLogFilter {
+
+ LogFilter logFilter;
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @Before
+ public void setUp() throws Exception {
+ logFilter = new LogFilter();
+ logFilter.init(null);
+ }
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @After
+ public void tearDown() throws Exception {
+ logFilter.destroy();
+ }
+
+ /**
+ * Test method for {@link org.onap.ccsdk.sli.core.filters.LogFilter#doFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse, javax.servlet.FilterChain)}.
+ * @throws ServletException
+ * @throws IOException
+ */
+ @Test
+ public void testDoFilter() throws IOException, ServletException {
+
+ // Test failed request with minimal headers
+ HttpServletRequest servletReq = mock(HttpServletRequest.class);
+ when(servletReq.getRequestURL()).thenReturn(new StringBuffer("SLI-API:healthcheck"));
+ when(servletReq.getPathInfo()).thenReturn("/hello:world");
+ HttpServletResponse servletResp = mock(HttpServletResponse.class);
+ when(servletResp.getStatus()).thenReturn(400);
+ FilterChain filterChain = mock(FilterChain.class);
+ logFilter.doFilter(servletReq, servletResp, filterChain);
+
+ // Test successful request with valid header
+ when(servletReq.getHeader(LogFilter.REQUEST_ID)).thenReturn(UUID.randomUUID().toString());
+ when(servletReq.getHeader("Authorization")).thenReturn("Basic "+Base64.encodeBase64String("username:password".getBytes()));
+ when(servletResp.getStatus()).thenReturn(200);
+ logFilter.doFilter(servletReq, servletResp, filterChain);
+
+
+ }
+
+}
diff --git a/filters/provider/src/test/java/org/onap/ccsdk/sli/core/filters/TestRequestResponseLoggingFilter.java b/filters/provider/src/test/java/org/onap/ccsdk/sli/core/filters/TestRequestResponseLoggingFilter.java
new file mode 100644
index 00000000..9f36fe11
--- /dev/null
+++ b/filters/provider/src/test/java/org/onap/ccsdk/sli/core/filters/TestRequestResponseLoggingFilter.java
@@ -0,0 +1,129 @@
+/**
+ *
+ */
+package org.onap.ccsdk.sli.core.filters;
+
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.*;
+import java.io.BufferedInputStream;
+import java.io.BufferedReader;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.StringBufferInputStream;
+import java.io.StringReader;
+import java.util.LinkedList;
+import java.util.UUID;
+import java.util.Vector;
+import javax.servlet.FilterChain;
+import javax.servlet.ServletException;
+import javax.servlet.ServletInputStream;
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import org.apache.commons.codec.binary.Base64;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * @author dt5972
+ *
+ */
+public class TestRequestResponseLoggingFilter {
+
+ RequestResponseLoggingFilter filter;
+
+ private class DummyServletInputStream extends ServletInputStream {
+
+ InputStream stream;
+
+ public DummyServletInputStream(InputStream stream) {
+ this.stream = stream;
+ }
+
+
+ @Override
+ public void close() throws IOException {
+ super.close();
+ stream.close();
+ }
+
+
+ @Override
+ public int read() throws IOException {
+ return stream.read();
+ }
+
+
+
+ }
+
+ private class DummyServletOutputStream extends ServletOutputStream {
+
+ OutputStream ostr;
+
+ public DummyServletOutputStream(OutputStream ostr) {
+ this.ostr = ostr;
+ }
+
+ @Override
+ public void write(int b) throws IOException {
+ ostr.write(b);
+ }
+
+ }
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @Before
+ public void setUp() throws Exception {
+ filter = new RequestResponseLoggingFilter();
+ filter.init(null);
+ }
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @After
+ public void tearDown() throws Exception {}
+
+ /**
+ * Test method for {@link org.onap.ccsdk.sli.core.filters.RequestResponseLoggingFilter#doFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse, javax.servlet.FilterChain)}.
+ * @throws IOException
+ * @throws ServletException
+ */
+ @Test
+ public void testDoFilter() throws IOException, ServletException {
+
+ HttpServletRequest request = mock(HttpServletRequest.class);
+ String msgBody = "hello world";
+ InputStream reqInputStream = new ByteArrayInputStream(msgBody.getBytes());
+ when(request.getInputStream()).thenReturn(new DummyServletInputStream(reqInputStream));
+ when(request.getMethod()).thenReturn("POST");
+ when(request.getRequestURL()).thenReturn(new StringBuffer("/HELLO:world"));
+ when(request.getPathInfo()).thenReturn("/hello:world");
+ Vector<String> headerList = new Vector<>();
+ headerList.add(LogFilter.REQUEST_ID);
+ headerList.add("Authorization");
+ when(request.getHeaderNames()).thenReturn(headerList.elements());
+
+ when(request.getHeader(LogFilter.REQUEST_ID)).thenReturn(UUID.randomUUID().toString());
+ when(request.getHeader("Authorization")).thenReturn("Basic "+Base64.encodeBase64String("username:password".getBytes()));
+
+ HttpServletResponse response = mock(HttpServletResponse.class);
+ OutputStream outStr = new ByteArrayOutputStream();
+ when(response.getOutputStream()).thenReturn(new DummyServletOutputStream(outStr));
+
+ FilterChain filterChain = mock(FilterChain.class);
+
+ filter.doFilter(request, response, filterChain);
+
+
+
+ }
+
+}
diff --git a/sli/common/pom.xml b/sli/common/pom.xml
index 1d35dfb1..c22c1ae6 100755
--- a/sli/common/pom.xml
+++ b/sli/common/pom.xml
@@ -18,6 +18,12 @@
<name>ccsdk-sli-core :: sli :: ${project.artifactId}</name>
<description>The SLI Common package includes common classes used by the various SLI subcomponents, as well as classes used by clients to interface with the service logic interpreter</description>
+ <properties>
+ <!-- Ignore deprecated classes in coverage counts -->
+ <sonar.coverage.exclusions>**/MessageWriter.java</sonar.coverage.exclusions>
+
+ </properties>
+
<dependencyManagement>
<dependencies>
<dependency>
@@ -31,9 +37,9 @@
</dependencyManagement>
<dependencies>
<dependency>
- <groupId>ch.vorburger.mariaDB4j</groupId>
- <artifactId>mariaDB4j</artifactId>
- <version>2.2.3</version>
+ <groupId>org.apache.derby</groupId>
+ <artifactId>derby</artifactId>
+ <version>10.11.1.1</version>
<scope>test</scope>
</dependency>
<dependency>
diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/MessageWriter.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/MessageWriter.java
index c75873eb..0e39896e 100644
--- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/MessageWriter.java
+++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/MessageWriter.java
@@ -8,9 +8,9 @@
* 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.
@@ -38,7 +38,7 @@ import org.osgi.framework.ServiceReference;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-
+@Deprecated
public class MessageWriter {
private static final Logger LOG = LoggerFactory.getLogger(MessageWriter.class);
diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicDblibStore.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicDblibStore.java
index ee3bcca5..864652b4 100644
--- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicDblibStore.java
+++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicDblibStore.java
@@ -66,6 +66,19 @@ public class SvcLogicDblibStore implements SvcLogicStore {
this.dbSvc = dbsvc;
}
+ public SvcLogicDblibStore(Properties props) {
+ try {
+ dbSvc = new DBResourceManager(props);
+ JavaSingleton.setInstance(dbSvc);
+ } catch (Exception e) {
+ LOG.warn("Caught exception trying to create DBResourceManager", e);
+ }
+ }
+
+ public Connection getConnection() throws SQLException {
+ return(dbSvc.getConnection());
+ }
+
@Override
public void init(Properties props) throws ConfigurationException {
diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicJdbcStore.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicJdbcStore.java
index e2fbdf72..0e7d05a6 100644
--- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicJdbcStore.java
+++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicJdbcStore.java
@@ -38,7 +38,6 @@ import java.util.Properties;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-
public class SvcLogicJdbcStore implements SvcLogicStore {
private static final Logger LOG = LoggerFactory.getLogger(SvcLogicJdbcStore.class);
diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicParser.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicParser.java
index 3d9caffb..2804f620 100644
--- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicParser.java
+++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicParser.java
@@ -437,7 +437,7 @@ public class SvcLogicParser {
}
-
+
public static void load(String xmlfile, SvcLogicStore store) throws SvcLogicException {
File xmlFile = new File(xmlfile);
if (!xmlFile.canRead()) {
@@ -531,7 +531,7 @@ public class SvcLogicParser {
}
- private static void activate(String module, String rpc, String version, String mode, SvcLogicStore store) {
+ public static void activate(String module, String rpc, String version, String mode, SvcLogicStore store) {
String details = "(module:" + module + ", rpc:" + rpc + ", version:" + version + ", mode:" + mode + ")";
try {
@@ -560,7 +560,7 @@ public class SvcLogicParser {
System.exit(1);
}
-
+
protected SAXParser initParser() throws ParserConfigurationException, SAXException {
URL xsdUrl = null;
Schema schema = null;
diff --git a/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/ITCaseSvcLogicParser.java b/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/ITCaseSvcLogicParser.java
index 368d9f95..6ee18e92 100644
--- a/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/ITCaseSvcLogicParser.java
+++ b/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/ITCaseSvcLogicParser.java
@@ -32,11 +32,13 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
+import java.sql.Connection;
+import java.sql.DatabaseMetaData;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
import java.util.Properties;
-import ch.vorburger.mariadb4j.DB;
-import ch.vorburger.mariadb4j.DBConfigurationBuilder;
-
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
@@ -67,17 +69,9 @@ public class ITCaseSvcLogicParser {
props.load(propStr);
+ store = SvcLogicStoreFactory.getSvcLogicStore(props);
- // Start MariaDB4j database
- DBConfigurationBuilder config = DBConfigurationBuilder.newBuilder();
- config.setPort(0); // 0 => autom. detect free port
- DB db = DB.newEmbeddedDB(config.build());
- db.start();
-
-
- // Override jdbc URL and database name
- props.setProperty("org.onap.ccsdk.sli.jdbc.database", "test");
- props.setProperty("org.onap.ccsdk.sli.jdbc.url", config.getURL("test"));
+ assertNotNull(store);
}
@@ -120,8 +114,123 @@ public class ITCaseSvcLogicParser {
}
try {
- SvcLogicParser.validate(testCaseUrl.getPath(), store);
+ SvcLogicParser.load(testCaseUrl.getPath(), store);
} catch (Exception e) {
+
+ fail("Validation failure [" + e.getMessage() + "]");
+ }
+ }
+ }
+ } catch (SvcLogicParserException e) {
+ fail("Parser error : " + e.getMessage());
+ } catch (Exception e) {
+ LOG.error("", e);
+ fail("Caught exception processing test cases");
+ }
+ }
+
+ @Test
+ public void testDblibLoadValidXml() throws IOException, SQLException, ConfigurationException {
+
+ URL propUrl = ITCaseSvcLogicParser.class.getResource("/dblib.properties");
+
+ InputStream propStr = ITCaseSvcLogicParser.class.getResourceAsStream("/dblib.properties");
+
+ Properties props = new Properties();
+
+ props.load(propStr);
+
+ SvcLogicDblibStore dblibStore = new SvcLogicDblibStore(props);
+
+ Connection dbConn = dblibStore.getConnection();
+
+ String dbName = props.getProperty("org.onap.ccsdk.sli.jdbc.database", "sdnctl");
+
+ DatabaseMetaData dbm;
+
+ try {
+ dbm = dbConn.getMetaData();
+ } catch (SQLException e) {
+
+ throw new ConfigurationException("could not get databse metadata", e);
+ }
+
+ // See if table SVC_LOGIC exists. If not, create it.
+ Statement stmt = null;
+ try {
+
+ ResultSet tables = dbm.getTables(null, null, "SVC_LOGIC", null);
+ if (tables.next()) {
+ LOG.debug("SVC_LOGIC table already exists");
+ } else {
+ String crTableCmd = "CREATE TABLE " + dbName + ".SVC_LOGIC (" + "module varchar(80) NOT NULL,"
+ + "rpc varchar(80) NOT NULL," + "version varchar(40) NOT NULL," + "mode varchar(5) NOT NULL,"
+ + "active varchar(1) NOT NULL," + "graph BLOB,"
+ + "CONSTRAINT P_SVC_LOGIC PRIMARY KEY(module, rpc, version, mode))";
+
+ stmt = dbConn.createStatement();
+ stmt.executeUpdate(crTableCmd);
+ }
+ } catch (Exception e) {
+ throw new ConfigurationException("could not create SVC_LOGIC table", e);
+ } finally {
+ if (stmt != null) {
+ try {
+ stmt.close();
+ } catch (SQLException e) {
+ LOG.error("Statement close error ", e);
+ }
+ }
+ }
+
+ // See if NODE_TYPES table exists and, if not, create it
+ stmt = null;
+ try {
+
+ ResultSet tables = dbm.getTables(null, null, "NODE_TYPES", null);
+ if (tables.next()) {
+ LOG.debug("NODE_TYPES table already exists");
+ } else {
+ String crTableCmd = "CREATE TABLE " + dbName + ".NODE_TYPES (" + "nodetype varchar(80) NOT NULL,"
+ + "CONSTRAINT P_NODE_TYPES PRIMARY KEY(nodetype))";
+
+ stmt = dbConn.createStatement();
+
+ stmt.executeUpdate(crTableCmd);
+ }
+ } catch (Exception e) {
+ throw new ConfigurationException("could not create SVC_LOGIC table", e);
+ } finally {
+ if (stmt != null) {
+ try {
+ stmt.close();
+ } catch (SQLException e) {
+ LOG.error("Statement close error ", e);
+ }
+ }
+ }
+
+ try {
+ InputStream testStr = getClass().getResourceAsStream("/parser-good.tests");
+ BufferedReader testsReader = new BufferedReader(new InputStreamReader(testStr));
+ String testCaseFile = null;
+ while ((testCaseFile = testsReader.readLine()) != null) {
+
+ testCaseFile = testCaseFile.trim();
+
+ if (testCaseFile.length() > 0) {
+ if (!testCaseFile.startsWith("/")) {
+ testCaseFile = "/" + testCaseFile;
+ }
+ URL testCaseUrl = getClass().getResource(testCaseFile);
+ if (testCaseUrl == null) {
+ fail("Could not resolve test case file " + testCaseFile);
+ }
+
+ try {
+ SvcLogicParser.load(testCaseUrl.getPath(), dblibStore);
+ } catch (Exception e) {
+
fail("Validation failure [" + e.getMessage() + "]");
}
}
@@ -152,7 +261,7 @@ public class ITCaseSvcLogicParser {
if (testCaseUrl == null) {
fail("Could not resolve test case file " + testCaseFile);
}
- SvcLogicParser.load(testCaseUrl.getPath(), store);
+ SvcLogicParser.validate(testCaseUrl.getPath(), store);
}
}
}
diff --git a/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/PrintYangToPropTest.java b/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/PrintYangToPropTest.java
index 21d3e59c..fb6eaf70 100644
--- a/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/PrintYangToPropTest.java
+++ b/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/PrintYangToPropTest.java
@@ -15,6 +15,9 @@ import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.Exe
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.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
+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.IpPrefixBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -50,6 +53,22 @@ public class PrintYangToPropTest {
pBuilder.setIntValue(null);
pBuilder.setBooleanValue(true);
pList.add(pBuilder.build());
+ pBuilder.setParameterName("ipaddress-value1");
+ pBuilder.setBooleanValue(null);
+ pBuilder.setIpaddressValue(IpAddressBuilder.getDefaultInstance("127.0.0.1"));
+ pList.add(pBuilder.build());
+ pBuilder.setParameterName("ipaddress-value1");
+ pBuilder.setIpaddressValue(IpAddressBuilder.getDefaultInstance("::1"));
+ pList.add(pBuilder.build());
+ pBuilder.setParameterName("ipprefix-value1");
+ pBuilder.setIpaddressValue(null);
+ pBuilder.setIpprefixValue(IpPrefixBuilder.getDefaultInstance("192.168.0.0/16"));
+ pList.add(pBuilder.build());
+ pBuilder.setParameterName("ipprefix-value2");
+ pBuilder.setIpprefixValue(IpPrefixBuilder.getDefaultInstance("2001:db8:3c4d::/48"));
+ pList.add(pBuilder.build());
+
+
egBuilder.setSliParameter(pList);
@@ -64,6 +83,9 @@ public class PrintYangToPropTest {
LOG.info("Property {} = {}", propName, props.getProperty(propName));
}
+ // Generate builder from properties just generated
+ PrintYangToProp.toBuilder(props, pBuilder);
+
}
}
diff --git a/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/TestMetricLogger.java b/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/TestMetricLogger.java
new file mode 100644
index 00000000..31a419bb
--- /dev/null
+++ b/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/TestMetricLogger.java
@@ -0,0 +1,135 @@
+package org.onap.ccsdk.sli.core.sli;
+
+import static org.junit.Assert.*;
+import java.util.Date;
+import org.junit.Before;
+import org.junit.Test;
+
+public class TestMetricLogger {
+
+ MetricLogger logger;
+
+ @Before
+ public void setUp() throws Exception {
+
+ logger = new MetricLogger();
+ logger.resetContext();
+ logger.logRequest("svcInstance1", "svcName", "svcPartner", "targetEntity", "targetServiceName", "targetVirtualEntity", "hello-world");
+ logger.logResponse("200", "200", "SUCCESS");
+
+ }
+
+ @Test
+ public final void testGetBeginTimestamp() {
+ logger.getBeginTimestamp();
+ }
+
+ @Test
+ public final void testGetEndTimestamp() {
+ logger.getEndTimestamp();
+ }
+
+ @Test
+ public final void testGetRequestID() {
+ logger.getRequestID();
+ }
+
+ @Test
+ public final void testGetServiceInstanceID() {
+ logger.getServiceInstanceID();
+ }
+
+ @Test
+ public final void testGetServiceName() {
+ logger.getServiceName();
+ }
+
+ @Test
+ public final void testGetPartnerName() {
+ logger.getPartnerName();
+ }
+
+ @Test
+ public final void testGetTargetEntity() {
+ logger.getTargetEntity();
+ }
+
+ @Test
+ public final void testGetTargetServiceName() {
+ logger.getTargetServiceName();
+ }
+
+ @Test
+ public final void testGetStatusCode() {
+ logger.getStatusCode();
+ }
+
+ @Test
+ public final void testGetResponseCode() {
+ logger.getResponseCode();
+ }
+
+ @Test
+ public final void testGetResponseDescription() {
+ logger.getResponseDescription();
+ }
+
+ @Test
+ public final void testGetInstanceUUID() {
+ logger.getInstanceUUID();
+ }
+
+ @Test
+ public final void testGetCategoryLogLevel() {
+ logger.getCategoryLogLevel();
+ }
+
+ @Test
+ public final void testGetSeverity() {
+ logger.getSeverity();
+ }
+
+ @Test
+ public final void testGetServerIpAddress() {
+ logger.getServerIpAddress();
+ }
+
+ @Test
+ public final void testGetElapsedTime() {
+ logger.getElapsedTime();
+ }
+
+ @Test
+ public final void testGetServer() {
+ logger.getServer();
+ }
+
+ @Test
+ public final void testGetClientIp() {
+ logger.getClientIp();
+ }
+
+ @Test
+ public final void testGetClassName() {
+ logger.getClassName();
+ }
+
+ @Test
+ public final void testGetTargetVirtualEntity() {
+ logger.getTargetVirtualEntity();
+ }
+
+ @Test
+ public final void testAsIso8601Date() {
+ logger.asIso8601(new Date());
+ }
+
+ @Test
+ public final void testAsIso8601Long() {
+ logger.asIso8601(System.currentTimeMillis());
+ }
+
+
+
+
+}
diff --git a/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/TestSvcLogicLoader.java b/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/TestSvcLogicLoader.java
new file mode 100644
index 00000000..8998382e
--- /dev/null
+++ b/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/TestSvcLogicLoader.java
@@ -0,0 +1,38 @@
+package org.onap.ccsdk.sli.core.sli;
+
+import static org.junit.Assert.*;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.Properties;
+import org.junit.Test;
+
+public class TestSvcLogicLoader {
+
+ @Test
+ public void testLoadAndActivate() throws IOException, SvcLogicException {
+ URL propUrl = ITCaseSvcLogicParser.class.getResource("/svclogic.properties");
+
+ InputStream propStr = ITCaseSvcLogicParser.class.getResourceAsStream("/svclogic.properties");
+
+ Properties props = new Properties();
+
+ props.load(propStr);
+
+ SvcLogicStore store = SvcLogicStoreFactory.getSvcLogicStore(props);
+
+ URL graphUrl = TestSvcLogicLoader.class.getClassLoader().getResource("graphs");
+
+ if (graphUrl == null) {
+ fail("Cannot find graphs directory");
+ }
+
+ SvcLogicLoader loader = new SvcLogicLoader(graphUrl.getPath(), store);
+ loader.loadAndActivate();
+
+
+ }
+
+
+
+}
diff --git a/sli/common/src/test/resources/dblib.properties b/sli/common/src/test/resources/dblib.properties
new file mode 100755
index 00000000..f08dce7a
--- /dev/null
+++ b/sli/common/src/test/resources/dblib.properties
@@ -0,0 +1,14 @@
+org.onap.ccsdk.sli.dbtype=jdbc
+org.onap.ccsdk.sli.jdbc.hosts=sdnctldb01,sdnctldb02
+org.onap.ccsdk.sli.jdbc.url=jdbc:derby:memory:test;create=true
+org.onap.ccsdk.sli.jdbc.driver=org.apache.derby.jdbc.EmbeddedDriver
+org.onap.ccsdk.sli.jdbc.database=test
+org.onap.ccsdk.sli.jdbc.user=test
+org.onap.ccsdk.sli.jdbc.password=test
+org.onap.ccsdk.sli.jdbc.connection.name=sdnctldb01
+
+org.onap.ccsdk.sli.jdbc.connection.timeout=50
+org.onap.ccsdk.sli.jdbc.request.timeout=100
+org.onap.ccsdk.sli.jdbc.limit.init=10
+org.onap.ccsdk.sli.jdbc.limit.min=10
+org.onap.ccsdk.sli.jdbc.limit.max=20
diff --git a/sli/common/src/test/resources/graphs/sliapi/graph.versions b/sli/common/src/test/resources/graphs/sliapi/graph.versions
new file mode 100644
index 00000000..d72920a4
--- /dev/null
+++ b/sli/common/src/test/resources/graphs/sliapi/graph.versions
@@ -0,0 +1 @@
+sli healthcheck 1.0.0 sync
diff --git a/sli/common/src/test/resources/graphs/sliapi/sli_healthcheck.xml b/sli/common/src/test/resources/graphs/sliapi/sli_healthcheck.xml
new file mode 100644
index 00000000..d512f546
--- /dev/null
+++ b/sli/common/src/test/resources/graphs/sliapi/sli_healthcheck.xml
@@ -0,0 +1,27 @@
+<!--
+ ============LICENSE_START=======================================================
+ openECOMP : SDN-C
+ ================================================================================
+ Copyright (C) 2017 AT&T Intellectual Property. 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=========================================================
+ -->
+
+<service-logic xmlns="http://www.onap.org/sdnc/svclogic"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.onap.org/sdnc/svclogic ./svclogic.xsd" module='sli' version='1.0.0'><method rpc='healthcheck' mode='sync'>
+<set>
+<parameter name='error-code' value='200' />
+<parameter name='error-message' value='SDN-C is healthy'/>
+<parameter name='ack-final' value='Y'/>
+</set></method></service-logic>
diff --git a/sli/common/src/test/resources/l3sdn_logic_v10.xml b/sli/common/src/test/resources/l3sdn_logic_v10.xml
new file mode 100644
index 00000000..58a420f9
--- /dev/null
+++ b/sli/common/src/test/resources/l3sdn_logic_v10.xml
@@ -0,0 +1,208 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- ============LICENSE_START=======================================================
+ ONAP : CCSDK ================================================================================
+ Copyright (C) 2017 AT&T Intellectual Property. 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========================================================= -->
+
+
+<service-logic xmlns="http://www.onap.org/sdnc/svclogic"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.onap.org/sdnc/svclogic ./svclogic.xsd"
+ module="neutron" version="1.0.0">
+
+ <method rpc="canCreateNetwork" mode="sync">
+ <return status="success">
+ <parameter name="error-code" value="200" />
+ </return>
+ </method>
+
+ <method rpc="switchTester" mode="sync">
+
+ <switch test="`$test-value`">
+ <outcome value="">
+ <return status="success">
+ <parameter name="visited-outcome" value="empty string" />
+ </return>
+ </outcome>
+ <outcome value="Other">
+ <return status="success">
+ <parameter name="visited-outcome" value="Other" />
+ </return>
+ </outcome>
+ </switch>
+
+
+ </method>
+
+ <method rpc="forRecordTester" mode="sync">
+ <for index="i" start="0" end="1">
+ <record plugin="org.onap.ccsdk.sli.core.sli.provider.DummyRecorder">
+ <parameter name="level" value="INFO"/>
+ <parameter name="field1" value="`forRecordTester message $i`"/>
+ </record>
+ </for>
+ </method>
+
+ <method rpc="whileNodeTester" mode="sync">
+ <while test="`$test-value`">
+ <break/>
+ </while>
+
+ </method>
+
+ <method rpc="resourceTester" mode="sync">
+ <block>
+ <set>
+ <parameter name='resource-plugin'
+ value='org.onap.ccsdk.sli.core.sli.provider.DummyResource' />
+ </set>
+
+ <save plugin="`$resource-plugin`" resource="sample" key="sample-key == 'resourceTester.status'">
+ <parameter name="sample-key" value="resourceTester.status"/>
+ <parameter name="sample-value" value="FAILED"/>
+ </save>
+
+ <update plugin="`$resource-plugin`" resource="sample" key="sample-key == 'resourceTester.status'">
+ <parameter name="sample-key" value="resourceTester.status"/>
+ <parameter name="sample-value" value="PASSED"/>
+ </update>
+
+ <get-resource plugin="`$resource-plugin`" resource="sample" key="sample-key == 'resourceTester.status'" pfx="sample"/>
+
+ <exists plugin="`$resource-plugin`" resource="sample" key="sample-key == 'resourceTester.status'"/>
+
+ <is-available plugin="`$resource-plugin`" resource="sample" key="sample-key == 'resourceTester.status'"/>
+
+ <reserve plugin="`$resource-plugin`" resource="sample" key="sample-key == 'resourceTester.status'"/>
+
+ <release plugin="`$resource-plugin`" resource="sample" key="sample-key == 'resourceTester.status'"/>
+
+
+ <reserve plugin="`$resource-plugin`" resource="sample" key="sample-key == 'resourceTester.status'"/>
+
+ <notify plugin="`$resource-plugin`" resource="sample" action="RESERVE"/>
+
+ <delete plugin="`$resource-plugin`" resource="sample" key="sample-key == 'resourceTester.status'"/>
+
+
+
+ </block>
+ </method>
+
+ <method rpc="configureTester" mode="sync">
+ <block>
+ <set>
+ <parameter name='configure-plugin'
+ value='org.onap.ccsdk.sli.core.sli.provider.DummyAdaptor' />
+ </set>
+ <configure adaptor="`$configure-plugin`" key="dummy" activate="true">
+ <parameter name="field1" value="1"/>
+ </configure>
+ <configure adaptor="`$configure-plugin`" key="SUCCESS" activate="true">
+ <parameter name="field1" value="1"/>
+ </configure>
+ <configure adaptor="`$configure-plugin`" key="ALREADY_ACTIVE" activate="true">
+ <parameter name="field1" value="1"/>
+ </configure>
+ <configure adaptor="`$configure-plugin`" key="NOT_FOUND" activate="true">
+ <parameter name="field1" value="1"/>
+ </configure>
+ <configure adaptor="`$configure-plugin`" key="NOT_READY" activate="true">
+ <parameter name="field1" value="1"/>
+ </configure>
+ <configure adaptor="`$configure-plugin`" key="FAILURE" activate="true">
+ <parameter name="field1" value="1"/>
+ </configure>
+ <configure adaptor="`$configure-plugin`" key="dummy" activate="false">
+ <parameter name="field1" value="1"/>
+ </configure>
+ <configure adaptor="`$configure-plugin`" key="SUCCESS" activate="false">
+ <parameter name="field1" value="1"/>
+ </configure>
+ <configure adaptor="`$configure-plugin`" key="ALREADY_ACTIVE" activate="false">
+ <parameter name="field1" value="1"/>
+ </configure>
+ <configure adaptor="`$configure-plugin`" key="NOT_FOUND" activate="false">
+ <parameter name="field1" value="1"/>
+ </configure>
+ <configure adaptor="`$configure-plugin`" key="NOT_READY" activate="false">
+ <parameter name="field1" value="1"/>
+ </configure>
+ <configure adaptor="`$configure-plugin`" key="FAILURE" activate="false">
+ <parameter name="field1" value="1"/>
+ </configure>
+
+ </block>
+ </method>
+
+
+ <method rpc="javaPluginTester" mode="sync">
+ <block>
+ <set>
+ <parameter name='java-plugin'
+ value='org.onap.ccsdk.sli.core.sli.provider.VoidDummyPlugin' />
+ </set>
+ <execute plugin="`$java-plugin`" method="dummy"/>
+ </block>
+ </method>
+
+ <method rpc="allNodesTester" mode="sync">
+ <block>
+ <set>
+ <parameter name='resource-plugin'
+ value='org.onap.ccsdk.sli.core.sli.provider.DummyResource' />
+ <parameter name='configure-plugin'
+ value='org.onap.ccsdk.sli.core.sli.provider.DummyAdaptor' />
+ <parameter name='java-plugin'
+ value='org.onap.ccsdk.sli.core.sli.provider.VoidDummyPlugin' />
+
+ </set>
+
+ <call rpc="switchTester" mode="sync" />
+
+ <call rpc="forRecordTester" mode="sync"/>
+
+ <call rpc="resourceTester" mode="sync"/>
+
+ <call rpc="configureTester" mode="sync"/>
+
+ <call rpc="javaPluginTester" mode="sync"/>
+
+ <call rpc="whileNodeTester" mode="sync"/>
+
+ </block>
+ </method>
+
+ <method rpc="networkCreated" mode="sync">
+ <switch
+ test="length($network.segment[0].provider-physical-network) >= 5 and substr($network.segment[0].provider-physical-network,0,5) == 'dvspg'">
+ <outcome value="true">
+ <block>
+ <set>
+ <parameter name="$vlanlist"
+ value="$network.segment[0].provider-segmentation-id" />
+ </set>
+ <for index="i" start="1" end="$network.num-segments">
+ <set>
+ <parameter name="$vlanlist"
+ value="eval($vlanlist+','+$network.segment[i].provider-segmentation-id)" />
+ </set>
+ </for>
+
+ </block>
+ </outcome>
+ <outcome value="Other">
+ <return status="success">
+ <parameter name="error-code" value="200" />
+ </return>
+ </outcome>
+ </switch>
+ </method>
+
+</service-logic>
diff --git a/sli/common/src/test/resources/parser-good.tests b/sli/common/src/test/resources/parser-good.tests
index 06543126..4147fdb6 100755
--- a/sli/common/src/test/resources/parser-good.tests
+++ b/sli/common/src/test/resources/parser-good.tests
@@ -1,2 +1,3 @@
ReleasePortSvcLogic_v101.xml
neutron_logic_v10.xml
+l3sdn_logic_v10.xml
diff --git a/sli/common/src/test/resources/svclogic.properties b/sli/common/src/test/resources/svclogic.properties
index 33d7ae6e..426960f7 100644
--- a/sli/common/src/test/resources/svclogic.properties
+++ b/sli/common/src/test/resources/svclogic.properties
@@ -20,7 +20,8 @@
###
org.onap.ccsdk.sli.dbtype = jdbc
-org.onap.ccsdk.sli.jdbc.url = jdbc:mysql://localhost:3306/test
-org.onap.ccsdk.sli.jdbc.database = test
+org.onap.ccsdk.sli.jdbc.url=jdbc:derby:memory:sdnctl;create=true
+org.onap.ccsdk.sli.jdbc.driver=org.apache.derby.jdbc.EmbeddedDriver
+org.onap.ccsdk.sli.jdbc.database = sdnctl
org.onap.ccsdk.sli.jdbc.user = test
-org.onap.ccsdk.sli.jdbc.password = test123
+org.onap.ccsdk.sli.jdbc.password = test
diff --git a/sli/common/src/test/resources/svclogic.xsd b/sli/common/src/test/resources/svclogic.xsd
index a63758f7..2704de88 100755
--- a/sli/common/src/test/resources/svclogic.xsd
+++ b/sli/common/src/test/resources/svclogic.xsd
@@ -30,6 +30,7 @@
<xsd:element ref="call" />
<xsd:element ref="notify" />
<xsd:element ref="break" />
+ <xsd:element ref="while" />
</xsd:choice>
</xsd:group>
@@ -320,4 +321,14 @@
<xsd:complexType />
</xsd:element>
+ <xsd:element name="while">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:group ref="node" minOccurs="0" maxOccurs="unbounded" />
+ </xsd:sequence>
+ <xsd:attribute name="test" use="required" type="xsd:string" />
+ <xsd:attribute name="do" use="optional" type="xsd:boolean" />
+ </xsd:complexType>
+ </xsd:element>
+
</xsd:schema>
diff --git a/sli/provider/pom.xml b/sli/provider/pom.xml
index 4a90ae00..1b21b002 100755
--- a/sli/provider/pom.xml
+++ b/sli/provider/pom.xml
@@ -1,44 +1,40 @@
<?xml version="1.0"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
- <parent>
+ <parent>
<groupId>org.onap.ccsdk.parent</groupId>
<artifactId>binding-parent</artifactId>
<version>1.0.1-SNAPSHOT</version>
- <relativePath/>
+ <relativePath />
</parent>
- <groupId>org.onap.ccsdk.sli.core</groupId>
- <artifactId>sli-provider</artifactId>
- <version>0.2.1-SNAPSHOT</version>
- <packaging>bundle</packaging>
+ <groupId>org.onap.ccsdk.sli.core</groupId>
+ <artifactId>sli-provider</artifactId>
+ <version>0.2.1-SNAPSHOT</version>
+ <packaging>bundle</packaging>
- <name>ccsdk-sli-core :: sli :: ${project.artifactId}</name>
- <description>SLI Provider is the OSGi bundle that exposes the service logic interpreter as a service.</description>
+ <name>ccsdk-sli-core :: sli :: ${project.artifactId}</name>
+ <description>SLI Provider is the OSGi bundle that exposes the service logic interpreter as a service.</description>
- <properties>
+ <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
- <dependencyManagement>
- <dependencies>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>mdsal-artifacts</artifactId>
- <version>1.6.1</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- </dependencies>
- </dependencyManagement>
- <dependencies>
- <dependency>
- <groupId>ch.vorburger.mariaDB4j</groupId>
- <artifactId>mariaDB4j</artifactId>
- <version>2.2.3</version>
- <scope>test</scope>
- </dependency>
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>mdsal-artifacts</artifactId>
+ <version>1.6.1</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+ <dependencies>
+
<dependency>
<groupId>org.onap.ccsdk.sli.core</groupId>
<artifactId>sli-model</artifactId>
@@ -62,11 +58,6 @@
<version>${slf4j.version}</version>
</dependency>
<dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>jcl-over-slf4j</artifactId>
- <version>${slf4j.version}</version>
- </dependency>
- <dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>${commons.lang.version}</version>
@@ -74,23 +65,28 @@
</dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-binding-api</artifactId>
- </dependency>
-
- <!-- Testing Dependencies -->
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>sal-binding-api</artifactId>
+ </dependency>
- <dependency>
- <groupId>org.mockito</groupId>
- <artifactId>mockito-core</artifactId>
- <scope>test</scope>
- </dependency>
+ <!-- Testing Dependencies -->
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-core</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.derby</groupId>
+ <artifactId>derby</artifactId>
+ <version>10.11.1.1</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
</project>
diff --git a/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/ITCaseSvcLogicGraphExecutor.java b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/ITCaseSvcLogicGraphExecutor.java
index 4c112ab2..0a8bf71a 100644
--- a/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/ITCaseSvcLogicGraphExecutor.java
+++ b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/ITCaseSvcLogicGraphExecutor.java
@@ -24,8 +24,7 @@ package org.onap.ccsdk.sli.core.sli.provider;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;
-import ch.vorburger.mariadb4j.DB;
-import ch.vorburger.mariadb4j.DBConfigurationBuilder;
+
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
@@ -40,6 +39,7 @@ import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
+import org.onap.ccsdk.sli.core.dblib.DBResourceManager;
import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
import org.onap.ccsdk.sli.core.sli.SvcLogicGraph;
import org.onap.ccsdk.sli.core.sli.SvcLogicParser;
@@ -74,6 +74,7 @@ public class ITCaseSvcLogicGraphExecutor {
put("set", new SetNodeExecutor());
put("switch", new SwitchNodeExecutor());
put("update", new UpdateNodeExecutor());
+ put("while", new WhileNodeExecutor());
}
};
@@ -88,16 +89,6 @@ public class ITCaseSvcLogicGraphExecutor {
Properties svcprops = new Properties();
svcprops.load(propStr);
- // Start MariaDB4j database
- DBConfigurationBuilder config = DBConfigurationBuilder.newBuilder();
- config.setPort(0); // 0 => autom. detect free port
- DB db = DB.newEmbeddedDB(config.build());
- db.start();
-
- // Override jdbc URL and database name
- svcprops.setProperty("org.onap.ccsdk.sli.jdbc.database", "test");
- svcprops.setProperty("org.onap.ccsdk.sli.jdbc.url", config.getURL("test"));
-
SvcLogicStore store = SvcLogicStoreFactory.getSvcLogicStore(svcprops);
assertNotNull(store);
@@ -144,18 +135,9 @@ public class ITCaseSvcLogicGraphExecutor {
Properties svcprops = new Properties();
svcprops.load(propStr);
- // Start MariaDB4j database
- DBConfigurationBuilder config = DBConfigurationBuilder.newBuilder();
- config.setPort(0); // 0 => autom. detect free port
- DB db = DB.newEmbeddedDB(config.build());
- db.start();
-
- // Override jdbc URL and database name
- svcprops.setProperty("org.onap.ccsdk.sli.jdbc.database", "test");
- svcprops.setProperty("org.onap.ccsdk.sli.jdbc.url", config.getURL("test"));
-
SvcLogicStore store = SvcLogicStoreFactory.getSvcLogicStore(svcprops);
+
assertNotNull(store);
@@ -214,10 +196,13 @@ public class ITCaseSvcLogicGraphExecutor {
fail("Could not resolve test case file " + testCaseFile);
}
+
LinkedList<SvcLogicGraph> graphs = parser.parse(testCaseUrl.getPath());
assertNotNull(graphs);
+ // Load grqphs into db to support call node
+ parser.load(testCaseUrl.getPath(), store);
for (SvcLogicGraph graph : graphs) {
if (graph.getRpc().equals(testCaseMethod)) {
Properties props = ctx.toProperties();
diff --git a/sli/provider/src/test/resources/executor.tests b/sli/provider/src/test/resources/executor.tests
index e4e60208..5468c8d6 100755
--- a/sli/provider/src/test/resources/executor.tests
+++ b/sli/provider/src/test/resources/executor.tests
@@ -1,6 +1,8 @@
l3sdn_logic_v10.xml:switchTester:test-value=""
l3sdn_logic_v10.xml:switchTester:test-value="hi"
l3sdn_logic_v10.xml:forRecordTester
+l3sdn_logic_v10.xml:whileNodeTester
l3sdn_logic_v10.xml:resourceTester
l3sdn_logic_v10.xml:configureTester
-l3sdn_logic_v10.xml:javaPluginTester \ No newline at end of file
+l3sdn_logic_v10.xml:javaPluginTester
+l3sdn_logic_v10.xml:allNodesTester \ No newline at end of file
diff --git a/sli/provider/src/test/resources/l3sdn_logic_v10.xml b/sli/provider/src/test/resources/l3sdn_logic_v10.xml
index 1386df10..cbb5db1b 100644
--- a/sli/provider/src/test/resources/l3sdn_logic_v10.xml
+++ b/sli/provider/src/test/resources/l3sdn_logic_v10.xml
@@ -49,6 +49,27 @@
</for>
</method>
+ <method rpc="whileNodeTester" mode="sync">
+ <block>
+ <set>
+ <parameter name="counter" value="0" />
+
+ </set>
+ <while test="`$counter &lt; 10`">
+ <set>
+ <parameter name="counter" value="`$counter + 1`" />
+ </set>
+
+ <switch test="`$counter > 6`">
+ <outcome value="true">
+ <break />
+ </outcome>
+ </switch>
+ </while>
+ </block>
+
+ </method>
+
<method rpc="resourceTester" mode="sync">
<block>
<set>
@@ -167,6 +188,8 @@
<call rpc="javaPluginTester" mode="sync"/>
+ <call rpc="whileNodeTester" mode="sync"/>
+
</block>
</method>
diff --git a/sli/provider/src/test/resources/svclogic.properties b/sli/provider/src/test/resources/svclogic.properties
index 49d39ab4..426960f7 100644
--- a/sli/provider/src/test/resources/svclogic.properties
+++ b/sli/provider/src/test/resources/svclogic.properties
@@ -19,7 +19,9 @@
# ============LICENSE_END=========================================================
###
-org.onap.ccsdk.sli.dbtype = dblib
+org.onap.ccsdk.sli.dbtype = jdbc
org.onap.ccsdk.sli.jdbc.url=jdbc:derby:memory:sdnctl;create=true
org.onap.ccsdk.sli.jdbc.driver=org.apache.derby.jdbc.EmbeddedDriver
org.onap.ccsdk.sli.jdbc.database = sdnctl
+org.onap.ccsdk.sli.jdbc.user = test
+org.onap.ccsdk.sli.jdbc.password = test
diff --git a/sliapi/provider/pom.xml b/sliapi/provider/pom.xml
index cb4dfc89..5650416d 100755
--- a/sliapi/provider/pom.xml
+++ b/sliapi/provider/pom.xml
@@ -1,73 +1,94 @@
<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.onap.ccsdk.parent</groupId>
- <artifactId>binding-parent</artifactId>
- <version>1.0.1-SNAPSHOT</version>
- <relativePath/>
- </parent>
+ <parent>
+ <groupId>org.onap.ccsdk.parent</groupId>
+ <artifactId>binding-parent</artifactId>
+ <version>1.0.1-SNAPSHOT</version>
+ <relativePath />
+ </parent>
- <groupId>org.onap.ccsdk.sli.core</groupId>
- <artifactId>sliapi-provider</artifactId>
- <version>0.2.1-SNAPSHOT</version>
- <packaging>bundle</packaging>
+ <groupId>org.onap.ccsdk.sli.core</groupId>
+ <artifactId>sliapi-provider</artifactId>
+ <version>0.2.1-SNAPSHOT</version>
+ <packaging>bundle</packaging>
- <name>ccsdk-sli-core :: sliapi :: ${project.artifactId}</name>
+ <name>ccsdk-sli-core :: sliapi :: ${project.artifactId}</name>
- <dependencyManagement>
- <dependencies>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>mdsal-artifacts</artifactId>
- <version>1.6.1</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- </dependencies>
- </dependencyManagement>
- <dependencies>
- <dependency>
- <groupId>org.onap.ccsdk.sli.core</groupId>
- <artifactId>sliapi-model</artifactId>
- <version>${project.version}</version>
- </dependency>
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>mdsal-artifacts</artifactId>
+ <version>1.6.1</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.onap.ccsdk.sli.core</groupId>
+ <artifactId>sliapi-model</artifactId>
+ <version>${project.version}</version>
+ </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-binding-config</artifactId>
- </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>sal-binding-config</artifactId>
+ </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-binding-api</artifactId>
- </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>sal-binding-api</artifactId>
+ </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-common-util</artifactId>
- </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>sal-common-util</artifactId>
+ </dependency>
- <dependency>
- <groupId>org.onap.ccsdk.sli.core</groupId>
- <artifactId>sli-common</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.onap.ccsdk.sli.core</groupId>
- <artifactId>sli-provider</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-core-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>yang-data-impl</artifactId>
- </dependency>
- </dependencies>
+ <dependency>
+ <groupId>org.onap.ccsdk.sli.core</groupId>
+ <artifactId>sli-common</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.ccsdk.sli.core</groupId>
+ <artifactId>sli-provider</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>sal-core-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.yangtools</groupId>
+ <artifactId>yang-data-impl</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>${junit.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-core</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.derby</groupId>
+ <artifactId>derby</artifactId>
+ <version>10.11.1.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
</project>
diff --git a/sliapi/provider/src/main/java/org/onap/ccsdk/sli/core/sliapi/sliapiProvider.java b/sliapi/provider/src/main/java/org/onap/ccsdk/sli/core/sliapi/sliapiProvider.java
index 3ff2f52d..e9a2b8eb 100644
--- a/sliapi/provider/src/main/java/org/onap/ccsdk/sli/core/sliapi/sliapiProvider.java
+++ b/sliapi/provider/src/main/java/org/onap/ccsdk/sli/core/sliapi/sliapiProvider.java
@@ -114,14 +114,16 @@ import com.google.common.util.concurrent.Futures;
*/
public class sliapiProvider implements AutoCloseable, SLIAPIService{
- private final Logger LOG = LoggerFactory.getLogger( sliapiProvider.class );
- private final String appName = "slitester";
+ private static final Logger LOG = LoggerFactory.getLogger( sliapiProvider.class );
+ private static final String appName = "slitester";
protected DataBroker dataBroker;
protected DOMDataBroker domDataBroker;
protected NotificationPublishService notificationService;
protected RpcProviderRegistry rpcRegistry;
+ private SvcLogicService svcLogic;
+
protected BindingAwareBroker.RpcRegistration<SLIAPIService> rpcRegistration;
private static String SLIAPI_NAMESPACE = "org:onap:ccsdk:sli:core:sliapi";
@@ -142,15 +144,23 @@ public class sliapiProvider implements AutoCloseable, SLIAPIService{
RESULTS_QNAME = QName.create(TEST_RESULT_QNAME, "results");
}
+ public sliapiProvider(
+ DataBroker dataBroker,
+ NotificationPublishService notificationPublishService,
+ RpcProviderRegistry rpcProviderRegistry) {
+ this(dataBroker, notificationPublishService, rpcProviderRegistry, findSvcLogicService());
+ }
public sliapiProvider(
DataBroker dataBroker,
NotificationPublishService notificationPublishService,
- RpcProviderRegistry rpcProviderRegistry) {
+ RpcProviderRegistry rpcProviderRegistry,
+ SvcLogicService svcLogic) {
this.LOG.info( "Creating provider for " + appName );
this.dataBroker = dataBroker;
this.notificationService = notificationPublishService;
this.rpcRegistry = rpcProviderRegistry;
+ this.svcLogic = svcLogic;
initialize();
}
@@ -357,6 +367,13 @@ public class sliapiProvider implements AutoCloseable, SLIAPIService{
private SvcLogicService getSvcLogicService() {
+ if (svcLogic == null) {
+ svcLogic = findSvcLogicService();
+ }
+
+ return(svcLogic);
+ }
+ private static SvcLogicService findSvcLogicService() {
BundleContext bctx = FrameworkUtil.getBundle(SvcLogicService.class).getBundleContext();
SvcLogicService svcLogic = null;
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
new file mode 100644
index 00000000..38cbd40c
--- /dev/null
+++ b/sliapi/provider/src/test/java/org/onap/ccsdk/sli/core/sliapi/TestSliapiProvider.java
@@ -0,0 +1,171 @@
+/**
+ *
+ */
+package org.onap.ccsdk.sli.core.sliapi;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
+import static org.mockito.Mockito.*;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.ccsdk.sli.core.sli.SvcLogicParser;
+import org.onap.ccsdk.sli.core.sli.SvcLogicStore;
+import org.onap.ccsdk.sli.core.sli.SvcLogicStoreFactory;
+import org.onap.ccsdk.sli.core.sli.provider.BlockNodeExecutor;
+import org.onap.ccsdk.sli.core.sli.provider.CallNodeExecutor;
+import org.onap.ccsdk.sli.core.sli.provider.ConfigureNodeExecutor;
+import org.onap.ccsdk.sli.core.sli.provider.DeleteNodeExecutor;
+import org.onap.ccsdk.sli.core.sli.provider.ExecuteNodeExecutor;
+import org.onap.ccsdk.sli.core.sli.provider.ExistsNodeExecutor;
+import org.onap.ccsdk.sli.core.sli.provider.ForNodeExecutor;
+import org.onap.ccsdk.sli.core.sli.provider.GetResourceNodeExecutor;
+import org.onap.ccsdk.sli.core.sli.provider.IsAvailableNodeExecutor;
+import org.onap.ccsdk.sli.core.sli.provider.NotifyNodeExecutor;
+import org.onap.ccsdk.sli.core.sli.provider.RecordNodeExecutor;
+import org.onap.ccsdk.sli.core.sli.provider.ReleaseNodeExecutor;
+import org.onap.ccsdk.sli.core.sli.provider.ReserveNodeExecutor;
+import org.onap.ccsdk.sli.core.sli.provider.ReturnNodeExecutor;
+import org.onap.ccsdk.sli.core.sli.provider.SaveNodeExecutor;
+import org.onap.ccsdk.sli.core.sli.provider.SetNodeExecutor;
+import org.onap.ccsdk.sli.core.sli.provider.SvcLogicNodeExecutor;
+import org.onap.ccsdk.sli.core.sli.provider.SvcLogicPropertiesProviderImpl;
+import org.onap.ccsdk.sli.core.sli.provider.SvcLogicServiceImpl;
+import org.onap.ccsdk.sli.core.sli.provider.SwitchNodeExecutor;
+import org.onap.ccsdk.sli.core.sli.provider.UpdateNodeExecutor;
+import org.onap.ccsdk.sli.core.sli.provider.WhileNodeExecutor;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
+import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ExecuteGraphInput;
+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.SLIAPIService;
+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;
+
+/**
+ * @author dt5972
+ *
+ */
+public class TestSliapiProvider {
+
+ private sliapiProvider provider;
+
+ private static final String HEALTHCHECK_DG = "sli_healthcheck.xml";
+
+ private static final Map<String, SvcLogicNodeExecutor> BUILTIN_NODES = new HashMap<String, SvcLogicNodeExecutor>() {
+ {
+ put("block", new BlockNodeExecutor());
+ put("call", new CallNodeExecutor());
+ put("configure", new ConfigureNodeExecutor());
+ put("delete", new DeleteNodeExecutor());
+ put("execute", new ExecuteNodeExecutor());
+ put("exists", new ExistsNodeExecutor());
+ put("for", new ForNodeExecutor());
+ put("get-resource", new GetResourceNodeExecutor());
+ put("is-available", new IsAvailableNodeExecutor());
+ put("notify", new NotifyNodeExecutor());
+ put("record", new RecordNodeExecutor());
+ put("release", new ReleaseNodeExecutor());
+ put("reserve", new ReserveNodeExecutor());
+ put("return", new ReturnNodeExecutor());
+ put("save", new SaveNodeExecutor());
+ put("set", new SetNodeExecutor());
+ put("switch", new SwitchNodeExecutor());
+ put("update", new UpdateNodeExecutor());
+ put("while", new WhileNodeExecutor());
+
+ }
+ };
+
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @Before
+ public void setUp() throws Exception {
+ 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);
+ 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();
+ svcprops.load(propStr);
+
+ SvcLogicStore store = SvcLogicStoreFactory.getSvcLogicStore(svcprops);
+
+ assertNotNull(store);
+
+ // Load the DG for the healthcheck api
+ URL testCaseUrl = TestSliapiProvider.class.getClassLoader().getResource(HEALTHCHECK_DG);
+ if (testCaseUrl == null) {
+ fail("Cannot find "+HEALTHCHECK_DG);
+ }
+ SvcLogicParser.load(testCaseUrl.getPath(), store);
+ SvcLogicParser.activate("sli", "healthcheck", "1.0.0", "sync", store);
+
+ // Create a ServiceLogicService and initialize it
+ SvcLogicServiceImpl svc = new SvcLogicServiceImpl(new SvcLogicPropertiesProviderImpl());
+ for (String nodeType : BUILTIN_NODES.keySet()) {
+ svc.registerExecutor(nodeType, BUILTIN_NODES.get(nodeType));
+ }
+
+ // Finally ready to create sliapiProvider
+ provider = new sliapiProvider(dataBroker, notifyService, rpcRegistry, svc);
+ provider.setDataBroker(dataBroker);
+ provider.setNotificationService(notifyService);
+ provider.setRpcRegistry(rpcRegistry);
+ }
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @After
+ public void tearDown() throws Exception {
+ provider.close();
+ }
+
+ /**
+ * 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() {
+ ExecuteGraphInputBuilder inputBuilder = new ExecuteGraphInputBuilder();
+
+ inputBuilder.setMode(ExecuteGraphInput.Mode.Sync);
+ inputBuilder.setModuleName("sli");
+ inputBuilder.setRpcName("healthcheck");
+ List<SliParameter> pList = new LinkedList<>();
+ SliParameterBuilder pBuilder = new SliParameterBuilder();
+ pBuilder.setParameterName("int-parameter");
+ pBuilder.setIntValue(1);
+ pList.add(pBuilder.build());
+ inputBuilder.setSliParameter(pList);
+
+
+
+
+ provider.executeGraph(inputBuilder.build());
+ }
+
+ /**
+ * Test method for {@link org.onap.ccsdk.sli.core.sliapi.sliapiProvider#healthcheck()}.
+ */
+ @Test
+ public void testHealthcheck() {
+ provider.healthcheck();
+ }
+
+}
diff --git a/sliapi/provider/src/test/resources/sli_healthcheck.xml b/sliapi/provider/src/test/resources/sli_healthcheck.xml
new file mode 100644
index 00000000..d512f546
--- /dev/null
+++ b/sliapi/provider/src/test/resources/sli_healthcheck.xml
@@ -0,0 +1,27 @@
+<!--
+ ============LICENSE_START=======================================================
+ openECOMP : SDN-C
+ ================================================================================
+ Copyright (C) 2017 AT&T Intellectual Property. 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=========================================================
+ -->
+
+<service-logic xmlns="http://www.onap.org/sdnc/svclogic"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.onap.org/sdnc/svclogic ./svclogic.xsd" module='sli' version='1.0.0'><method rpc='healthcheck' mode='sync'>
+<set>
+<parameter name='error-code' value='200' />
+<parameter name='error-message' value='SDN-C is healthy'/>
+<parameter name='ack-final' value='Y'/>
+</set></method></service-logic>
diff --git a/sli/provider/src/main/resources/svclogic.properties b/sliapi/provider/src/test/resources/svclogic.properties
index 49d39ab4..426960f7 100644
--- a/sli/provider/src/main/resources/svclogic.properties
+++ b/sliapi/provider/src/test/resources/svclogic.properties
@@ -19,7 +19,9 @@
# ============LICENSE_END=========================================================
###
-org.onap.ccsdk.sli.dbtype = dblib
+org.onap.ccsdk.sli.dbtype = jdbc
org.onap.ccsdk.sli.jdbc.url=jdbc:derby:memory:sdnctl;create=true
org.onap.ccsdk.sli.jdbc.driver=org.apache.derby.jdbc.EmbeddedDriver
org.onap.ccsdk.sli.jdbc.database = sdnctl
+org.onap.ccsdk.sli.jdbc.user = test
+org.onap.ccsdk.sli.jdbc.password = test