Merge "BUG 1839 - HTTP delete of non existing data"
[controller.git] / opendaylight / netconf / netconf-monitoring / src / test / java / org / opendaylight / controller / netconf / monitoring / osgi / NetconfMonitoringActivatorTest.java
1 /*
2  * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8
9 package org.opendaylight.controller.netconf.monitoring.osgi;
10
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;
20
21 import static org.mockito.Matchers.any;
22 import static org.mockito.Matchers.anyString;
23 import static org.mockito.Mockito.*;
24
25 public class NetconfMonitoringActivatorTest {
26
27     @Mock
28     BundleContext context;
29     @Mock
30     Filter filter;
31
32     @Before
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());
40     }
41
42     @Test
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());
47
48         activator.stop(context);
49         verify(context, times(1)).removeServiceListener(any(ServiceListener.class));
50     }
51 }