X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=openflowplugin-impl%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fopenflowplugin%2Fimpl%2FOpenFlowPluginProviderImplTest.java;h=acf9f1f42e5009a6d12e47683cd759865bc267ac;hb=55d7ecd5a44d3cc29598fda492ce527e082c7448;hp=c32fdc8aab54cbde124a6d2ebcc4ab98e5743007;hpb=f7bb5e29abc769d488b32d5ef74c4844e2aa31d8;p=openflowplugin.git diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/OpenFlowPluginProviderImplTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/OpenFlowPluginProviderImplTest.java index c32fdc8aab..acf9f1f42e 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/OpenFlowPluginProviderImplTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/OpenFlowPluginProviderImplTest.java @@ -10,25 +10,28 @@ package org.opendaylight.openflowplugin.impl; import static org.mockito.Matchers.any; import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; + import com.google.common.collect.Lists; import com.google.common.util.concurrent.Futures; -import org.junit.After; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.runners.MockitoJUnitRunner; import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.NotificationService; +import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService; import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipListenerRegistration; import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipService; import org.opendaylight.controller.sal.binding.api.BindingAwareBroker; import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; +import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider; import org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProvider; +import org.opendaylight.openflowplugin.api.openflow.configuration.ConfigurationProperty; +import org.opendaylight.openflowplugin.api.openflow.configuration.ConfigurationService; +import org.opendaylight.openflowplugin.api.openflow.mastership.MastershipChangeServiceManager; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.sm.control.rev150812.StatisticsManagerControlService; @RunWith(MockitoJUnitRunner.class) @@ -41,7 +44,7 @@ public class OpenFlowPluginProviderImplTest { RpcProviderRegistry rpcProviderRegistry; @Mock - NotificationService notificationService; + NotificationPublishService notificationPublishService; @Mock WriteTransaction writeTransaction; @@ -58,8 +61,22 @@ public class OpenFlowPluginProviderImplTest { @Mock SwitchConnectionProvider switchConnectionProvider; - private static final long RPC_REQUESTS_QUOTA = 500; + @Mock + ClusterSingletonServiceProvider clusterSingletonServiceProvider; + + @Mock + ConfigurationService configurationService; + + @Mock + MastershipChangeServiceManager mastershipChangeServiceManager; + + private static final int RPC_REQUESTS_QUOTA = 500; private static final long GLOBAL_NOTIFICATION_QUOTA = 131072; + private static final int THREAD_POOL_MIN_THREADS = 1; + private static final int THREAD_POOL_MAX_THREADS = 32000; + private static final long THREAD_POOL_TIMEOUT = 60; + private static final long BASIC_TIMER_DELAY = 1L; + private static final boolean USE_SINGLE_LAYER_SERIALIZATION = false; private OpenFlowPluginProviderImpl provider; @@ -70,26 +87,28 @@ public class OpenFlowPluginProviderImplTest { when(entityOwnershipService.registerListener(any(), any())).thenReturn(entityOwnershipListenerRegistration); when(rpcProviderRegistry.addRpcImplementation(eq(StatisticsManagerControlService.class), any())).thenReturn(controlServiceRegistration); when(switchConnectionProvider.startup()).thenReturn(Futures.immediateCheckedFuture(null)); - - provider = new OpenFlowPluginProviderImpl(RPC_REQUESTS_QUOTA, GLOBAL_NOTIFICATION_QUOTA); - provider.setDataBroker(dataBroker); - provider.setRpcProviderRegistry(rpcProviderRegistry); - provider.setNotificationProviderService(notificationService); - provider.setEntityOwnershipService(entityOwnershipService); - provider.setSwitchConnectionProviders(Lists.newArrayList(switchConnectionProvider)); - } - - @After - public void tearDown() throws Exception { - + when(configurationService.getProperty(eq(ConfigurationProperty.USE_SINGLE_LAYER_SERIALIZATION.toString()), any())).thenReturn(USE_SINGLE_LAYER_SERIALIZATION); + when(configurationService.getProperty(eq(ConfigurationProperty.THREAD_POOL_MIN_THREADS.toString()), any())).thenReturn(THREAD_POOL_MIN_THREADS); + when(configurationService.getProperty(eq(ConfigurationProperty.THREAD_POOL_MAX_THREADS.toString()), any())).thenReturn(THREAD_POOL_MAX_THREADS); + when(configurationService.getProperty(eq(ConfigurationProperty.THREAD_POOL_TIMEOUT.toString()), any())).thenReturn(THREAD_POOL_TIMEOUT); + when(configurationService.getProperty(eq(ConfigurationProperty.RPC_REQUESTS_QUOTA.toString()), any())).thenReturn(RPC_REQUESTS_QUOTA); + when(configurationService.getProperty(eq(ConfigurationProperty.GLOBAL_NOTIFICATION_QUOTA.toString()), any())).thenReturn(GLOBAL_NOTIFICATION_QUOTA); + when(configurationService.getProperty(eq(ConfigurationProperty.BASIC_TIMER_DELAY.toString()), any())).thenReturn(BASIC_TIMER_DELAY); + + provider = new OpenFlowPluginProviderImpl( + configurationService, + Lists.newArrayList(switchConnectionProvider), + dataBroker, + rpcProviderRegistry, + notificationPublishService, + clusterSingletonServiceProvider, + entityOwnershipService, + mastershipChangeServiceManager); } @Test public void testInitializeAndClose() throws Exception { provider.initialize(); verify(switchConnectionProvider).startup(); - - provider.close(); - verify(entityOwnershipListenerRegistration, times(2)).close(); } -} \ No newline at end of file +}