2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.controller.netconf.impl.osgi;
11 import java.util.Arrays;
12 import java.util.Collection;
13 import java.util.Dictionary;
14 import org.junit.Before;
15 import org.junit.Test;
16 import org.mockito.Mock;
17 import org.mockito.MockitoAnnotations;
18 import org.opendaylight.controller.netconf.api.monitoring.NetconfMonitoringService;
19 import org.opendaylight.controller.netconf.mapping.api.NetconfOperationProvider;
20 import org.osgi.framework.*;
22 import static org.mockito.Matchers.any;
23 import static org.mockito.Mockito.*;
25 public class NetconfImplActivatorTest {
28 private BundleContext bundle;
30 private Filter filter;
32 private ServiceReference reference;
34 private ServiceRegistration registration;
37 public void setUp() throws Exception {
38 MockitoAnnotations.initMocks(this);
39 doReturn(filter).when(bundle).createFilter(anyString());
40 doNothing().when(bundle).addServiceListener(any(ServiceListener.class), anyString());
42 ServiceReference[] refs = new ServiceReference[0];
43 doReturn(refs).when(bundle).getServiceReferences(anyString(), anyString());
44 doReturn(Arrays.asList(refs)).when(bundle).getServiceReferences(any(Class.class), anyString());
45 doReturn("").when(bundle).getProperty(anyString());
46 doReturn(registration).when(bundle).registerService(any(Class.class), any(NetconfOperationServiceFactoryListenerImpl.class), any(Dictionary.class));
47 doNothing().when(registration).unregister();
48 doNothing().when(bundle).removeServiceListener(any(ServiceListener.class));
52 public void testStart() throws Exception {
53 NetconfImplActivator activator = new NetconfImplActivator();
54 activator.start(bundle);
55 verify(bundle, times(2)).registerService(any(Class.class), any(NetconfOperationServiceFactoryListenerImpl.class), any(Dictionary.class));
56 activator.stop(bundle);