Bump MRI upstreams
[openflowplugin.git] / openflowjava / openflow-protocol-it / src / test / java / org / opendaylight / openflowjava / protocol / it / integration / IntegrationTest.java
index 3300d8ede33efa773c90753a44959f22f48eb1bd..fde9d56876c2b434826305ef3f29d7ca31d70652 100644 (file)
@@ -5,7 +5,6 @@
  * 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.openflowjava.protocol.it.integration;
 
 import java.net.InetAddress;
@@ -13,10 +12,17 @@ import java.util.ArrayList;
 import java.util.Deque;
 import java.util.List;
 import java.util.concurrent.ExecutionException;
+import java.util.concurrent.ExecutorService;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.TimeoutException;
 import org.junit.After;
 import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.ArgumentMatchers;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.junit.MockitoJUnitRunner;
+import org.opendaylight.openflowjava.protocol.api.connection.OpenflowDiagStatusProvider;
 import org.opendaylight.openflowjava.protocol.api.connection.TlsConfiguration;
 import org.opendaylight.openflowjava.protocol.api.connection.TlsConfigurationImpl;
 import org.opendaylight.openflowjava.protocol.impl.clients.ClientEvent;
@@ -46,6 +52,7 @@ import org.slf4j.LoggerFactory;
  * @author michal.polkorab
  * @author timotej.kubas
  */
+@RunWith(MockitoJUnitRunner.class)
 public class IntegrationTest {
 
     private static final Logger LOGGER = LoggerFactory
@@ -53,12 +60,15 @@ public class IntegrationTest {
 
     private static int port;
     private TlsConfiguration tlsConfiguration;
+    private static final int CHANNEL_OUTBOUND_QUEUE_SIZE = 1024;
     private static final int SWITCH_IDLE_TIMEOUT = 2000;
     private static final long CONNECTION_TIMEOUT = 2000;
     private InetAddress startupAddress;
     private MockPlugin mockPlugin;
     private SwitchConnectionProviderImpl switchConnectionProvider;
     private ConnectionConfigurationImpl connConfig;
+    @Mock
+    private ExecutorService executorService;
 
     private Thread thread;
 
@@ -69,6 +79,10 @@ public class IntegrationTest {
 
     public void setUp(final TransportProtocol protocol) throws Exception {
         LOGGER.debug("\n starting test -------------------------------");
+        Mockito.doAnswer(invocation -> {
+            ((Runnable)invocation.getArguments()[0]).run();
+            return null;
+        }).when(executorService).execute(ArgumentMatchers.any());
 
         final String currentDir = System.getProperty("user.dir");
         LOGGER.debug("Current dir using System: {}", currentDir);
@@ -78,14 +92,15 @@ public class IntegrationTest {
             tlsConfiguration = new TlsConfigurationImpl(KeystoreType.JKS,
                     "/selfSignedSwitch", PathType.CLASSPATH, KeystoreType.JKS,
                     "/selfSignedController", PathType.CLASSPATH,
-                    new ArrayList<String>());
+                    List.of());
         }
         connConfig = new ConnectionConfigurationImpl(startupAddress, 0, tlsConfiguration,
-                SWITCH_IDLE_TIMEOUT, true, false);
+                SWITCH_IDLE_TIMEOUT, true, false, CHANNEL_OUTBOUND_QUEUE_SIZE);
         connConfig.setTransferProtocol(protocol);
-        mockPlugin = new MockPlugin();
+        mockPlugin = new MockPlugin(executorService);
 
-        switchConnectionProvider = new SwitchConnectionProviderImpl(connConfig);
+        switchConnectionProvider = new SwitchConnectionProviderImpl(connConfig,
+                Mockito.mock(OpenflowDiagStatusProvider.class));
         switchConnectionProvider.setSwitchConnectionHandler(mockPlugin);
         switchConnectionProvider.startup().get(CONNECTION_TIMEOUT, TimeUnit.MILLISECONDS);
         if (protocol.equals(TransportProtocol.TCP) || protocol.equals(TransportProtocol.TLS)) {
@@ -98,7 +113,7 @@ public class IntegrationTest {
     }
 
     @After
-    public void tearDown() throws Exception {
+    public void tearDown() {
         switchConnectionProvider.close();
         LOGGER.debug("\n ending test -------------------------------");
     }