diff options
11 files changed, 429 insertions, 113 deletions
diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicAdaptorFactory.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicAdaptorFactory.java index 7316db57..ecfe6b69 100644 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicAdaptorFactory.java +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicAdaptorFactory.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. @@ -35,7 +35,7 @@ public class SvcLogicAdaptorFactory { private static final Logger LOG = LoggerFactory .getLogger(SvcLogicAdaptorFactory.class); - private static HashMap<String, SvcLogicAdaptor> adaptorMap = new HashMap<String, SvcLogicAdaptor>(); + private static HashMap<String, SvcLogicAdaptor> adaptorMap = new HashMap<>(); public static void registerAdaptor(SvcLogicAdaptor adaptor) { String name = adaptor.getClass().getName(); @@ -51,36 +51,18 @@ public class SvcLogicAdaptorFactory { } } - public static SvcLogicAdaptor getInstance(String name) { - if (adaptorMap.containsKey(name)) { - return (adaptorMap.get(name)); - } else { - BundleContext bctx = null; - try - { - bctx = FrameworkUtil.getBundle(SvcLogicAdaptorFactory.class) - .getBundleContext(); - } - catch (Exception e) - { - LOG.debug("Caught exception trying to locate device adaptor "+name, e); - return(null); - } - - ServiceReference sref = bctx.getServiceReference(name); + public static SvcLogicAdaptor getInstance(String name) { + if (adaptorMap.containsKey(name)) { + return adaptorMap.get(name); + } else { - if (sref != null) { - SvcLogicAdaptor adaptor = (SvcLogicAdaptor) bctx - .getService(sref); + SvcLogicAdaptor adaptor = (SvcLogicAdaptor) SvcLogicClassResolver.resolve(name); - if (adaptor != null) { - registerAdaptor(adaptor); + if (adaptor != null) { + registerAdaptor(adaptor); + } - return (adaptor); - } - return (null); - } - } - return(null); - } + return adaptor; + } + } } diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicClassResolver.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicClassResolver.java new file mode 100644 index 00000000..d2b733fc --- /dev/null +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicClassResolver.java @@ -0,0 +1,41 @@ +package org.onap.ccsdk.sli.core.sli.provider; + +import org.osgi.framework.Bundle; +import org.osgi.framework.BundleContext; +import org.osgi.framework.FrameworkUtil; +import org.osgi.framework.ServiceReference; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class SvcLogicClassResolver { + private static final Logger LOG = LoggerFactory.getLogger(SvcLogicClassResolver.class); + + public static Object resolve(String className) { + + Bundle bundle = FrameworkUtil.getBundle(SvcLogicClassResolver.class); + + if (bundle == null) { + // Running outside OSGi container (e.g. jUnit). Use Reflection + // to resolve class + try { + return(Class.forName(className).newInstance()); + } catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) { + + LOG.error("Could not resolve class "+className, e); + return null; + } + + } else { + BundleContext bctx = bundle.getBundleContext(); + ServiceReference sref = bctx.getServiceReference(className); + if (sref != null) { + return bctx.getService(sref); + } else { + + LOG.warn("Could not find service reference object for class " + className); + return null; + } + } + } + +} diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicNodeExecutor.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicNodeExecutor.java index 593c972a..f34c261d 100644 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicNodeExecutor.java +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicNodeExecutor.java @@ -29,6 +29,7 @@ import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin; import org.onap.ccsdk.sli.core.sli.SvcLogicNode; import org.onap.ccsdk.sli.core.sli.SvcLogicRecorder; import org.onap.ccsdk.sli.core.sli.SvcLogicResource; +import org.osgi.framework.Bundle; import org.osgi.framework.BundleContext; import org.osgi.framework.FrameworkUtil; import org.osgi.framework.ServiceReference; @@ -53,56 +54,25 @@ public abstract class SvcLogicNodeExecutor { } + protected SvcLogicAdaptor getAdaptor(String adaptorName) { return SvcLogicAdaptorFactory.getInstance(adaptorName); } protected SvcLogicResource getSvcLogicResource(String plugin) { - BundleContext bctx = FrameworkUtil.getBundle(this.getClass()) - .getBundleContext(); - - ServiceReference sref = bctx.getServiceReference(plugin); - if (sref != null) { - SvcLogicResource resourcePlugin = (SvcLogicResource) bctx - .getService(sref); - return resourcePlugin; - } - else { - LOG.warn("Could not find service reference object for plugin " + plugin); - return null; - } + + return((SvcLogicResource) SvcLogicClassResolver.resolve(plugin)); } protected SvcLogicRecorder getSvcLogicRecorder(String plugin) { - BundleContext bctx = FrameworkUtil.getBundle(this.getClass()) - .getBundleContext(); - - ServiceReference sref = bctx.getServiceReference(plugin); - if (sref != null) { - SvcLogicRecorder resourcePlugin = (SvcLogicRecorder) bctx - .getService(sref); - return resourcePlugin; - } - else { - return null; - } + return((SvcLogicRecorder) SvcLogicClassResolver.resolve(plugin)); } protected SvcLogicJavaPlugin getSvcLogicJavaPlugin(String pluginName){ - BundleContext bctx = FrameworkUtil.getBundle(this.getClass()) - .getBundleContext(); - - ServiceReference sref = bctx.getServiceReference(pluginName); - - if (sref == null) { - LOG.warn("Could not find service reference object for plugin " + pluginName); - return null; - } else { - SvcLogicJavaPlugin plugin = (SvcLogicJavaPlugin) bctx - .getService(sref); - return plugin; - } - } + return((SvcLogicJavaPlugin) SvcLogicClassResolver.resolve(pluginName)); + + } + protected SvcLogicNode getNextNode(SvcLogicNode node, String outValue) { MetricLogger.resetContext(); SvcLogicNode nextNode = node.getOutcomeValue(outValue); diff --git a/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/DummyAdaptor.java b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/DummyAdaptor.java new file mode 100644 index 00000000..87765344 --- /dev/null +++ b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/DummyAdaptor.java @@ -0,0 +1,42 @@ +/** + * + */ +package org.onap.ccsdk.sli.core.sli.provider; + +import java.util.Map; +import org.onap.ccsdk.sli.core.sli.SvcLogicAdaptor; +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; + +/** + * @author dt5972 + * + */ + +public class DummyAdaptor implements SvcLogicAdaptor { + + /* (non-Javadoc) + * @see org.onap.ccsdk.sli.core.sli.SvcLogicAdaptor#configure(java.lang.String, java.util.Map, org.onap.ccsdk.sli.core.sli.SvcLogicContext) + */ + @Override + public ConfigStatus configure(String key, Map<String, String> parameters, SvcLogicContext ctx) { + + return ConfigStatus.SUCCESS; + } + + /* (non-Javadoc) + * @see org.onap.ccsdk.sli.core.sli.SvcLogicAdaptor#activate(java.lang.String, org.onap.ccsdk.sli.core.sli.SvcLogicContext) + */ + @Override + public ConfigStatus activate(String key, SvcLogicContext ctx) { + return ConfigStatus.SUCCESS; + } + + /* (non-Javadoc) + * @see org.onap.ccsdk.sli.core.sli.SvcLogicAdaptor#deactivate(java.lang.String, org.onap.ccsdk.sli.core.sli.SvcLogicContext) + */ + @Override + public ConfigStatus deactivate(String key, SvcLogicContext ctx) { + return ConfigStatus.SUCCESS; + } + +} diff --git a/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/DummyRecorder.java b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/DummyRecorder.java new file mode 100644 index 00000000..e87f9628 --- /dev/null +++ b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/DummyRecorder.java @@ -0,0 +1,14 @@ +package org.onap.ccsdk.sli.core.sli.provider; + +import java.util.Map; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.core.sli.SvcLogicRecorder; + +public class DummyRecorder implements SvcLogicRecorder { + + @Override + public void record(Map<String, String> parmMap) throws SvcLogicException { + return; + } + +} diff --git a/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/DummyResource.java b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/DummyResource.java new file mode 100644 index 00000000..2f784186 --- /dev/null +++ b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/DummyResource.java @@ -0,0 +1,97 @@ +/** + * + */ +package org.onap.ccsdk.sli.core.sli.provider; + +import java.util.Map; +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.core.sli.SvcLogicResource; + +/** + * @author dt5972 + * + */ +public class DummyResource implements SvcLogicResource { + + /* (non-Javadoc) + * @see org.onap.ccsdk.sli.core.sli.SvcLogicResource#isAvailable(java.lang.String, java.lang.String, java.lang.String, org.onap.ccsdk.sli.core.sli.SvcLogicContext) + */ + @Override + public QueryStatus isAvailable(String resource, String key, String prefix, SvcLogicContext ctx) + throws SvcLogicException { + return QueryStatus.SUCCESS; + } + + /* (non-Javadoc) + * @see org.onap.ccsdk.sli.core.sli.SvcLogicResource#exists(java.lang.String, java.lang.String, java.lang.String, org.onap.ccsdk.sli.core.sli.SvcLogicContext) + */ + @Override + public QueryStatus exists(String resource, String key, String prefix, SvcLogicContext ctx) + throws SvcLogicException { + return QueryStatus.SUCCESS; + } + + /* (non-Javadoc) + * @see org.onap.ccsdk.sli.core.sli.SvcLogicResource#query(java.lang.String, boolean, java.lang.String, java.lang.String, java.lang.String, java.lang.String, org.onap.ccsdk.sli.core.sli.SvcLogicContext) + */ + @Override + public QueryStatus query(String resource, boolean localOnly, String select, String key, String prefix, + String orderBy, SvcLogicContext ctx) throws SvcLogicException { + return QueryStatus.SUCCESS; + } + + /* (non-Javadoc) + * @see org.onap.ccsdk.sli.core.sli.SvcLogicResource#reserve(java.lang.String, java.lang.String, java.lang.String, java.lang.String, org.onap.ccsdk.sli.core.sli.SvcLogicContext) + */ + @Override + public QueryStatus reserve(String resource, String select, String key, String prefix, SvcLogicContext ctx) + throws SvcLogicException { + return QueryStatus.SUCCESS; + } + + /* (non-Javadoc) + * @see org.onap.ccsdk.sli.core.sli.SvcLogicResource#save(java.lang.String, boolean, boolean, java.lang.String, java.util.Map, java.lang.String, org.onap.ccsdk.sli.core.sli.SvcLogicContext) + */ + @Override + public QueryStatus save(String resource, boolean force, boolean localOnly, String key, Map<String, String> parms, + String prefix, SvcLogicContext ctx) throws SvcLogicException { + return QueryStatus.SUCCESS; + } + + /* (non-Javadoc) + * @see org.onap.ccsdk.sli.core.sli.SvcLogicResource#release(java.lang.String, java.lang.String, org.onap.ccsdk.sli.core.sli.SvcLogicContext) + */ + @Override + public QueryStatus release(String resource, String key, SvcLogicContext ctx) throws SvcLogicException { + + return QueryStatus.SUCCESS; + } + + /* (non-Javadoc) + * @see org.onap.ccsdk.sli.core.sli.SvcLogicResource#delete(java.lang.String, java.lang.String, org.onap.ccsdk.sli.core.sli.SvcLogicContext) + */ + @Override + public QueryStatus delete(String resource, String key, SvcLogicContext ctx) throws SvcLogicException { + return QueryStatus.SUCCESS; + } + + /* (non-Javadoc) + * @see org.onap.ccsdk.sli.core.sli.SvcLogicResource#notify(java.lang.String, java.lang.String, java.lang.String, org.onap.ccsdk.sli.core.sli.SvcLogicContext) + */ + @Override + public QueryStatus notify(String resource, String action, String key, SvcLogicContext ctx) + throws SvcLogicException { + return QueryStatus.SUCCESS; + } + + /* (non-Javadoc) + * @see org.onap.ccsdk.sli.core.sli.SvcLogicResource#update(java.lang.String, java.lang.String, java.util.Map, java.lang.String, org.onap.ccsdk.sli.core.sli.SvcLogicContext) + */ + @Override + public QueryStatus update(String resource, String key, Map<String, String> parms, String prefix, + SvcLogicContext ctx) throws SvcLogicException { + return QueryStatus.SUCCESS; + } + +} 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 5e627cdb..4c112ab2 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 @@ -45,6 +45,9 @@ import org.onap.ccsdk.sli.core.sli.SvcLogicGraph; 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.osgi.framework.BundleContext; +import org.osgi.framework.FrameworkUtil; +import org.osgi.framework.ServiceRegistration; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -101,7 +104,6 @@ public class ITCaseSvcLogicGraphExecutor { SvcLogicParser parser = new SvcLogicParser(); - // Loop through executor tests SvcLogicPropertiesProvider resourceProvider = new SvcLogicPropertiesProviderImpl(); SvcLogicServiceImpl svc = new SvcLogicServiceImpl(resourceProvider); @@ -109,6 +111,10 @@ public class ITCaseSvcLogicGraphExecutor { LOG.info("SLI - registering node executor for node type " + nodeType); svc.registerExecutor(nodeType, BUILTIN_NODES.get(nodeType)); } + + + + } @AfterClass diff --git a/sli/provider/src/test/resources/executor.tests b/sli/provider/src/test/resources/executor.tests index e7547e63..e4e60208 100755 --- a/sli/provider/src/test/resources/executor.tests +++ b/sli/provider/src/test/resources/executor.tests @@ -1,2 +1,6 @@ l3sdn_logic_v10.xml:switchTester:test-value="" -l3sdn_logic_v10.xml:switchTester:test-value="hi"
\ No newline at end of file +l3sdn_logic_v10.xml:switchTester:test-value="hi" +l3sdn_logic_v10.xml:forRecordTester +l3sdn_logic_v10.xml:resourceTester +l3sdn_logic_v10.xml:configureTester +l3sdn_logic_v10.xml:javaPluginTester
\ 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 127c181f..c1123d13 100644 --- a/sli/provider/src/test/resources/l3sdn_logic_v10.xml +++ b/sli/provider/src/test/resources/l3sdn_logic_v10.xml @@ -1,22 +1,14 @@ <?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========================================================= - --> +<!-- ============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" @@ -32,40 +24,140 @@ <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> + <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="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> + + </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"/> + </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'"> + <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> + <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"/> + <parameter name="error-code" value="200" /> </return> </outcome> </switch> diff --git a/sli/recording/src/test/java/org/onap/ccsdk/sli/core/sli/recording/TestFileRecorder.java b/sli/recording/src/test/java/org/onap/ccsdk/sli/core/sli/recording/TestFileRecorder.java new file mode 100644 index 00000000..c879d8f6 --- /dev/null +++ b/sli/recording/src/test/java/org/onap/ccsdk/sli/core/sli/recording/TestFileRecorder.java @@ -0,0 +1,35 @@ +/** + * + */ +package org.onap.ccsdk.sli.core.sli.recording; + +import static org.junit.Assert.*; +import java.util.HashMap; +import org.junit.Test; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; + +/** + * @author dt5972 + * + */ +public class TestFileRecorder { + + /** + * Test method for {@link org.onap.ccsdk.sli.core.sli.recording.FileRecorder#record(java.util.Map)}. + */ + @Test + public void testRecord() { + + FileRecorder recorder = new FileRecorder(); + + HashMap<String,String> parms = new HashMap<>(); + parms.put("file", "/dev/null"); + parms.put("field1","hi"); + try { + recorder.record(parms); + } catch (SvcLogicException e) { + fail("Caught SvcLogicException : "+e.getMessage()); + } + } + +} diff --git a/sli/recording/src/test/java/org/onap/ccsdk/sli/core/sli/recording/TestSlf4jRecorder.java b/sli/recording/src/test/java/org/onap/ccsdk/sli/core/sli/recording/TestSlf4jRecorder.java new file mode 100644 index 00000000..c696f25b --- /dev/null +++ b/sli/recording/src/test/java/org/onap/ccsdk/sli/core/sli/recording/TestSlf4jRecorder.java @@ -0,0 +1,33 @@ +/** + * + */ +package org.onap.ccsdk.sli.core.sli.recording; + +import static org.junit.Assert.*; +import java.util.HashMap; +import org.junit.Test; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; + +/** + * @author dt5972 + * + */ +public class TestSlf4jRecorder { + + /** + * Test method for {@link org.onap.ccsdk.sli.core.sli.recording.Slf4jRecorder#record(java.util.Map)}. + */ + @Test + public void testRecord() { + Slf4jRecorder recorder = new Slf4jRecorder(); + + HashMap<String,String> parms = new HashMap<>(); + parms.put("field1","hi"); + try { + recorder.record(parms); + } catch (SvcLogicException e) { + fail("Caught SvcLogicException : "+e.getMessage()); + } + } + +} |