Refinements to core
authorGaurav Agrawal <gaurav.agrawal@huawei.com>
Wed, 27 Sep 2017 10:43:04 +0000 (16:13 +0530)
committerGaurav Agrawal <gaurav.agrawal@huawei.com>
Wed, 27 Sep 2017 10:43:04 +0000 (16:13 +0530)
Changes includes:
1. Simplifying the test cases.
2. Critical Sonar issue fix for MdsalHelper
3. Critical sonar issue fix for SvcLogicServiceImpl
4. Use logger in-built formatting.
https://sonar.onap.org/component_issues/index?id=org.onap.ccsdk.sli.core%3Accsdk-sli-core#resolved=false|severities=CRITICAL

Change-Id: Ib85637fcd2351970f8d96bf6b855db05cf7d9834
Issue-Id: CCSDK-67
Signed-off-by: Gaurav Agrawal <gaurav.agrawal@huawei.com>
sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/ITCaseSvcLogicParser.java
sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/MdsalHelper.java
sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicServiceImpl.java
sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/ITCaseSvcLogicGraphExecutor.java

index 7af4c1c..0912ee9 100644 (file)
@@ -28,6 +28,7 @@ import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.fail;
 
 import java.io.BufferedReader;
+import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.net.URL;
@@ -103,117 +104,81 @@ public class ITCaseSvcLogicParser {
                store.registerNodeType("save");
                store.registerNodeType("update");
                store.registerNodeType("break");
-       }
-
-       @Before
-       public void setUp() throws Exception {
-               LOG.info("before");
-       }
-
-       @After
-       public void tearDown() throws Exception {
-               LOG.info("after");
-       }
-
-       @AfterClass
-       public static void tearDownAfterClass() throws Exception {
-               LOG.info("after class");
-       }
-
-       /**
-        * Test method for {@link org.onap.ccsdk.sli.core.sli.SvcLogicParser#parse(java.lang.String)}.
-        */
-       @Test
-       public void testParseValidXml() {
-
-               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.validate(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 testParseInvalidXml() {
-
-               try
-               {
-                       InputStream testStr = getClass().getResourceAsStream("/parser-bad.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);
-                                       }
-
-                                       boolean valid = true;
-                                       try {
-                                               SvcLogicParser.load(testCaseUrl.getPath(), store);
-                                       } catch (Exception e) {
-                                               System.out.println(e.getMessage());
-                                               valid = false;
-                                       }
-
-                                       if (valid) {
-                                               fail("Expected compiler error on "+testCaseFile+", but got success");
-                                       }
-                               }
-                       }
-               }
-               catch (SvcLogicParserException e)
-               {
-                       fail("Parser error : "+e.getMessage());
-               }
-               catch (Exception e)
-               {
-                       LOG.error("", e);
-                       fail("Caught exception processing test cases");
-               }
-
-       }
-
+    }
+
+    @AfterClass
+    public static void tearDownAfterClass() throws Exception {
+        LOG.info("after class");
+    }
+
+    @Before
+    public void setUp() throws Exception {
+        LOG.info("before");
+    }
+
+    @After
+    public void tearDown() throws Exception {
+        LOG.info("after");
+    }
+
+    /**
+     * Test method for {@link org.onap.ccsdk.sli.core.sli.SvcLogicParser#parse(java.lang.String)}.
+     */
+    @Test
+    public void testParseValidXml() {
+
+        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.validate(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(expected = SvcLogicException.class)
+    public void testParseInvalidXml() throws SvcLogicException, IOException {
+
+        InputStream testStr = getClass().getResourceAsStream("/parser-bad.tests");
+        BufferedReader testsReader = new BufferedReader(new InputStreamReader(testStr));
+        String testCaseFile;
+        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);
+                }
+                SvcLogicParser.load(testCaseUrl.getPath(), store);
+            }
+        }
+    }
 }
index 3eeb398..52c25b6 100644 (file)
@@ -765,7 +765,7 @@ public class MdsalHelper {
 
                                                 } catch (Exception gme) {
                                                     LOG.info("Unable to find static method getDefaultInstance for "
-                                                        + "class {}", paramClass.getSimpleName(), e);
+                                                        + "class {}", paramClass.getSimpleName(), gme);
                                                 }
                                             }
 
