@@ -421,6 +421,44 @@ public void testDeserializationOfDateAndTimeAsLong() throws Exception {
421
421
}
422
422
}
423
423
424
+ @ Test
425
+ public void testDeserializationOfIntegerAsByteArray () throws Exception {
426
+ final BinaryLogClient client = new BinaryLogClient (slave .hostname , slave .port ,
427
+ slave .username , slave .password );
428
+ EventDeserializer eventDeserializer = new EventDeserializer ();
429
+ eventDeserializer .setCompatibilityMode (CompatibilityMode .INTEGER_AS_BYTE_ARRAY );
430
+ client .setEventDeserializer (eventDeserializer );
431
+ client .connect (DEFAULT_TIMEOUT );
432
+ try {
433
+ assertEquals (writeAndCaptureRow ("tinyint unsigned" , "0" , "1" , "255" ),
434
+ new Serializable []{new byte []{0 }, new byte []{1 }, new byte []{-1 }});
435
+ assertEquals (writeAndCaptureRow ("tinyint" , "-128" , "-1" , "0" , "1" , "127" ),
436
+ new Serializable []{new byte []{-0x80 }, new byte []{-1 }, new byte []{0 }, new byte []{1 }, new byte []{0x7f }});
437
+
438
+ assertEquals (writeAndCaptureRow ("smallint unsigned" , "0" , "1" , "65535" ),
439
+ new Serializable []{new byte []{0 , 0 }, new byte []{0 , 1 }, new byte []{-1 , -1 }});
440
+ assertEquals (writeAndCaptureRow ("smallint" , "-32768" , "-1" , "0" , "1" , "32767" ),
441
+ new Serializable []{new byte []{-0x80 , 0 }, new byte []{-1 , -1 }, new byte []{0 , 0 }, new byte []{0 , 1 }, new byte []{0x7f , -1 }});
442
+
443
+ assertEquals (writeAndCaptureRow ("mediumint unsigned" , "0" , "1" , "16777215" ),
444
+ new Serializable []{new byte []{0 , 0 , 0 }, new byte []{0 , 0 , 1 }, new byte []{-1 , -1 , -1 }});
445
+ assertEquals (writeAndCaptureRow ("mediumint" , "-8388608" , "-1" , "0" , "1" , "8388607" ),
446
+ new Serializable []{new byte []{-0x80 , 0 , 0 }, new byte []{-1 , -1 , -1 }, new byte []{0 , 0 , 0 }, new byte []{0 , 0 , 1 }, new byte []{0x7f , -1 , -1 }});
447
+
448
+ assertEquals (writeAndCaptureRow ("int unsigned" , "0" , "1" , "4294967295" ),
449
+ new Serializable []{new byte []{0 , 0 , 0 , 0 }, new byte []{0 , 0 , 0 , 1 }, new byte []{-1 , -1 , -1 , -1 }});
450
+ assertEquals (writeAndCaptureRow ("int" , "-2147483648" , "-1" , "0" , "1" , "2147483647" ),
451
+ new Serializable []{new byte []{-0x80 , 0 , 0 , 0 }, new byte []{-1 , -1 , -1 , -1 }, new byte []{0 , 0 , 0 , 0 }, new byte []{0 , 0 , 0 , 1 }, new byte []{0x7f , -1 , -1 , -1 }});
452
+
453
+ assertEquals (writeAndCaptureRow ("bigint unsigned" , "0" , "1" , "18446744073709551615" ),
454
+ new Serializable []{new byte []{0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 }, new byte []{0 , 0 , 0 , 0 , 0 , 0 , 0 , 1 }, new byte []{-1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 }});
455
+ assertEquals (writeAndCaptureRow ("bigint" , "-9223372036854775808" , "-1" , "0" , "1" , "9223372036854775807" ),
456
+ new Serializable []{new byte []{-0x80 , 0 , 0 , 0 , 0 , 0 , 0 , 0 }, new byte []{-1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 }, new byte []{0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 }, new byte []{0 , 0 , 0 , 0 , 0 , 0 , 0 , 1 }, new byte []{0x7f , -1 , -1 , -1 , -1 , -1 , -1 , -1 }});
457
+ } finally {
458
+ client .disconnect ();
459
+ }
460
+ }
461
+
424
462
@ Test
425
463
public void testDeserializationOfDateAndTimeAsLongMicrosecondsPrecision () throws Exception {
426
464
final BinaryLogClient client = new BinaryLogClient (slave .hostname , slave .port ,
0 commit comments