|
2 | 2 |
|
3 | 3 | import com.github.shyiko.mysql.binlog.event.TableMapEventMetadata;
|
4 | 4 | import com.github.shyiko.mysql.binlog.io.ByteArrayInputStream;
|
| 5 | + |
5 | 6 | import org.testng.annotations.Test;
|
6 | 7 |
|
7 | 8 | import java.io.IOException;
|
@@ -29,26 +30,35 @@ public class TableMapEventMetadataDeserializerTest {
|
29 | 30 | */
|
30 | 31 | @Test
|
31 | 32 | public void deserialize() throws IOException {
|
32 |
| - byte[] metadataIncludingUnknownFieldType = {1, 2, -1, 2, 9, 83, 6, 63, 7, 63, 8, 63, 9, 63}; |
| 33 | + byte[] metadataIncludingUnknownFieldType = { 1, 1, 29, 2, 9, 83, 6, 63, 7, 63, 8, 63, 9, 63 }; |
33 | 34 | TableMapEventMetadataDeserializer deserializer = new TableMapEventMetadataDeserializer();
|
34 | 35 | // suppose there Columns idx likes
|
35 |
| - // col 0, 2, 4, 6, 7, 9, 11, 13 unsigned |
36 |
| - // col 1 ,3 ..., 22 signed or non numeric |
37 |
| - List<Integer> numericIndexWithAllColumn = Arrays.asList(0, 2, 4, 6, 7, 9, 11, 13); |
| 36 | + // col 0, 1, 10, 11,,, non numeric |
| 37 | + // col 2, 3, 4, 8 signed |
| 38 | + // col 5, 6, 7, 9 unsigned |
| 39 | + List<Integer> numericIndexWithAllColumn = Arrays.asList(2, 3, 4, 5, 6, 7, 8, 9); |
38 | 40 | TableMapEventMetadata tableMapEventMetadata =
|
39 |
| - deserializer.deserialize(new ByteArrayInputStream(metadataIncludingUnknownFieldType), 23, 8, numericIndexWithAllColumn); |
| 41 | + deserializer.deserialize(new ByteArrayInputStream(metadataIncludingUnknownFieldType), 23, 8, |
| 42 | + numericIndexWithAllColumn); |
40 | 43 |
|
41 | 44 | Map<Integer, Integer> expectedCharsetCollations = new LinkedHashMap<>();
|
42 | 45 | expectedCharsetCollations.put(6, 63);
|
43 | 46 | expectedCharsetCollations.put(7, 63);
|
44 | 47 | expectedCharsetCollations.put(8, 63);
|
45 | 48 | expectedCharsetCollations.put(9, 63);
|
46 | 49 |
|
| 50 | + // metadataIncludingUnknownFieldType[2] = 29 |
| 51 | + // bin 00011101 |
| 52 | + // 2, 3, 4, 5(hit), 6(hit), 7(hit), 8, 9(hit |
47 | 53 | BitSet expectAllColumnBitSet = new BitSet();
|
48 |
| - for(int i=0; i< numericIndexWithAllColumn.size(); i++)expectAllColumnBitSet.set(numericIndexWithAllColumn.get(i)); |
| 54 | + expectAllColumnBitSet.set(5); |
| 55 | + expectAllColumnBitSet.set(6); |
| 56 | + expectAllColumnBitSet.set(7); |
| 57 | + expectAllColumnBitSet.set(9); |
49 | 58 |
|
50 | 59 | assertEquals(tableMapEventMetadata.getDefaultCharset().getDefaultCharsetCollation(), 83);
|
51 |
| - assertEquals(tableMapEventMetadata.getDefaultCharset().getCharsetCollations(), expectedCharsetCollations); |
| 60 | + assertEquals(tableMapEventMetadata.getDefaultCharset().getCharsetCollations(), |
| 61 | + expectedCharsetCollations); |
52 | 62 | assertEquals(tableMapEventMetadata.getSignedness(), expectAllColumnBitSet);
|
53 | 63 | }
|
54 | 64 | }
|
0 commit comments