Skip to content

Commit 09e9e64

Browse files
committed
add testDeserializationOfIntegerAsByteArray in BinaryLogClientIntegrationTest.
1 parent 7d6d123 commit 09e9e64

File tree

2 files changed

+41
-3
lines changed

2 files changed

+41
-3
lines changed

src/test/java/com/github/shyiko/mysql/binlog/BinaryLogClientIntegrationTest.java

+38
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,44 @@ public void testDeserializationOfDateAndTimeAsLong() throws Exception {
421421
}
422422
}
423423

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+
424462
@Test
425463
public void testDeserializationOfDateAndTimeAsLongMicrosecondsPrecision() throws Exception {
426464
final BinaryLogClient client = new BinaryLogClient(slave.hostname, slave.port,

src/test/onetimeserver

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ PLATFORM=${_PLATFORM/ /-}
55

66
OS=`uname -s | tr '[:upper:]' '[:lower:]'`
77

8-
THIS_URL="https://raw.githubusercontent.com/osheroff/onetimeserver/master/onetimeserver"
9-
WRAPPER_URL="https://raw.githubusercontent.com/osheroff/onetimeserver/master/wrapper/wrapper.c"
10-
ONETIMESERVER_URL="https://raw.githubusercontent.com/osheroff/onetimeserver-binaries/master/onetimeserver-go/$OS/onetimeserver-go"
8+
THIS_URL="https://gitee.com/zengzetang/onetimeserver/raw/master/onetimeserver"
9+
WRAPPER_URL="https://gitee.com/zengzetang/onetimeserver/raw/master/wrapper/wrapper.c"
10+
ONETIMESERVER_URL="http://localhost:8888/Desktop/onetimeserver-go.txt"
1111
CACHE_DIR=$HOME/.onetimeserver/$PLATFORM
1212

1313
function usage() {

0 commit comments

Comments
 (0)