Bug-915: Adding static document generation.
[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 static org.mockito.Matchers.any;
12 import static org.mockito.Matchers.anyString;
13 import static org.mockito.Mockito.doNothing;
14 import static org.mockito.Mockito.doReturn;
15 import static org.mockito.Mockito.times;
16 import static org.mockito.Mockito.verify;
17 import java.util.Arrays;
18 import org.junit.Before;
19 import org.junit.Test;
20 import org.mockito.Mock;
21 import org.mockito.MockitoAnnotations;
22 import org.osgi.framework.BundleContext;
23 import org.osgi.framework.Filter;
24 import org.osgi.framework.ServiceListener;
25 import org.osgi.framework.ServiceReference;
26
27 public class NetconfMonitoringActivatorTest {
28
29     @Mock
30     BundleContext context;
31     @Mock
32     Filter filter;
33
34     @Before
35     public void setUp() throws Exception {
36         MockitoAnnotations.initMocks(this);
37         doReturn(filter).when(context).createFilter(anyString());
38         doNothing().when(context).addServiceListener(any(ServiceListener.class), anyString());
39         ServiceReference<?>[] refs = new ServiceReference[2];
40         doReturn(Arrays.asList(refs)).when(context).getServiceReferences(any(Class.class), anyString());
41         doReturn(refs).when(context).getServiceReferences(anyString(), anyString());
42     }
43
44     @Test
45     public void testNetconfMonitoringActivator() throws Exception {
46         NetconfMonitoringActivator activator = new NetconfMonitoringActivator();
47         activator.start(context);
48         verify(context, times(1)).addServiceListener(any(ServiceListener.class), anyString());
49
50         activator.stop(context);
51         verify(context, times(1)).removeServiceListener(any(ServiceListener.class));
52     }
53 }