X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=tests%2Fhoneynode%2F2.2.1%2Fnetconf-impl%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fnetconf%2Fimpl%2Fosgi%2FNetconfImplActivatorTest.java;fp=tests%2Fhoneynode%2F2.2.1%2Fnetconf-impl%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fnetconf%2Fimpl%2Fosgi%2FNetconfImplActivatorTest.java;h=5f8c6d2aa46f858c39d21e330b298b2d9adc8ea2;hb=b90fdacec82f92e07d14ed1df31e3fe53275c676;hp=0000000000000000000000000000000000000000;hpb=1030996d2cfc0cec3c6c2b5d8da37c6188122372;p=transportpce.git diff --git a/tests/honeynode/2.2.1/netconf-impl/src/test/java/org/opendaylight/netconf/impl/osgi/NetconfImplActivatorTest.java b/tests/honeynode/2.2.1/netconf-impl/src/test/java/org/opendaylight/netconf/impl/osgi/NetconfImplActivatorTest.java new file mode 100644 index 000000000..5f8c6d2aa --- /dev/null +++ b/tests/honeynode/2.2.1/netconf-impl/src/test/java/org/opendaylight/netconf/impl/osgi/NetconfImplActivatorTest.java @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.netconf.impl.osgi; + +import static org.mockito.Matchers.any; +import static org.mockito.Mockito.anyString; +import static org.mockito.Mockito.doNothing; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.verify; + +import java.util.Arrays; +import java.util.Dictionary; +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.osgi.framework.BundleContext; +import org.osgi.framework.Filter; +import org.osgi.framework.ServiceListener; +import org.osgi.framework.ServiceReference; +import org.osgi.framework.ServiceRegistration; + +public class NetconfImplActivatorTest { + + @Mock + private BundleContext bundle; + @Mock + private Filter filter; + @Mock + private ServiceReference reference; + @Mock + private ServiceRegistration registration; + + @Before + public void setUp() throws Exception { + MockitoAnnotations.initMocks(this); + doReturn(filter).when(bundle).createFilter(anyString()); + doNothing().when(bundle).addServiceListener(any(ServiceListener.class), anyString()); + + ServiceReference[] refs = {}; + doReturn(refs).when(bundle).getServiceReferences(anyString(), anyString()); + doReturn(Arrays.asList(refs)).when(bundle).getServiceReferences(any(Class.class), anyString()); + doReturn("").when(bundle).getProperty(anyString()); + doReturn(registration).when(bundle).registerService(any(Class.class), + any(AggregatedNetconfOperationServiceFactory.class), any(Dictionary.class)); + doNothing().when(registration).unregister(); + doNothing().when(bundle).removeServiceListener(any(ServiceListener.class)); + } + + @Test + public void testStart() throws Exception { + NetconfImplActivator activator = new NetconfImplActivator(); + activator.start(bundle); + verify(bundle).registerService(any(Class.class), any(AggregatedNetconfOperationServiceFactory.class), + any(Dictionary.class)); + activator.stop(bundle); + } +}