2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2018 Samsung. All rights
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
22 package org.onap.ccsdk.sli.adaptors.resource.mdsal;
24 import org.junit.Before;
25 import org.junit.Test;
26 import org.osgi.framework.Bundle;
27 import org.osgi.framework.BundleContext;
28 import org.osgi.framework.BundleException;
29 import org.osgi.framework.BundleListener;
30 import org.osgi.framework.Filter;
31 import org.osgi.framework.FrameworkListener;
32 import org.osgi.framework.InvalidSyntaxException;
33 import org.osgi.framework.ServiceFactory;
34 import org.osgi.framework.ServiceListener;
35 import org.osgi.framework.ServiceObjects;
36 import org.osgi.framework.ServiceReference;
37 import org.osgi.framework.ServiceRegistration;
39 import org.onap.ccsdk.sli.core.sli.ConfigurationException;
41 import java.io.InputStream;
42 import java.util.Collection;
43 import java.util.Dictionary;
45 public class TestMdsalResourceActivator {
47 MdsalResourceActivator mdsal;
51 mdsal = new MdsalResourceActivator();
54 @Test(expected = ConfigurationException.class)
55 public void testStartResource() throws Exception {
56 BundleContext ctx = new BundleContext() {
58 public String getProperty(String key) {
63 public Bundle getBundle() {
68 public Bundle installBundle(String location, InputStream input) throws BundleException {
73 public Bundle installBundle(String location) throws BundleException {
78 public Bundle getBundle(long id) {
83 public Bundle[] getBundles() {
88 public void addServiceListener(ServiceListener listener, String filter) throws InvalidSyntaxException {
93 public void addServiceListener(ServiceListener listener) {
98 public void removeServiceListener(ServiceListener listener) {
103 public void addBundleListener(BundleListener listener) {
108 public void removeBundleListener(BundleListener listener) {
113 public void addFrameworkListener(FrameworkListener listener) {
118 public void removeFrameworkListener(FrameworkListener listener) {
123 public ServiceRegistration<?> registerService(String[] clazzes, Object service,
124 Dictionary<String, ?> properties) {
129 public ServiceRegistration<?> registerService(String clazz, Object service,
130 Dictionary<String, ?> properties) {
135 public <S> ServiceRegistration<S> registerService(Class<S> clazz, S service,
136 Dictionary<String, ?> properties) {
141 public ServiceReference<?>[] getServiceReferences(String clazz, String filter)
142 throws InvalidSyntaxException {
143 return new ServiceReference[0];
147 public ServiceReference<?>[] getAllServiceReferences(String clazz, String filter)
148 throws InvalidSyntaxException {
149 return new ServiceReference[0];
153 public ServiceReference<?> getServiceReference(String clazz) {
158 public <S> ServiceReference<S> getServiceReference(Class<S> clazz) {
163 public <S> Collection<ServiceReference<S>> getServiceReferences(Class<S> clazz, String filter)
164 throws InvalidSyntaxException {
169 public <S> S getService(ServiceReference<S> reference) {
174 public boolean ungetService(ServiceReference<?> reference) {
179 public File getDataFile(String filename) {
184 public Filter createFilter(String filter) throws InvalidSyntaxException {
189 public Bundle getBundle(String location) {
194 public <S> ServiceRegistration<S> registerService(Class<S> clazz, ServiceFactory<S> factory,
195 Dictionary<String, ?> properties) {
196 // TODO Auto-generated method stub
201 public <S> ServiceObjects<S> getServiceObjects(ServiceReference<S> reference) {
202 // TODO Auto-generated method stub
212 public void testStopResource() throws Exception {
213 BundleContext ctx = new BundleContext() {
215 public String getProperty(String key) {
220 public Bundle getBundle() {
225 public Bundle installBundle(String location, InputStream input) throws BundleException {
230 public Bundle installBundle(String location) throws BundleException {
235 public Bundle getBundle(long id) {
240 public Bundle[] getBundles() {
241 return new Bundle[0];
245 public void addServiceListener(ServiceListener listener, String filter) throws InvalidSyntaxException {
250 public void addServiceListener(ServiceListener listener) {
255 public void removeServiceListener(ServiceListener listener) {
260 public void addBundleListener(BundleListener listener) {
265 public void removeBundleListener(BundleListener listener) {
270 public void addFrameworkListener(FrameworkListener listener) {
275 public void removeFrameworkListener(FrameworkListener listener) {
280 public ServiceRegistration<?> registerService(String[] clazzes, Object service, Dictionary<String, ?> properties) {
285 public ServiceRegistration<?> registerService(String clazz, Object service, Dictionary<String, ?> properties) {
290 public <S> ServiceRegistration<S> registerService(Class<S> clazz, S service, Dictionary<String, ?> properties) {
295 public ServiceReference<?>[] getServiceReferences(String clazz, String filter) throws InvalidSyntaxException {
296 return new ServiceReference[0];
300 public ServiceReference<?>[] getAllServiceReferences(String clazz, String filter) throws InvalidSyntaxException {
301 return new ServiceReference[0];
305 public ServiceReference<?> getServiceReference(String clazz) {
310 public <S> ServiceReference<S> getServiceReference(Class<S> clazz) {
315 public <S> Collection<ServiceReference<S>> getServiceReferences(Class<S> clazz, String filter) throws InvalidSyntaxException {
320 public <S> S getService(ServiceReference<S> reference) {
325 public boolean ungetService(ServiceReference<?> reference) {
330 public File getDataFile(String filename) {
335 public Filter createFilter(String filter) throws InvalidSyntaxException {
340 public Bundle getBundle(String location) {
345 public <S> ServiceRegistration<S> registerService(Class<S> clazz, ServiceFactory<S> factory,
346 Dictionary<String, ?> properties) {
347 // TODO Auto-generated method stub
352 public <S> ServiceObjects<S> getServiceObjects(ServiceReference<S> reference) {
353 // TODO Auto-generated method stub