Merge "Fix checkstyle warnings in opendaylight/netconf"
[controller.git] / opendaylight / netconf / netconf-impl / src / test / java / org / opendaylight / controller / netconf / impl / osgi / NetconfImplActivatorTest.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.impl.osgi;
10
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.*;
21
22 import static org.mockito.Matchers.any;
23 import static org.mockito.Mockito.*;
24
25 public class NetconfImplActivatorTest {
26
27     @Mock
28     private BundleContext bundle;
29     @Mock
30     private Filter filter;
31     @Mock
32     private ServiceReference reference;
33     @Mock
34     private ServiceRegistration registration;
35
36     @Before
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());
41
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));
49     }
50
51     @Test
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);
57     }
58 }