index 4bb460d..5f4d365 100644 (file)
@@ -59,12 +59,11 @@ public class SvcLogicServiceImpl implements SvcLogicService {
         }
 
         if (nodeExecutors == null) {
-            nodeExecutors = new HashMap<String, SvcLogicNodeExecutor>();
+            nodeExecutors = new HashMap<>();
         }
 
         LOG.info("Opening service tracker");
-        ServiceTracker tracker = new ServiceTracker(bctx,
-                SvcLogicNodeExecutor.class.getName(), null);
+        ServiceTracker tracker = new ServiceTracker(bctx, SvcLogicNodeExecutor.class.getName(), null);
 
         tracker.open();
 
@@ -90,14 +89,12 @@ public class SvcLogicServiceImpl implements SvcLogicService {
                 + ")";
         try {
             bctx.addServiceListener(listener, filter);
-            ServiceReference[] srl = bctx.getServiceReferences(
-                    SvcLogicNodeExecutor.class.getName(), null);
+            ServiceReference[] srl = bctx.getServiceReferences(SvcLogicNodeExecutor.class.getName(), null);
             for (int i = 0; srl != null && i < srl.length; i++) {
-                listener.serviceChanged(new ServiceEvent(
-                        ServiceEvent.REGISTERED, srl[i]));
+                listener.serviceChanged(new ServiceEvent(ServiceEvent.REGISTERED, srl[i]));
             }
         } catch (InvalidSyntaxException e) {
-            e.printStackTrace();
+            LOG.info("Invalid syntax", e);
         }
         LOG.info("Done registerExecutors");
     }
@@ -107,26 +104,24 @@ public class SvcLogicServiceImpl implements SvcLogicService {
         String nodeName = (String) sr.getProperty("nodeType");
         if (nodeName != null) {
 
-            SvcLogicNodeExecutor executor = null;
+            SvcLogicNodeExecutor executor;
 
             try {
                 executor = (SvcLogicNodeExecutor) bctx.getService(sr);
             } catch (Exception e) {
-                LOG.error("Cannot get service executor for " + nodeName);
+                LOG.error("Cannot get service executor for {}", nodeName, e);
                 return;
             }
-
             registerExecutor(nodeName, executor);
-
         }
     }
 
     public void registerExecutor(String nodeName, SvcLogicNodeExecutor executor)
     {
         if (nodeExecutors == null) {
-            nodeExecutors = new HashMap<String, SvcLogicNodeExecutor>();
+            nodeExecutors = new HashMap<>();
         }
-        LOG.info("SLI - registering executor for node type "+nodeName);
+        LOG.info("SLI - registering executor for node type {}", nodeName);
         nodeExecutors.put(nodeName, executor);
     }
 
@@ -134,25 +129,16 @@ public class SvcLogicServiceImpl implements SvcLogicService {
         String nodeName = (String) sr.getProperty("nodeType");
 
         if (nodeName != null) {
-
              unregisterExecutor(nodeName);
-
         }
-
     }
 
