OPNFLWPLUG-1010 Adopt mdsal changes proposed through weather item TSC-99
[openflowplugin.git] / openflowplugin-impl / src / test / java / org / opendaylight / openflowplugin / impl / OpenFlowPluginProviderImplTest.java
index feb26ec103864529af7c2a648e3db24825d7a29c..c7f8e4052e31d01f0a7ce044032d5474a572a4f1 100644 (file)
@@ -23,13 +23,14 @@ import org.mockito.runners.MockitoJUnitRunner;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 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.openflow.OpenFlowPluginProvider;
+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;
@@ -47,6 +48,12 @@ public class OpenFlowPluginProviderImplTest {
     @Mock
     NotificationPublishService notificationPublishService;
 
+    @Mock
+    OpenflowPluginDiagStatusProvider ofPluginDiagstatusProvider;
+
+    @Mock
+    SystemReadyMonitor systemReadyMonitor;
+
     @Mock
     WriteTransaction writeTransaction;
 
@@ -78,36 +85,52 @@ public class OpenFlowPluginProviderImplTest {
     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 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(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.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 OpenFlowPluginProvider provider = new OpenFlowPluginProviderFactoryImpl().newInstance(
+        final OpenFlowPluginProviderImpl provider = new OpenFlowPluginProviderImpl(
                 configurationService,
+                Lists.newArrayList(switchConnectionProvider),
                 dataBroker,
                 rpcProviderRegistry,
                 notificationPublishService,
-                entityOwnershipService,
-                Lists.newArrayList(switchConnectionProvider),
                 clusterSingletonServiceProvider,
-                mastershipChangeServiceManager);
+                entityOwnershipService,
+                mastershipChangeServiceManager,
+                ofPluginDiagstatusProvider,
+                systemReadyMonitor);
 
+        provider.initialize();
+        // Calling the onSystemBootReady() callback
+        provider.onSystemBootReady();
         verify(switchConnectionProvider).startup();
         provider.close();
         verify(switchConnectionProvider).shutdown();