aboutsummaryrefslogtreecommitdiffstats
path: root/sli/provider/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'sli/provider/src/test')
-rw-r--r--sli/provider/src/test/java/org/openecomp/sdnc/sli/provider/BadPlugin.java56
-rw-r--r--sli/provider/src/test/java/org/openecomp/sdnc/sli/provider/ExecuteNodeExecutorTest.java57
-rw-r--r--sli/provider/src/test/java/org/openecomp/sdnc/sli/provider/LunchSelectorPlugin.java78
-rw-r--r--sli/provider/src/test/java/org/openecomp/sdnc/sli/provider/MdsalHelperTest.java43
-rw-r--r--sli/provider/src/test/java/org/openecomp/sdnc/sli/provider/MdsalHelperTesterUtil.java37
-rw-r--r--sli/provider/src/test/java/org/openecomp/sdnc/sli/provider/PluginTest.java106
-rw-r--r--sli/provider/src/test/java/org/openecomp/sdnc/sli/provider/SvcLogicExpressionResolverTest.java123
-rw-r--r--sli/provider/src/test/java/org/openecomp/sdnc/sli/provider/SvcLogicGraphExecutorTest.java212
-rw-r--r--sli/provider/src/test/java/org/openecomp/sdnc/sli/provider/VoidDummyPlugin.java38
-rw-r--r--sli/provider/src/test/resources/executor.tests2
-rw-r--r--sli/provider/src/test/resources/expression.tests24
-rw-r--r--sli/provider/src/test/resources/l3sdn_logic_v10.xml74
-rw-r--r--sli/provider/src/test/resources/simplelogger.properties22
-rw-r--r--sli/provider/src/test/resources/svclogic.properties26
14 files changed, 0 insertions, 898 deletions
diff --git a/sli/provider/src/test/java/org/openecomp/sdnc/sli/provider/BadPlugin.java b/sli/provider/src/test/java/org/openecomp/sdnc/sli/provider/BadPlugin.java
deleted file mode 100644
index d1ab4cf..0000000
--- a/sli/provider/src/test/java/org/openecomp/sdnc/sli/provider/BadPlugin.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*-
- * ============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=========================================================
- */
-
-package org.openecomp.sdnc.sli.provider;
-
-import java.util.Map;
-
-import org.openecomp.sdnc.sli.SvcLogicContext;
-import org.openecomp.sdnc.sli.SvcLogicException;
-import org.openecomp.sdnc.sli.SvcLogicJavaPlugin;
-
-
-public class BadPlugin implements SvcLogicJavaPlugin {
- public String selectLunch(Map<String, String> parameters, SvcLogicContext ctx) throws SvcLogicException {
- String day = parameters.get("day");
- if (day == null || day.length() < 1) {
- throw new SvcLogicException("What day is it?");
- }
- switch (day) {
- case ("monday"): {
- return "pizza";
- }
- case ("tuesday"): {
- return "soup";
- }
- case ("wednesday"): {
- return "salad";
- }
- case ("thursday"): {
- return "sushi";
- }
- case ("friday"): {
- return "bbq";
- }
- }
- throw new SvcLogicException("Lunch cannot be served");
- }
-}
diff --git a/sli/provider/src/test/java/org/openecomp/sdnc/sli/provider/ExecuteNodeExecutorTest.java b/sli/provider/src/test/java/org/openecomp/sdnc/sli/provider/ExecuteNodeExecutorTest.java
deleted file mode 100644
index 3d43ee1..0000000
--- a/sli/provider/src/test/java/org/openecomp/sdnc/sli/provider/ExecuteNodeExecutorTest.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*-
- * ============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=========================================================
- */
-
-package org.openecomp.sdnc.sli.provider;
-
-import java.util.Map.Entry;
-
-import org.openecomp.sdnc.sli.DuplicateValueException;
-import org.openecomp.sdnc.sli.SvcLogicContext;
-import org.openecomp.sdnc.sli.SvcLogicException;
-import org.openecomp.sdnc.sli.SvcLogicExpression;
-import org.openecomp.sdnc.sli.SvcLogicGraph;
-import org.openecomp.sdnc.sli.SvcLogicJavaPlugin;
-import org.openecomp.sdnc.sli.SvcLogicNode;
-
-import junit.framework.TestCase;
-
-public class ExecuteNodeExecutorTest extends TestCase {
- public class MockExecuteNodeExecutor extends ExecuteNodeExecutor {
-
- protected SvcLogicJavaPlugin getSvcLogicJavaPlugin(String pluginName) {
- return (SvcLogicJavaPlugin) new LunchSelectorPlugin();
- }
-
- protected String evaluate(SvcLogicExpression expr, SvcLogicNode node,
- SvcLogicContext ctx) throws SvcLogicException {
- return "selectLunch";
- }
- }
-
- public void testBadPlugin() throws DuplicateValueException, SvcLogicException {
- LunchSelectorPlugin p = new LunchSelectorPlugin();
- MockExecuteNodeExecutor execute = new MockExecuteNodeExecutor();
- SvcLogicNode node = new SvcLogicNode(0, "", "", new SvcLogicGraph());
- node.setAttribute("method", "selectLunch");
- execute.execute(new SvcLogicServiceImpl(), new SvcLogicNode(0, "", "", new SvcLogicGraph()), new SvcLogicContext());
- }
-
-}
diff --git a/sli/provider/src/test/java/org/openecomp/sdnc/sli/provider/LunchSelectorPlugin.java b/sli/provider/src/test/java/org/openecomp/sdnc/sli/provider/LunchSelectorPlugin.java
deleted file mode 100644
index b9156bc..0000000
--- a/sli/provider/src/test/java/org/openecomp/sdnc/sli/provider/LunchSelectorPlugin.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*-
- * ============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=========================================================
- */
-
-package org.openecomp.sdnc.sli.provider;
-
-import java.util.Map;
-
-import org.openecomp.sdnc.sli.SvcLogicContext;
-import org.openecomp.sdnc.sli.SvcLogicException;
-import org.openecomp.sdnc.sli.SvcLogicJavaPlugin;
-
-
-
-public class LunchSelectorPlugin implements SvcLogicJavaPlugin {
- public class UnknownLunchDayException extends Exception{
-
- public UnknownLunchDayException(String string) {
- super(string);
- }
-
- }
- class Sandwhich {
- String meat;
- String cheese;
-
- public Sandwhich(String meat, String cheese) {
- this.meat = meat;
- this.cheese = cheese;
- }
- }
-
- public String selectLunch(Map<String, String> parameters, SvcLogicContext ctx) throws Exception {
- String day = parameters.get("day");
- if (day == null || day.length() < 1) {
- throw new UnknownLunchDayException("What day is it?");
- }
- switch (day) {
- case ("monday"): {
- return "pizza";
- }
- case ("tuesday"): {
- return "soup";
- }
- case ("wednesday"): {
- return "salad";
- }
- case ("thursday"): {
- return "sushi";
- }
- case ("friday"): {
- return "bbq";
- }
- }
- throw new SvcLogicException("Lunch cannot be served");
- }
-
- public Sandwhich makeLunch(Map<String, String> parameters, SvcLogicContext ctx) throws SvcLogicException {
- return new Sandwhich("ham", "american");
- }
-}
diff --git a/sli/provider/src/test/java/org/openecomp/sdnc/sli/provider/MdsalHelperTest.java b/sli/provider/src/test/java/org/openecomp/sdnc/sli/provider/MdsalHelperTest.java
deleted file mode 100644
index a4e41bb..0000000
--- a/sli/provider/src/test/java/org/openecomp/sdnc/sli/provider/MdsalHelperTest.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*-
- * ============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=========================================================
- */
-
-package org.openecomp.sdnc.sli.provider;
-
-import junit.framework.TestCase;
-
-public class MdsalHelperTest extends TestCase {
-
- public static final String pathToSdnPropertiesFile = "./src/test/resources/l3sdn.properties";
-
- public void testSdnProperties() {
- MdsalHelperTesterUtil.loadProperties(pathToSdnPropertiesFile);
- assertEquals("synccomplete", MdsalHelperTesterUtil.mapEnumeratedValue("request-status", "Synccomplete"));
- assertEquals("asynccomplete", MdsalHelperTesterUtil.mapEnumeratedValue("request-status", "asynccomplete"));
- assertEquals("notifycomplete", MdsalHelperTesterUtil.mapEnumeratedValue("request-status", "notifycomplete"));
- assertEquals("service-configuration-operation", MdsalHelperTesterUtil.mapEnumeratedValue("rpc-name",
- "ServiceConfigurationOperation"));
- }
-
- public void testNegativeSdnProperties() {
- assertNotSame("synccomplete", MdsalHelperTesterUtil.mapEnumeratedValue("request-status", "Synccomplete"));
- }
-
-}
diff --git a/sli/provider/src/test/java/org/openecomp/sdnc/sli/provider/MdsalHelperTesterUtil.java b/sli/provider/src/test/java/org/openecomp/sdnc/sli/provider/MdsalHelperTesterUtil.java
deleted file mode 100644
index 01e333f..0000000
--- a/sli/provider/src/test/java/org/openecomp/sdnc/sli/provider/MdsalHelperTesterUtil.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*-
- * ============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=========================================================
- */
-
-package org.openecomp.sdnc.sli.provider;
-
-import org.openecomp.sdnc.sli.provider.MdsalHelper;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class MdsalHelperTesterUtil extends MdsalHelper {
-
- private static final Logger LOG = LoggerFactory.getLogger(MdsalHelperTesterUtil.class);
-
- //Normally static init of classes goes here for some weird classloader thing
- static {
- String str = "Hello World!";
- }
-
-}
diff --git a/sli/provider/src/test/java/org/openecomp/sdnc/sli/provider/PluginTest.java b/sli/provider/src/test/java/org/openecomp/sdnc/sli/provider/PluginTest.java
deleted file mode 100644
index 035cd3e..0000000
--- a/sli/provider/src/test/java/org/openecomp/sdnc/sli/provider/PluginTest.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*-
- * ============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=========================================================
- */
-
-package org.openecomp.sdnc.sli.provider;
-
-import java.lang.reflect.Method;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.openecomp.sdnc.sli.SvcLogicContext;
-import org.openecomp.sdnc.sli.SvcLogicGraph;
-import org.openecomp.sdnc.sli.SvcLogicJavaPlugin;
-import org.openecomp.sdnc.sli.SvcLogicNode;
-
-import junit.framework.TestCase;
-
-public class PluginTest extends TestCase {
-
- // The existing plugins work just like a VoidDummyPlugin
- // They will return null simply because they are all void
- // The attribute emitsOutcome will not be present, the expected outcome is success when no exception is thrown by the plugin
- public void testOldPlugin() throws Exception {
- ExecuteNodeExecutor executor = new ExecuteNodeExecutor();
- SvcLogicJavaPlugin plugin = new VoidDummyPlugin();
-
- Class pluginClass = plugin.getClass();
- Method pluginMethod = pluginClass.getMethod("dummy", Map.class, SvcLogicContext.class);
- Map<String, String> parmMap = new HashMap<String, String>();
- SvcLogicContext ctx = new SvcLogicContext();
- Object o = pluginMethod.invoke(plugin, parmMap, ctx);
-
- SvcLogicGraph graph = new SvcLogicGraph();
- SvcLogicNode node = new SvcLogicNode(1, "return", graph);
- String emitsOutcome = SvcLogicExpressionResolver.evaluate(node.getAttribute("emitsOutcome"), node, ctx);
- String outValue = executor.mapOutcome(o, emitsOutcome);
- assertEquals("success",outValue);
- }
-
- //Newer plugins can set the attribute emitsOutcome to true, if so they should return a string
- //The string represents the outcome value
- public void testNewPlugin() throws Exception {
- ExecuteNodeExecutor executor = new ExecuteNodeExecutor();
- SvcLogicJavaPlugin plugin = new LunchSelectorPlugin();
-
- Class pluginClass = plugin.getClass();
- Method pluginMethod = pluginClass.getMethod("selectLunch", Map.class, SvcLogicContext.class);
-
- Map<String, String> parmMap = new HashMap<String, String>();
- SvcLogicContext ctx = new SvcLogicContext();
-
- parmMap.put("day", "monday");
- Object o = pluginMethod.invoke(plugin, parmMap, ctx);
- SvcLogicGraph graph = new SvcLogicGraph();
- SvcLogicNode node = new SvcLogicNode(1, "return", graph);
- node.setAttribute("emitsOutcome", "true");
- String emitsOutcome = SvcLogicExpressionResolver.evaluate(node.getAttribute("emitsOutcome"), node, ctx);
- String outValue = executor.mapOutcome(o, emitsOutcome);
- assertEquals("pizza", outValue);
-
- parmMap.put("day", "tuesday");
- outValue = (String) pluginMethod.invoke(plugin, parmMap, ctx);
- o = pluginMethod.invoke(plugin, parmMap, ctx);
- outValue = executor.mapOutcome(o, emitsOutcome);
- assertEquals("soup",outValue);
-
- }
-
- //APPC had some legacy plugins returning objects which should not be treated as outcomes
- //The attribute emitsOutcome will not be set
- //The outcome should be success as it has always been
- public void testObjPlugin() throws Exception{
- ExecuteNodeExecutor executor = new ExecuteNodeExecutor();
- SvcLogicJavaPlugin plugin = new LunchSelectorPlugin();
-
- Class pluginClass = plugin.getClass();
- Method pluginMethod = pluginClass.getMethod("makeLunch", Map.class, SvcLogicContext.class);
-
- Map<String, String> parmMap = new HashMap<String, String>();
- SvcLogicContext ctx = new SvcLogicContext();
- Object o = pluginMethod.invoke(plugin, parmMap, ctx);
- SvcLogicGraph graph = new SvcLogicGraph();
- SvcLogicNode node = new SvcLogicNode(1, "return", graph);
- String emitsOutcome = SvcLogicExpressionResolver.evaluate(node.getAttribute("emitsOutcome"), node, ctx);
- String outValue = executor.mapOutcome(o, emitsOutcome);
- assertEquals("success",outValue);
- }
-
-}
diff --git a/sli/provider/src/test/java/org/openecomp/sdnc/sli/provider/SvcLogicExpressionResolverTest.java b/sli/provider/src/test/java/org/openecomp/sdnc/sli/provider/SvcLogicExpressionResolverTest.java
deleted file mode 100644
index 6181548..0000000
--- a/sli/provider/src/test/java/org/openecomp/sdnc/sli/provider/SvcLogicExpressionResolverTest.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/*-
- * ============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=========================================================
- */
-
-package org.openecomp.sdnc.sli.provider;
-
-import java.io.BufferedReader;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-
-import org.openecomp.sdnc.sli.SvcLogicContext;
-import org.openecomp.sdnc.sli.SvcLogicExprListener;
-import org.openecomp.sdnc.sli.SvcLogicExpression;
-import org.openecomp.sdnc.sli.SvcLogicExpressionFactory;
-import org.openecomp.sdnc.sli.SvcLogicGraph;
-import org.openecomp.sdnc.sli.SvcLogicNode;
-import org.openecomp.sdnc.sli.provider.SvcLogicExpressionResolver;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import junit.framework.Assert;
-import junit.framework.TestCase;
-
-public class SvcLogicExpressionResolverTest extends TestCase {
-
-
- private static final Logger LOG = LoggerFactory
- .getLogger(SvcLogicExpressionResolver.class);
-
- public void testEvaluate()
- {
- InputStream testStr = getClass().getResourceAsStream("/expression.tests");
- BufferedReader testsReader = new BufferedReader(new InputStreamReader(testStr));
-
- try
- {
- SvcLogicContext ctx = new SvcLogicContext();
- SvcLogicGraph graph = new SvcLogicGraph();
- SvcLogicNode node = new SvcLogicNode(1, "return", graph);
- graph.setRootNode(node);
-
- String line = null;
- int lineNo = 0;
- while ((line = testsReader.readLine()) != null) {
- ++lineNo;
- if (line.startsWith("#"))
- {
- String testExpr = line.trim().substring(1).trim();
- String[] nameValue = testExpr.split("=");
- String name = nameValue[0].trim();
- String value = nameValue[1].trim();
-
- if (name.startsWith("$"))
- {
- LOG.info("Setting context attribute "+name+" = "+value);
- ctx.setAttribute(name.substring(1), value);
- }
- else
- {
-
- LOG.info("Setting node attribute "+name+" = "+value);
- node.setAttribute(name, value);
-
- }
- }
- else
- {
- // if the line contains #, what comes before is the expression to evaluate, and what comes after
- // is the expected value
- String[] substrings = line.split("#");
- String expectedValue = substrings.length > 1 ? substrings[1].trim() : null;
- String testExpr = substrings[0].trim();
-
- LOG.info("Parsing expression "+testExpr);
- SvcLogicExpression expr = SvcLogicExpressionFactory.parse(testExpr);
- if (expr == null)
- {
- fail("Unable to parse expression "+testExpr);
- }
- else
- {
- LOG.info("Evaluating parsed expression "+expr.asParsedExpr());
- String exprValue = SvcLogicExpressionResolver.evaluate(expr, node, ctx);
- if (exprValue == null)
- {
- fail("Unable to evaluate expression "+testExpr);
- }
- else
- {
- LOG.info("Expression " + testExpr + " evaluates to " + exprValue);
- if (expectedValue != null) {
- Assert.assertEquals("Line " + lineNo + ": " + testExpr, expectedValue, exprValue);
- }
- }
- }
- }
- }
- }
- catch (Exception e)
- {
- LOG.error("Caught exception", e);
- fail("Caught exception");
- }
- }
-
-}
diff --git a/sli/provider/src/test/java/org/openecomp/sdnc/sli/provider/SvcLogicGraphExecutorTest.java b/sli/provider/src/test/java/org/openecomp/sdnc/sli/provider/SvcLogicGraphExecutorTest.java
deleted file mode 100644
index 2e8b35e..0000000
--- a/sli/provider/src/test/java/org/openecomp/sdnc/sli/provider/SvcLogicGraphExecutorTest.java
+++ /dev/null
@@ -1,212 +0,0 @@
-/*-
- * ============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=========================================================
- */
-
-package org.openecomp.sdnc.sli.provider;
-
-import java.io.BufferedReader;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.net.URL;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.Map;
-import java.util.Properties;
-
-import org.openecomp.sdnc.sli.MetricLogger;
-import org.openecomp.sdnc.sli.SvcLogicContext;
-import org.openecomp.sdnc.sli.SvcLogicGraph;
-import org.openecomp.sdnc.sli.SvcLogicNode;
-import org.openecomp.sdnc.sli.SvcLogicParser;
-import org.openecomp.sdnc.sli.SvcLogicStore;
-import org.openecomp.sdnc.sli.SvcLogicStoreFactory;
-import org.openecomp.sdnc.sli.provider.BlockNodeExecutor;
-import org.openecomp.sdnc.sli.provider.CallNodeExecutor;
-import org.openecomp.sdnc.sli.provider.ConfigureNodeExecutor;
-import org.openecomp.sdnc.sli.provider.DeleteNodeExecutor;
-import org.openecomp.sdnc.sli.provider.ExecuteNodeExecutor;
-import org.openecomp.sdnc.sli.provider.ExistsNodeExecutor;
-import org.openecomp.sdnc.sli.provider.ForNodeExecutor;
-import org.openecomp.sdnc.sli.provider.GetResourceNodeExecutor;
-import org.openecomp.sdnc.sli.provider.IsAvailableNodeExecutor;
-import org.openecomp.sdnc.sli.provider.NotifyNodeExecutor;
-import org.openecomp.sdnc.sli.provider.RecordNodeExecutor;
-import org.openecomp.sdnc.sli.provider.ReleaseNodeExecutor;
-import org.openecomp.sdnc.sli.provider.ReserveNodeExecutor;
-import org.openecomp.sdnc.sli.provider.ReturnNodeExecutor;
-import org.openecomp.sdnc.sli.provider.SaveNodeExecutor;
-import org.openecomp.sdnc.sli.provider.SetNodeExecutor;
-import org.openecomp.sdnc.sli.provider.SvcLogicNodeExecutor;
-import org.openecomp.sdnc.sli.provider.SvcLogicServiceImpl;
-import org.openecomp.sdnc.sli.provider.SwitchNodeExecutor;
-import org.openecomp.sdnc.sli.provider.UpdateNodeExecutor;
-import org.osgi.framework.ServiceRegistration;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import junit.framework.TestCase;
-
-public class SvcLogicGraphExecutorTest 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");
-
- SvcLogicStore store = SvcLogicStoreFactory.getSvcLogicStore(propStr);
-
- 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");
- }
- }
-
-
-}
diff --git a/sli/provider/src/test/java/org/openecomp/sdnc/sli/provider/VoidDummyPlugin.java b/sli/provider/src/test/java/org/openecomp/sdnc/sli/provider/VoidDummyPlugin.java
deleted file mode 100644
index 6c8214a..0000000
--- a/sli/provider/src/test/java/org/openecomp/sdnc/sli/provider/VoidDummyPlugin.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*-
- * ============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=========================================================
- */
-
-package org.openecomp.sdnc.sli.provider;
-
-import java.util.Map;
-
-import org.openecomp.sdnc.sli.SvcLogicContext;
-import org.openecomp.sdnc.sli.SvcLogicException;
-import org.openecomp.sdnc.sli.SvcLogicJavaPlugin;
-
-
-
-public class VoidDummyPlugin implements SvcLogicJavaPlugin {
-
- public void dummy(Map<String, String> parameters, SvcLogicContext ctx) throws SvcLogicException {
- return;
- }
-
-}
diff --git a/sli/provider/src/test/resources/executor.tests b/sli/provider/src/test/resources/executor.tests
deleted file mode 100644
index e7547e6..0000000
--- a/sli/provider/src/test/resources/executor.tests
+++ /dev/null
@@ -1,2 +0,0 @@
-l3sdn_logic_v10.xml:switchTester:test-value=""
-l3sdn_logic_v10.xml:switchTester:test-value="hi" \ No newline at end of file
diff --git a/sli/provider/src/test/resources/expression.tests b/sli/provider/src/test/resources/expression.tests
deleted file mode 100644
index 848a0e7..0000000
--- a/sli/provider/src/test/resources/expression.tests
+++ /dev/null
@@ -1,24 +0,0 @@
-# $uni-circuit-id = abc123
-# $uni-cir-units = 10
-# value = 1
-# $arg1 = 2
-# $network.name = vCE0001.in
-# $network.segment[0].provider-segmentation-id = 1212
-# $network.segment[1].provider-segmentation-id = 1213
-# $availability-zone = mtsnj-esx-az01
-length($uni-circuit-id) > 0 # true
-$uni-cir-units * 1000 * 100 / 100 # 10000
-$uni-cir-units / 1000 # 0
-$uni-cir-units - 100 # -90
-$uni-cir-units + 100 # 110
-(value * 3 - $arg1 > 0) and (length($uni-circuit-id) == 0) # true
-'pg-'+$network.name # pg-vCE0001.in
-$network.segment[0].provider-segmentation-id # 1212
-toUpperCase($network.name) # VCE0001.IN
-toLowerCase($network.name) # vce0001.in
-toUpperCase(substr($availability-zone, 0, 5)) # MTSNJ
-convertBase(1234, 10) # 1234
-convertBase(10, 16, 10) # 16
-convertBase(ZZ, 36, 10) # 1295
-convertBase(10, 10, 36) # a
-(0 - 1) * $arg1 # -1
diff --git a/sli/provider/src/test/resources/l3sdn_logic_v10.xml b/sli/provider/src/test/resources/l3sdn_logic_v10.xml
deleted file mode 100644
index d81b8b7..0000000
--- a/sli/provider/src/test/resources/l3sdn_logic_v10.xml
+++ /dev/null
@@ -1,74 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ============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.openecomp.org/sdnc/svclogic"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://www.openecomp.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="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/provider/src/test/resources/simplelogger.properties b/sli/provider/src/test/resources/simplelogger.properties
deleted file mode 100644
index 3581395..0000000
--- a/sli/provider/src/test/resources/simplelogger.properties
+++ /dev/null
@@ -1,22 +0,0 @@
-###
-# ============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=========================================================
-###
-
-org.slf4j.simpleLogger.defaultLogLevel=info
diff --git a/sli/provider/src/test/resources/svclogic.properties b/sli/provider/src/test/resources/svclogic.properties
deleted file mode 100644
index fa33146..0000000
--- a/sli/provider/src/test/resources/svclogic.properties
+++ /dev/null
@@ -1,26 +0,0 @@
-###
-# ============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=========================================================
-###
-
-org.openecomp.sdnc.sli.dbtype = jdbc
-org.openecomp.sdnc.sli.jdbc.url = jdbc:mysql://localhost:3306/sdnctl
-org.openecomp.sdnc.sli.jdbc.database = sdnctl
-org.openecomp.sdnc.sli.jdbc.user = sdnctl
-org.openecomp.sdnc.sli.jdbc.password = gamma