X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=tests%2Fhoneynode%2F1.2.1%2Fnetconf-impl%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fnetconf%2Fimpl%2Fosgi%2FNetconfOperationServiceFactoryTrackerTest.java;fp=tests%2Fhoneynode%2F1.2.1%2Fnetconf-impl%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fnetconf%2Fimpl%2Fosgi%2FNetconfOperationServiceFactoryTrackerTest.java;h=ce20e1c0d7c8e240d9ce9bff219af49cff772b6d;hb=c764b14f67faf1665f8814db9e5d16ddb342553e;hp=0000000000000000000000000000000000000000;hpb=b90fdacec82f92e07d14ed1df31e3fe53275c676;p=transportpce.git diff --git a/tests/honeynode/1.2.1/netconf-impl/src/test/java/org/opendaylight/netconf/impl/osgi/NetconfOperationServiceFactoryTrackerTest.java b/tests/honeynode/1.2.1/netconf-impl/src/test/java/org/opendaylight/netconf/impl/osgi/NetconfOperationServiceFactoryTrackerTest.java new file mode 100644 index 000000000..ce20e1c0d --- /dev/null +++ b/tests/honeynode/1.2.1/netconf-impl/src/test/java/org/opendaylight/netconf/impl/osgi/NetconfOperationServiceFactoryTrackerTest.java @@ -0,0 +1,69 @@ +/* + * 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.junit.Assert.assertNotNull; +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.times; +import static org.mockito.Mockito.verify; + +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.opendaylight.netconf.api.util.NetconfConstants; +import org.opendaylight.netconf.mapping.api.NetconfOperationServiceFactory; +import org.opendaylight.netconf.mapping.api.NetconfOperationServiceFactoryListener; +import org.osgi.framework.BundleContext; +import org.osgi.framework.Filter; +import org.osgi.framework.ServiceReference; + +public class NetconfOperationServiceFactoryTrackerTest { + + @Mock + private Filter filter; + @Mock + private BundleContext context; + @Mock + private NetconfOperationServiceFactoryListener listener; + @Mock + private NetconfOperationServiceFactory factory; + @Mock + private ServiceReference reference; + + private NetconfOperationServiceFactoryTracker tracker; + + @Before + public void setUp() throws Exception { + MockitoAnnotations.initMocks(this); + doNothing().when(listener).onRemoveNetconfOperationServiceFactory(any(NetconfOperationServiceFactory.class)); + doReturn(filter).when(context).createFilter(anyString()); + doReturn("").when(reference).toString(); + doReturn(NetconfConstants.CONFIG_NETCONF_CONNECTOR).when(reference).getProperty(NetconfConstants.SERVICE_NAME); + doReturn(factory).when(context).getService(any(ServiceReference.class)); + doReturn("").when(factory).toString(); + doNothing().when(listener).onAddNetconfOperationServiceFactory(any(NetconfOperationServiceFactory.class)); + tracker = new NetconfOperationServiceFactoryTracker(context, listener); + } + + @Test + public void testNetconfOperationServiceFactoryTracker() throws Exception { + tracker.removedService(null, factory); + verify(listener, times(1)).onRemoveNetconfOperationServiceFactory(any(NetconfOperationServiceFactory.class)); + } + + @Test + public void testAddingService() throws Exception { + assertNotNull(tracker.addingService(reference)); + verify(listener, times(1)).onAddNetconfOperationServiceFactory(any(NetconfOperationServiceFactory.class)); + } +}