From fc5c5f80898cc3e5c06c1596c34d9e210710dc29 Mon Sep 17 00:00:00 2001 From: Ganesh Chandrasekaran Date: Fri, 7 Sep 2018 15:22:05 +0900 Subject: Mdsal resource activator coverage Issue-ID: CCSDK-521 Change-Id: I88534c476337fbfbeb66a542780a3474a982f219 Signed-off-by: Ganesh Chandrasekaran --- .../resource/mdsal/TestMdsalResourceActivator.java | 328 +++++++++++++++++++++ 1 file changed, 328 insertions(+) create mode 100644 mdsal-resource/provider/src/test/java/org/onap/ccsdk/sli/adaptors/resource/mdsal/TestMdsalResourceActivator.java (limited to 'mdsal-resource/provider/src') diff --git a/mdsal-resource/provider/src/test/java/org/onap/ccsdk/sli/adaptors/resource/mdsal/TestMdsalResourceActivator.java b/mdsal-resource/provider/src/test/java/org/onap/ccsdk/sli/adaptors/resource/mdsal/TestMdsalResourceActivator.java new file mode 100644 index 000000000..397915d08 --- /dev/null +++ b/mdsal-resource/provider/src/test/java/org/onap/ccsdk/sli/adaptors/resource/mdsal/TestMdsalResourceActivator.java @@ -0,0 +1,328 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : SDN-C + * ================================================================================ + * Copyright (C) 2018 Samsung. All rights + * reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.ccsdk.sli.adaptors.resource.mdsal; + +import org.junit.Before; +import org.junit.Test; +import org.osgi.framework.Bundle; +import org.osgi.framework.BundleContext; +import org.osgi.framework.BundleException; +import org.osgi.framework.BundleListener; +import org.osgi.framework.Filter; +import org.osgi.framework.FrameworkListener; +import org.osgi.framework.InvalidSyntaxException; +import org.osgi.framework.ServiceListener; +import org.osgi.framework.ServiceReference; +import org.osgi.framework.ServiceRegistration; + +import org.onap.ccsdk.sli.core.sli.ConfigurationException; +import java.io.File; +import java.io.InputStream; +import java.util.Collection; +import java.util.Dictionary; + +public class TestMdsalResourceActivator { + + MdsalResourceActivator mdsal; + + @Before + public void setup() { + mdsal = new MdsalResourceActivator(); + } + + + @Test (expected = ConfigurationException.class) + public void testStartResource() throws Exception { + BundleContext ctx = new BundleContext() { + @Override + public String getProperty(String key) { + return null; + } + + @Override + public Bundle getBundle() { + return null; + } + + @Override + public Bundle installBundle(String location, InputStream input) throws BundleException { + return null; + } + + @Override + public Bundle installBundle(String location) throws BundleException { + return null; + } + + @Override + public Bundle getBundle(long id) { + return null; + } + + @Override + public Bundle[] getBundles() { + return new Bundle[0]; + } + + @Override + public void addServiceListener(ServiceListener listener, String filter) throws InvalidSyntaxException { + + } + + @Override + public void addServiceListener(ServiceListener listener) { + + } + + @Override + public void removeServiceListener(ServiceListener listener) { + + } + + @Override + public void addBundleListener(BundleListener listener) { + + } + + @Override + public void removeBundleListener(BundleListener listener) { + + } + + @Override + public void addFrameworkListener(FrameworkListener listener) { + + } + + @Override + public void removeFrameworkListener(FrameworkListener listener) { + + } + + @Override + public ServiceRegistration registerService(String[] clazzes, Object service, Dictionary properties) { + return null; + } + + @Override + public ServiceRegistration registerService(String clazz, Object service, Dictionary properties) { + return null; + } + + @Override + public ServiceRegistration registerService(Class clazz, S service, Dictionary properties) { + return null; + } + + @Override + public ServiceReference[] getServiceReferences(String clazz, String filter) throws InvalidSyntaxException { + return new ServiceReference[0]; + } + + @Override + public ServiceReference[] getAllServiceReferences(String clazz, String filter) throws InvalidSyntaxException { + return new ServiceReference[0]; + } + + @Override + public ServiceReference getServiceReference(String clazz) { + return null; + } + + @Override + public ServiceReference getServiceReference(Class clazz) { + return null; + } + + @Override + public Collection> getServiceReferences(Class clazz, String filter) throws InvalidSyntaxException { + return null; + } + + @Override + public S getService(ServiceReference reference) { + return null; + } + + @Override + public boolean ungetService(ServiceReference reference) { + return false; + } + + @Override + public File getDataFile(String filename) { + return null; + } + + @Override + public Filter createFilter(String filter) throws InvalidSyntaxException { + return null; + } + + @Override + public Bundle getBundle(String location) { + return null; + } + }; + + mdsal.start(ctx); + + } + + @Test + public void testStopResource() throws Exception { + BundleContext ctx = new BundleContext() { + @Override + public String getProperty(String key) { + return null; + } + + @Override + public Bundle getBundle() { + return null; + } + + @Override + public Bundle installBundle(String location, InputStream input) throws BundleException { + return null; + } + + @Override + public Bundle installBundle(String location) throws BundleException { + return null; + } + + @Override + public Bundle getBundle(long id) { + return null; + } + + @Override + public Bundle[] getBundles() { + return new Bundle[0]; + } + + @Override + public void addServiceListener(ServiceListener listener, String filter) throws InvalidSyntaxException { + + } + + @Override + public void addServiceListener(ServiceListener listener) { + + } + + @Override + public void removeServiceListener(ServiceListener listener) { + + } + + @Override + public void addBundleListener(BundleListener listener) { + + } + + @Override + public void removeBundleListener(BundleListener listener) { + + } + + @Override + public void addFrameworkListener(FrameworkListener listener) { + + } + + @Override + public void removeFrameworkListener(FrameworkListener listener) { + + } + + @Override + public ServiceRegistration registerService(String[] clazzes, Object service, Dictionary properties) { + return null; + } + + @Override + public ServiceRegistration registerService(String clazz, Object service, Dictionary properties) { + return null; + } + + @Override + public ServiceRegistration registerService(Class clazz, S service, Dictionary properties) { + return null; + } + + @Override + public ServiceReference[] getServiceReferences(String clazz, String filter) throws InvalidSyntaxException { + return new ServiceReference[0]; + } + + @Override + public ServiceReference[] getAllServiceReferences(String clazz, String filter) throws InvalidSyntaxException { + return new ServiceReference[0]; + } + + @Override + public ServiceReference getServiceReference(String clazz) { + return null; + } + + @Override + public ServiceReference getServiceReference(Class clazz) { + return null; + } + + @Override + public Collection> getServiceReferences(Class clazz, String filter) throws InvalidSyntaxException { + return null; + } + + @Override + public S getService(ServiceReference reference) { + return null; + } + + @Override + public boolean ungetService(ServiceReference reference) { + return false; + } + + @Override + public File getDataFile(String filename) { + return null; + } + + @Override + public Filter createFilter(String filter) throws InvalidSyntaxException { + return null; + } + + @Override + public Bundle getBundle(String location) { + return null; + } + }; + + mdsal.stop(ctx); + + } +} -- cgit 1.2.3-korg