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=c7f8e4052e31d01f0a7ce044032d5474a572a4f1;hb=f913888c89b58874b1576d6b9d426effbc3b12ee;hp=dc619d61fc0f707f2422d9a200b2b81b9bfc1216;hpb=719ffdf0dfac6787cf9289b98ea465f4af45c86b;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 dc619d61fc..c7f8e4052e 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 @@ -15,21 +15,25 @@ 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.infrautils.ready.SystemReadyMonitor; +import org.opendaylight.mdsal.eos.binding.api.EntityOwnershipListenerRegistration; +import org.opendaylight.mdsal.eos.binding.api.EntityOwnershipService; import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider; import org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProvider; +import org.opendaylight.openflowplugin.api.diagstatus.OpenflowPluginDiagStatusProvider; +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) @@ -42,7 +46,13 @@ public class OpenFlowPluginProviderImplTest { RpcProviderRegistry rpcProviderRegistry; @Mock - NotificationService notificationService; + NotificationPublishService notificationPublishService; + + @Mock + OpenflowPluginDiagStatusProvider ofPluginDiagstatusProvider; + + @Mock + SystemReadyMonitor systemReadyMonitor; @Mock WriteTransaction writeTransaction; @@ -62,44 +72,67 @@ public class OpenFlowPluginProviderImplTest { @Mock ClusterSingletonServiceProvider clusterSingletonServiceProvider; - private static final long RPC_REQUESTS_QUOTA = 500; + @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 OpenFlowPluginProviderImpl provider; + private static final long BASIC_TIMER_DELAY = 1L; + private static final boolean USE_SINGLE_LAYER_SERIALIZATION = false; + private static final int DEVICE_CONNECTION_RATE_LIMIT_PER_MIN = 0; @Before public void setUp() throws Exception { when(dataBroker.newWriteOnlyTransaction()).thenReturn(writeTransaction); when(writeTransaction.submit()).thenReturn(Futures.immediateCheckedFuture(null)); 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, - THREAD_POOL_MIN_THREADS, - THREAD_POOL_MAX_THREADS, - THREAD_POOL_TIMEOUT); - - provider.setDataBroker(dataBroker); - provider.setRpcProviderRegistry(rpcProviderRegistry); - provider.setNotificationProviderService(notificationService); - provider.setSwitchConnectionProviders(Lists.newArrayList(switchConnectionProvider)); - provider.setClusteringSingletonServicesProvider(clusterSingletonServiceProvider); - } - - @After - public void tearDown() throws Exception { - + when(rpcProviderRegistry.addRpcImplementation(eq(StatisticsManagerControlService.class), any())) + .thenReturn(controlServiceRegistration); + when(switchConnectionProvider.startup()).thenReturn(Futures.immediateFuture(true)); + when(switchConnectionProvider.shutdown()).thenReturn(Futures.immediateFuture(true)); + 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); + when(configurationService.getProperty(eq(ConfigurationProperty.DEVICE_CONNECTION_RATE_LIMIT_PER_MIN.toString()), + any())).thenReturn(DEVICE_CONNECTION_RATE_LIMIT_PER_MIN); } @Test public void testInitializeAndClose() throws Exception { + final OpenFlowPluginProviderImpl provider = new OpenFlowPluginProviderImpl( + configurationService, + Lists.newArrayList(switchConnectionProvider), + dataBroker, + rpcProviderRegistry, + notificationPublishService, + clusterSingletonServiceProvider, + entityOwnershipService, + mastershipChangeServiceManager, + ofPluginDiagstatusProvider, + systemReadyMonitor); + provider.initialize(); + // Calling the onSystemBootReady() callback + provider.onSystemBootReady(); verify(switchConnectionProvider).startup(); + provider.close(); + verify(switchConnectionProvider).shutdown(); } -} \ No newline at end of file +}