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.monitoring.osgi;
11 import java.util.Arrays;
12 import org.junit.Before;
13 import org.junit.Test;
14 import org.mockito.Mock;
15 import org.mockito.MockitoAnnotations;
16 import org.osgi.framework.BundleContext;
17 import org.osgi.framework.Filter;
18 import org.osgi.framework.ServiceListener;
19 import org.osgi.framework.ServiceReference;
21 import static org.mockito.Matchers.any;
22 import static org.mockito.Matchers.anyString;
23 import static org.mockito.Mockito.*;
25 public class NetconfMonitoringActivatorTest {
28 BundleContext context;
33 public void setUp() throws Exception {
34 MockitoAnnotations.initMocks(this);
35 doReturn(filter).when(context).createFilter(anyString());
36 doNothing().when(context).addServiceListener(any(ServiceListener.class), anyString());
37 ServiceReference[] refs = new ServiceReference[2];
38 doReturn(Arrays.asList(refs)).when(context).getServiceReferences(any(Class.class), anyString());
39 doReturn(refs).when(context).getServiceReferences(anyString(), anyString());
43 public void testNetconfMonitoringActivator() throws Exception {
44 NetconfMonitoringActivator activator = new NetconfMonitoringActivator();
45 activator.start(context);
46 verify(context, times(1)).addServiceListener(any(ServiceListener.class), anyString());
48 activator.stop(context);
49 verify(context, times(1)).removeServiceListener(any(ServiceListener.class));