Merge "Bug 2697: Improvement wrong response handling, missing message"
[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 static org.mockito.Matchers.any;
12 import static org.mockito.Mockito.anyString;
13 import static org.mockito.Mockito.doNothing;
14 import static org.mockito.Mockito.doReturn;
15 import static org.mockito.Mockito.verify;
16
17 import java.util.Arrays;
18 import java.util.Dictionary;
19 import org.junit.Before;
20 import org.junit.Test;
21 import org.mockito.Mock;
22 import org.mockito.MockitoAnnotations;
23 import org.osgi.framework.BundleContext;
24 import org.osgi.framework.Filter;
25 import org.osgi.framework.ServiceListener;
26 import org.osgi.framework.ServiceReference;
27 import org.osgi.framework.ServiceRegistration;
28
29 public class NetconfImplActivatorTest {
30
31     @Mock
32     private BundleContext bundle;
33     @Mock
34     private Filter filter;
35     @Mock
36     private ServiceReference<?> reference;
37     @Mock
38     private ServiceRegistration<?> registration;
39
40     @Before
41     public void setUp() throws Exception {
42         MockitoAnnotations.initMocks(this);
43         doReturn(filter).when(bundle).createFilter(anyString());
44         doNothing().when(bundle).addServiceListener(any(ServiceListener.class), anyString());
45
46         ServiceReference<?>[] refs = {};
47         doReturn(refs).when(bundle).getServiceReferences(anyString(), anyString());
48         doReturn(Arrays.asList(refs)).when(bundle).getServiceReferences(any(Class.class), anyString());
49         doReturn("").when(bundle).getProperty(anyString());
50         doReturn(registration).when(bundle).registerService(any(Class.class), any(AggregatedNetconfOperationServiceFactory.class), any(Dictionary.class));
51         doNothing().when(registration).unregister();
52         doNothing().when(bundle).removeServiceListener(any(ServiceListener.class));
53     }
54
55     @Test
56     public void testStart() throws Exception {
57         NetconfImplActivator activator = new NetconfImplActivator();
58         activator.start(bundle);
59         verify(bundle).registerService(any(Class.class), any(AggregatedNetconfOperationServiceFactory.class), any(Dictionary.class));
60         activator.stop(bundle);
61     }
62 }