-    public void unregisterExecutor(String nodeName)
-    {
-
-        LOG.info("SLI - unregistering executor for node type "+nodeName);
+    public void unregisterExecutor(String nodeName) {
+        LOG.info("SLI - unregistering executor for node type {}", nodeName);
         nodeExecutors.remove(nodeName);
     }
 
-
-
-
-    public SvcLogicContext execute(SvcLogicGraph graph, SvcLogicContext ctx)
-            throws SvcLogicException {
+    public SvcLogicContext execute(SvcLogicGraph graph, SvcLogicContext ctx) throws SvcLogicException {
 
         if (nodeExecutors == null) {
             registerExecutors();
@@ -164,13 +150,11 @@ public class SvcLogicServiceImpl implements SvcLogicService {
         MDC.put("currentGraph", graph.toString());
 
         SvcLogicNode curNode = graph.getRootNode();
-        LOG.info("About to execute graph " + graph.toString());
-
-
+        LOG.info("About to execute graph {}", graph.toString());
 
         while (curNode != null) {
             MDC.put("nodeId", curNode.getNodeId()+" ("+curNode.getNodeType()+")");
-            LOG.info("About to execute node # "+curNode.getNodeId()+" ("+curNode.getNodeType()+")");
+            LOG.info("About to execute node # {} ({})", curNode.getNodeId(), curNode.getNodeType());
 
             SvcLogicNode nextNode = executeNode(curNode, ctx);
             curNode = nextNode;
@@ -181,25 +165,24 @@ public class SvcLogicServiceImpl implements SvcLogicService {
         return (ctx);
     }
 
-
-    public SvcLogicNode executeNode(SvcLogicNode node, SvcLogicContext ctx)
-            throws SvcLogicException {
+    public SvcLogicNode executeNode(SvcLogicNode node, SvcLogicContext ctx) throws SvcLogicException {
         if (node == null) {
             return (null);
         }
 
         if (LOG.isDebugEnabled()) {
-            LOG.debug("Executing node " + node.getNodeId());
+            LOG.debug("Executing node {}", node.getNodeId());
         }
 
         SvcLogicNodeExecutor executor = nodeExecutors.get(node.getNodeType());
 
         if (executor != null) {
-            LOG.debug("Executing node executor for node type "+node.getNodeType()+" - "+executor.getClass().getName());
+            LOG.debug("Executing node executor for node type {} - {}",
+                node.getNodeType(), executor.getClass().getName());
             return (executor.execute(this, node, ctx));
         } else {
             if (LOG.isDebugEnabled()) {
-                LOG.debug(node.getNodeType() + " node not implemented");
+                LOG.debug("{} node not implemented", node.getNodeType());
             }
             SvcLogicNode nextNode = node.getOutcomeValue("failure");
             if (nextNode != null) {
@@ -243,23 +226,18 @@ public class SvcLogicServiceImpl implements SvcLogicService {
     public Properties execute(String module, String rpc, String version, String mode,
             Properties props, DOMDataBroker domDataBroker) throws SvcLogicException {
 
-
         // See if there is a service logic defined
-        //
         SvcLogicStore store = SvcLogicActivator.getStore();
 
         LOG.info("Fetching service logic from data store");
         SvcLogicGraph graph = store.fetch(module, rpc, version, mode);
 
-
-
         if (graph == null)
         {
             Properties retProps = new Properties();
             retProps.setProperty("error-code", "401");
             retProps.setProperty("error-message", "No service logic found for ["+module+","+rpc+","+version+","+mode+"]");
             return(retProps);
-
         }
 
         SvcLogicContext ctx = new SvcLogicContext(props);
@@ -271,8 +249,4 @@ public class SvcLogicServiceImpl implements SvcLogicService {
 
         return(ctx.toProperties());
     }
-
-
-
-
 }
index cdf837a..0a0e28c 100644 (file)
 
 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;
@@ -30,7 +35,11 @@ import java.util.HashMap;
 import java.util.LinkedList;
 import java.util.Map;
 import java.util.Properties;
-
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
 import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
 import org.onap.ccsdk.sli.core.sli.SvcLogicGraph;
 import org.onap.ccsdk.sli.core.sli.SvcLogicParser;
@@ -39,170 +48,220 @@ import org.onap.ccsdk.sli.core.sli.SvcLogicStoreFactory;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import ch.vorburger.mariadb4j.DB;
-import ch.vorburger.mariadb4j.DBConfigurationBuilder;
-import junit.framework.TestCase;
-
-public class ITCaseSvcLogicGraphExecutor extends TestCase {
-       private static final Logger LOG = LoggerFactory
-                       .getLogger(SvcLogicGraph.class);
-
-       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());
-
-               }
-       };
-
-       public void testExecute() {
-
-               try {
-                       InputStream testStr = getClass().getResourceAsStream("/executor.tests");
-                       BufferedReader testsReader = new BufferedReader(new InputStreamReader(testStr));
-
-                       InputStream propStr = getClass().getResourceAsStream("/svclogic.properties");
-
-                       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);
-
-                       store.registerNodeType("switch");
-                       store.registerNodeType("block");
-                       store.registerNodeType("get-resource");
-                       store.registerNodeType("reserve");
-                       store.registerNodeType("is-available");
-                       store.registerNodeType("exists");
-                       store.registerNodeType("configure");
-                       store.registerNodeType("return");
-                       store.registerNodeType("record");
-                       store.registerNodeType("allocate");
-                       store.registerNodeType("release");
-                       store.registerNodeType("for");
-                       store.registerNodeType("set");
-                       SvcLogicParser parser = new SvcLogicParser(store);
-
-                       // Loop through executor tests
-
-                       SvcLogicServiceImpl svc = new SvcLogicServiceImpl();
-
-                       for (String nodeType : BUILTIN_NODES.keySet()) {
-
-                               LOG.info("SLI - registering node executor for node type "+nodeType);
-
-                               svc.registerExecutor(nodeType, BUILTIN_NODES.get(nodeType));
-
-                       }
-                       String testCaseLine = null;
-                       while ((testCaseLine = testsReader.readLine()) != null) {
-
-                               String[] testCaseFields = testCaseLine.split(":");
-                               String testCaseFile = testCaseFields[0];
-                               String testCaseMethod = testCaseFields[1];
-                               String testCaseParameters = null;
-
-                               if (testCaseFields.length > 2) {
-                                       testCaseParameters = testCaseFields[2];
-                               }
-
-                               SvcLogicContext ctx = new SvcLogicContext();
-                               if (testCaseParameters != null) {
-                                       String[] testCaseParameterSettings = testCaseParameters.split(",");
-
-                                       for (int i = 0 ; i < testCaseParameterSettings.length ; i++) {
-                                               String[] nameValue = testCaseParameterSettings[i].split("=");
-                                               if (nameValue != null) {
-                                                       String name = nameValue[0];
-                                                       String value = "";
-                                                       if (nameValue.length > 1) {
-                                                               value = nameValue[1];
-                                                       }
-
-                                                       ctx.setAttribute(name,  value);
-                                               }
-                                       }
-                               }
-
-                               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);
-                                       }
-
-                                       LinkedList<SvcLogicGraph> graphs = parser.parse(testCaseUrl.getPath());
-
-
-                                       assertNotNull(graphs);
-
-                                       for (SvcLogicGraph graph: graphs) {
-                                               if (graph.getRpc().equals(testCaseMethod)) {
-                                                       Properties props = ctx.toProperties();
-                                                       LOG.info("SvcLogicContext before executing "+testCaseMethod+":");
-                                                       for (Enumeration e1 = props.propertyNames(); e1.hasMoreElements() ; ) {
-                                                               String propName = (String) e1.nextElement();
-                                                               LOG.info(propName+" = "+props.getProperty(propName));
-                                                       }
-
-                                                       svc.execute(graph, ctx);
-
-                                                       props = ctx.toProperties();
-                                                       LOG.info("SvcLogicContext after executing "+testCaseMethod+":");
-                                                       for (Enumeration e2 = props.propertyNames(); e2.hasMoreElements() ; ) {
-                                                               String propName = (String) e2.nextElement();
-                                                               LOG.info(propName+" = "+props.getProperty(propName));
-                                                       }
-                                               }
-                                       }
-
-                               }
-
-
-                       }
-
-
-               } catch (Exception e) {
-                       LOG.error("Caught exception executing directed graphs", e);
-                       fail("Exception executing graphs");
-               }
-       }
-
-
+public class ITCaseSvcLogicGraphExecutor {
+
+    private static final Logger LOG = LoggerFactory.getLogger(SvcLogicGraph.class);
+    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());
+
+        }
+    };
+
+    @BeforeClass
+    public static void setUpBeforeClass() throws Exception {
+
+        LOG.info("before class");
+
+        InputStream propStr = ITCaseSvcLogicGraphExecutor.class.getResourceAsStream("/svclogic.properties");
+
+        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);
+
+        store.registerNodeType("switch");
+        store.registerNodeType("block");
+        store.registerNodeType("get-resource");
+        store.registerNodeType("reserve");
+        store.registerNodeType("is-available");
+        store.registerNodeType("exists");
+        store.registerNodeType("configure");
+        store.registerNodeType("return");
+        store.registerNodeType("record");
+        store.registerNodeType("allocate");
+        store.registerNodeType("release");
+        store.registerNodeType("for");
+        store.registerNodeType("set");
+        SvcLogicParser parser = new SvcLogicParser(store);
+
+        // Loop through executor tests
+
+        SvcLogicServiceImpl svc = new SvcLogicServiceImpl();
+
+        for (String nodeType : BUILTIN_NODES.keySet()) {
+            LOG.info("SLI - registering node executor for node type " + nodeType);
+            svc.registerExecutor(nodeType, BUILTIN_NODES.get(nodeType));
+        }
+    }
+
+    @AfterClass
+    public static void tearDownAfterClass() throws Exception {
+        LOG.info("after class");
+    }
+
+    @Before
+    public void setUp() throws Exception {
+        LOG.info("before");
+    }
+
+    @After
+    public void tearDown() throws Exception {
+        LOG.info("after");
+    }
+
+    @Test
+    public void testExecute() {
+
+        try {
+            InputStream testStr = getClass().getResourceAsStream("/executor.tests");
+            BufferedReader testsReader = new BufferedReader(new InputStreamReader(testStr));
+
+            InputStream propStr = getClass().getResourceAsStream("/svclogic.properties");
+
+            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);
+
+            store.registerNodeType("switch");
+            store.registerNodeType("block");
+            store.registerNodeType("get-resource");
+            store.registerNodeType("reserve");
+            store.registerNodeType("is-available");
+            store.registerNodeType("exists");
+            store.registerNodeType("configure");
+            store.registerNodeType("return");
+            store.registerNodeType("record");
+            store.registerNodeType("allocate");
+            store.registerNodeType("release");
+            store.registerNodeType("for");
+            store.registerNodeType("set");
+            SvcLogicParser parser = new SvcLogicParser(store);
+
+            // Loop through executor tests
+
+            SvcLogicServiceImpl svc = new SvcLogicServiceImpl();
+
+            for (String nodeType : BUILTIN_NODES.keySet()) {
+
+                LOG.info("SLI - registering node executor for node type {}", nodeType);
+
+                svc.registerExecutor(nodeType, BUILTIN_NODES.get(nodeType));
+
+            }
+            String testCaseLine = null;
+            while ((testCaseLine = testsReader.readLine()) != null) {
+
+                String[] testCaseFields = testCaseLine.split(":");
+                String testCaseFile = testCaseFields[0];
+                String testCaseMethod = testCaseFields[1];
+                String testCaseParameters = null;
+
+                if (testCaseFields.length > 2) {
+                    testCaseParameters = testCaseFields[2];
+                }
+
+                SvcLogicContext ctx = new SvcLogicContext();
+                if (testCaseParameters != null) {
+                    String[] testCaseParameterSettings = testCaseParameters.split(",");
+
+                    for (int i = 0; i < testCaseParameterSettings.length; i++) {
+                        String[] nameValue = testCaseParameterSettings[i].split("=");
+                        if (nameValue != null) {
+                            String name = nameValue[0];
+                            String value = "";
+                            if (nameValue.length > 1) {
+                                value = nameValue[1];
+                            }
+
+                            ctx.setAttribute(name, value);
+                        }
+                    }
+                }
+
+                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);
+                    }
+
+                    LinkedList<SvcLogicGraph> graphs = parser.parse(testCaseUrl.getPath());
+
+                    assertNotNull(graphs);
+
+                    for (SvcLogicGraph graph : graphs) {
+                        if (graph.getRpc().equals(testCaseMethod)) {
+                            Properties props = ctx.toProperties();
+                            LOG.info("SvcLogicContext before executing {}:", testCaseMethod);
+                            for (Enumeration e1 = props.propertyNames(); e1.hasMoreElements(); ) {
+                                String propName = (String) e1.nextElement();
+                                LOG.info(propName + " = " + props.getProperty(propName));
+                            }
+
+                            svc.execute(graph, ctx);
+
+                            props = ctx.toProperties();
+                            LOG.info("SvcLogicContext after executing {}:", testCaseMethod);
+                            for (Enumeration e2 = props.propertyNames(); e2.hasMoreElements(); ) {
+                                String propName = (String) e2.nextElement();
+                                LOG.info(propName + " = " + props.getProperty(propName));
+                            }
+                        }
+                    }
+
+                }
+            }
+
+        } catch (Exception e) {
+            LOG.error("Caught exception executing directed graphs", e);
+            fail("Exception executing graphs");
+        }
+    }
 }