Migrate openflowplugim-impl tests to uint types
[openflowplugin.git] / openflowplugin-impl / src / test / java / org / opendaylight / openflowplugin / impl / connection / ConnectionManagerImplTest.java
index 4b5c75252007d66bc261cb35e19d58ae53022157..4299e033a99c182187a453d9b72112b5e89e0467 100644 (file)
@@ -26,9 +26,10 @@ import org.mockito.Mock;
 import org.mockito.Mockito;
 import org.mockito.junit.MockitoJUnitRunner;
 import org.opendaylight.mdsal.binding.api.DataBroker;
+import org.opendaylight.mdsal.binding.api.NotificationPublishService;
 import org.opendaylight.openflowjava.protocol.api.connection.ConnectionAdapter;
 import org.opendaylight.openflowjava.protocol.api.connection.ConnectionReadyListener;
-import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
 import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext;
 import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceConnectedHandler;
 import org.opendaylight.openflowplugin.impl.util.ThreadPoolLoggingExecutor;
@@ -45,6 +46,10 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.provider.config.rev160510.OpenflowProviderConfigBuilder;
 import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
+import org.opendaylight.yangtools.yang.common.Uint16;
+import org.opendaylight.yangtools.yang.common.Uint32;
+import org.opendaylight.yangtools.yang.common.Uint64;
+import org.opendaylight.yangtools.yang.common.Uint8;
 
 /**
  * Test of {@link ConnectionManagerImpl} - lightweight version, using basic ways (TDD).
@@ -59,6 +64,8 @@ public class ConnectionManagerImplTest {
     private ConnectionAdapter connection;
     @Mock
     private DeviceConnectedHandler deviceConnectedHandler;
+    @Mock
+    private NotificationPublishService notificationPublishService;
     @Captor
     private ArgumentCaptor<ConnectionReadyListener> connectionReadyListenerAC;
     @Captor
@@ -66,9 +73,10 @@ public class ConnectionManagerImplTest {
     @Mock
     DataBroker dataBroker;
 
-    private static final long ECHO_REPLY_TIMEOUT = 500;
-    private static final int DEVICE_CONNECTION_RATE_LIMIT_PER_MIN = 0;
-    private static final int DEVICE_CONNECTION_HOLD_TIME_IN_SECONDS = 60;
+    private static final Uint32 ECHO_REPLY_TIMEOUT = Uint32.valueOf(500);
+    private static final Uint16 DEVICE_CONNECTION_RATE_LIMIT_PER_MIN = Uint16.ZERO;
+    private static final Uint16 DEVICE_CONNECTION_HOLD_TIME_IN_SECONDS = Uint16.valueOf(60);
+    private static final boolean ENABLE_CUSTOM_TRUST_MANAGER = false;
 
     @Before
     public void setUp() {
@@ -80,7 +88,8 @@ public class ConnectionManagerImplTest {
                 .setEchoReplyTimeout(new NonZeroUint32Type(ECHO_REPLY_TIMEOUT))
                 .setDeviceConnectionRateLimitPerMin(DEVICE_CONNECTION_RATE_LIMIT_PER_MIN)
                 .setDeviceConnectionHoldTimeInSeconds(DEVICE_CONNECTION_HOLD_TIME_IN_SECONDS)
-                .build(), threadPool, dataBroker);
+                .setEnableCustomTrustManager(ENABLE_CUSTOM_TRUST_MANAGER)
+                .build(), threadPool, dataBroker, notificationPublishService);
 
         connectionManagerImpl.setDeviceConnectedHandler(deviceConnectedHandler);
         final InetSocketAddress deviceAddress = InetSocketAddress.createUnresolved("yahoo", 42);
@@ -134,19 +143,22 @@ public class ConnectionManagerImplTest {
 
         //set dpn last connected time to be before dpn hold time seconds from now
         connectionManagerImpl.getDeviceConnectionStatusProvider().addDeviceLastConnectionTime(BigInteger.TEN,
-                LocalDateTime.now().minusSeconds(DEVICE_CONNECTION_HOLD_TIME_IN_SECONDS));
+                LocalDateTime.now().minusSeconds(DEVICE_CONNECTION_HOLD_TIME_IN_SECONDS.toJava()));
 
         // send hello reply
-        final HelloMessage hello = new HelloMessageBuilder().setVersion(OFConstants.OFP_VERSION_1_3).setXid(1L).build();
+        final HelloMessage hello = new HelloMessageBuilder()
+                .setVersion(EncodeConstants.OF_VERSION_1_3)
+                .setXid(Uint32.ONE)
+                .build();
         ofpListenerAC.getValue().onHelloMessage(hello);
 
         // deliver getFeature output
         Thread.sleep(100L);
         final GetFeaturesOutput getFeatureOutput = new GetFeaturesOutputBuilder()
-                .setDatapathId(BigInteger.TEN)
-                .setVersion(OFConstants.OFP_VERSION_1_3)
-                .setXid(2L)
-                .setTables((short) 15)
+                .setDatapathId(Uint64.TEN)
+                .setVersion(EncodeConstants.OF_VERSION_1_3)
+                .setXid(Uint32.TWO)
+                .setTables(Uint8.valueOf(15))
                 .build();
         final RpcResult<GetFeaturesOutput> rpcFeaturesOutput = RpcResultBuilder.success(getFeatureOutput).build();
         featureResponseFx.set(rpcFeaturesOutput);
@@ -185,10 +197,13 @@ public class ConnectionManagerImplTest {
 
         //set dpn last connected time to be before dpn hold time seconds from now
         connectionManagerImpl.getDeviceConnectionStatusProvider().addDeviceLastConnectionTime(BigInteger.TEN,
-                LocalDateTime.now().minusSeconds(DEVICE_CONNECTION_HOLD_TIME_IN_SECONDS));
+                LocalDateTime.now().minusSeconds(DEVICE_CONNECTION_HOLD_TIME_IN_SECONDS.toJava()));
 
         // fire handshake - send hello reply
-        final HelloMessage hello = new HelloMessageBuilder().setVersion(OFConstants.OFP_VERSION_1_3).setXid(1L).build();
+        final HelloMessage hello = new HelloMessageBuilder()
+                .setVersion(EncodeConstants.OF_VERSION_1_3)
+                .setXid(Uint32.ONE)
+                .build();
         ofpListenerAC.getValue().onHelloMessage(hello);
 
         // notify about connection ready
@@ -202,10 +217,10 @@ public class ConnectionManagerImplTest {
         // deliver getFeature output
         Thread.sleep(100L);
         final GetFeaturesOutput getFeatureOutput = new GetFeaturesOutputBuilder()
-                .setDatapathId(BigInteger.TEN)
-                .setVersion(OFConstants.OFP_VERSION_1_3)
-                .setXid(2L)
-                .setTables((short) 15)
+                .setDatapathId(Uint64.TEN)
+                .setVersion(EncodeConstants.OF_VERSION_1_3)
+                .setXid(Uint32.TWO)
+                .setTables(Uint8.valueOf(15))
                 .build();
         final RpcResult<GetFeaturesOutput> rpcFeaturesOutput = RpcResultBuilder.success(getFeatureOutput).build();
         featureResponseFx.set(rpcFeaturesOutput);