mirror of
https://github.com/alibaba/canal.git
synced 2026-11-04 00:30:15 +08:00
Add unit tests (#2235)
* Add Unit Tests for the following classes: com.alibaba.otter.canal.client.adapter.support.JdbcTypeUtilTest com.alibaba.otter.canal.client.adapter.support.UtilTest com.taobao.tddl.dbsync.binlog.JsonConversion_Json_ValueTest com.taobao.tddl.dbsync.binlog.JsonDiffConversionTest com.taobao.tddl.dbsync.binlog.LogBufferTest com.taobao.tddl.dbsync.binlog.LogEventTest com.taobao.tddl.dbsync.binlog.event.LogHeaderTest com.taobao.tddl.dbsync.binlog.event.RowsLogBufferTest com.alibaba.otter.canal.parse.driver.mysql.packets.client.RegisterSlaveCommandPacketTest com.alibaba.otter.canal.parse.driver.mysql.utils.ByteHelperTest com.alibaba.otter.canal.parse.inbound.mysql.ddl.DdlResultTest com.alibaba.otter.canal.parse.inbound.mysql.ddl.DruidDdlParserTest These tests were written using Diffblue Cover * Add dependencies and refactor
This commit is contained in:
@@ -44,5 +44,35 @@
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.powermock</groupId>
|
||||
<artifactId>powermock-api-mockito</artifactId>
|
||||
<version>1.6.5</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.powermock</groupId>
|
||||
<artifactId>powermock-module-junit4</artifactId>
|
||||
<version>1.6.5</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-all</artifactId>
|
||||
<version>1.10.19</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.8.2</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.diffblue</groupId>
|
||||
<artifactId>deeptestutils</artifactId>
|
||||
<version>1.9.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
package com.taobao.tddl.dbsync.binlog;
|
||||
|
||||
import com.taobao.tddl.dbsync.binlog.JsonConversion.Json_Value;
|
||||
import com.taobao.tddl.dbsync.binlog.JsonConversion.Json_enum_type;
|
||||
import com.taobao.tddl.dbsync.binlog.JsonConversion;
|
||||
import com.taobao.tddl.dbsync.binlog.LogBuffer;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
import org.junit.rules.Timeout;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
public class JsonConversion_Json_ValueTest {
|
||||
|
||||
@Rule public final ExpectedException thrown = ExpectedException.none();
|
||||
|
||||
@Rule public final Timeout globalTimeout = new Timeout(10000);
|
||||
|
||||
/* testedClasses: JsonConversion_Json_Value */
|
||||
// Test written by Diffblue Cover.
|
||||
|
||||
@Test
|
||||
public void constructorInputNullNotNullOutputVoid() {
|
||||
|
||||
// Arrange
|
||||
final Json_enum_type t = null;
|
||||
final String value = ",";
|
||||
|
||||
// Act, creating object to test constructor
|
||||
final Json_Value objectUnderTest = new Json_Value(t, value);
|
||||
|
||||
// Assert side effects
|
||||
Assert.assertEquals(",", objectUnderTest.m_string_value);
|
||||
}
|
||||
|
||||
// Test written by Diffblue Cover.
|
||||
@Test
|
||||
public void parse_valueInputZeroNotNullPositiveNotNullOutputIllegalArgumentException() {
|
||||
|
||||
// Arrange
|
||||
final int type = 0;
|
||||
final LogBuffer buffer = new LogBuffer();
|
||||
final long len = 4_294_967_297L;
|
||||
final String charsetName = "3";
|
||||
|
||||
// Act
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
JsonConversion.parse_value(type, buffer, len, charsetName);
|
||||
|
||||
// Method is not expected to return due to exception thrown
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,214 @@
|
||||
package com.taobao.tddl.dbsync.binlog;
|
||||
|
||||
import com.taobao.tddl.dbsync.binlog.JsonDiffConversion;
|
||||
import com.taobao.tddl.dbsync.binlog.LogBuffer;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
import org.junit.rules.Timeout;
|
||||
|
||||
import java.lang.reflect.Array;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
public class JsonDiffConversionTest {
|
||||
|
||||
@Rule public final ExpectedException thrown = ExpectedException.none();
|
||||
|
||||
@Rule public final Timeout globalTimeout = new Timeout(10000);
|
||||
|
||||
/* testedClasses: JsonDiffConversion */
|
||||
// Test written by Diffblue Cover.
|
||||
@Test
|
||||
public void print_json_diffInputNotNullPositiveNotNullZeroNotNullOutputIllegalArgumentException()
|
||||
throws InvocationTargetException {
|
||||
|
||||
// Arrange
|
||||
final LogBuffer buffer = new LogBuffer();
|
||||
buffer.position = 28;
|
||||
buffer.semival = 0;
|
||||
final byte[] myByteArray = {(byte)3, (byte)3, (byte)67, (byte)67, (byte)67, (byte)67,
|
||||
(byte)67, (byte)66, (byte)67, (byte)66, (byte)67, (byte)66,
|
||||
(byte)67, (byte)67, (byte)67, (byte)66, (byte)67, (byte)66,
|
||||
(byte)67, (byte)66, (byte)67, (byte)67, (byte)67, (byte)66,
|
||||
(byte)67, (byte)67, (byte)67, (byte)66, (byte)2, (byte)66};
|
||||
buffer.buffer = myByteArray;
|
||||
buffer.limit = -1_000_000_065;
|
||||
buffer.origin = 1_000_000_096;
|
||||
final long len = 71L;
|
||||
final String columnName = "foo";
|
||||
final int columnIndex = 0;
|
||||
final String charsetName = "foo";
|
||||
try {
|
||||
|
||||
// Act
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
JsonDiffConversion.print_json_diff(buffer, len, columnName, columnIndex, charsetName);
|
||||
} catch (IllegalArgumentException ex) {
|
||||
|
||||
// Assert side effects
|
||||
Assert.assertNotNull(buffer);
|
||||
Assert.assertEquals(30, buffer.position);
|
||||
Assert.assertEquals(0, buffer.semival);
|
||||
Assert.assertArrayEquals(new byte[] {(byte)3, (byte)3, (byte)67, (byte)67, (byte)67,
|
||||
(byte)67, (byte)67, (byte)66, (byte)67, (byte)66,
|
||||
(byte)67, (byte)66, (byte)67, (byte)67, (byte)67,
|
||||
(byte)66, (byte)67, (byte)66, (byte)67, (byte)66,
|
||||
(byte)67, (byte)67, (byte)67, (byte)66, (byte)67,
|
||||
(byte)67, (byte)67, (byte)66, (byte)2, (byte)66},
|
||||
buffer.buffer);
|
||||
Assert.assertEquals(-1_000_000_065, buffer.limit);
|
||||
Assert.assertEquals(1_000_000_096, buffer.origin);
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
// Test written by Diffblue Cover.
|
||||
@Test
|
||||
public void print_json_diffInputNotNullZeroNotNullZeroNotNullOutputIllegalArgumentException()
|
||||
throws InvocationTargetException {
|
||||
|
||||
// Arrange
|
||||
final LogBuffer buffer = new LogBuffer();
|
||||
buffer.position = 28;
|
||||
buffer.semival = 0;
|
||||
final byte[] myByteArray = {
|
||||
(byte)2, (byte)2, (byte)2, (byte)2, (byte)2, (byte)2, (byte)2, (byte)2, (byte)2, (byte)2,
|
||||
(byte)2, (byte)2, (byte)2, (byte)2, (byte)2, (byte)2, (byte)2, (byte)2, (byte)2, (byte)2,
|
||||
(byte)2, (byte)2, (byte)2, (byte)2, (byte)2, (byte)2, (byte)2, (byte)2, (byte)3, (byte)2};
|
||||
buffer.buffer = myByteArray;
|
||||
buffer.limit = 31;
|
||||
buffer.origin = 0;
|
||||
final long len = 0L;
|
||||
final String columnName = "foo";
|
||||
final int columnIndex = 0;
|
||||
final String charsetName = "foo";
|
||||
try {
|
||||
|
||||
// Act
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
JsonDiffConversion.print_json_diff(buffer, len, columnName, columnIndex, charsetName);
|
||||
} catch (IllegalArgumentException ex) {
|
||||
|
||||
// Assert side effects
|
||||
Assert.assertNotNull(buffer);
|
||||
Assert.assertEquals(29, buffer.position);
|
||||
Assert.assertEquals(0, buffer.semival);
|
||||
Assert.assertArrayEquals(new byte[] {(byte)2, (byte)2, (byte)2, (byte)2, (byte)2, (byte)2,
|
||||
(byte)2, (byte)2, (byte)2, (byte)2, (byte)2, (byte)2,
|
||||
(byte)2, (byte)2, (byte)2, (byte)2, (byte)2, (byte)2,
|
||||
(byte)2, (byte)2, (byte)2, (byte)2, (byte)2, (byte)2,
|
||||
(byte)2, (byte)2, (byte)2, (byte)2, (byte)3, (byte)2},
|
||||
buffer.buffer);
|
||||
Assert.assertEquals(31, buffer.limit);
|
||||
Assert.assertEquals(0, buffer.origin);
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
// Test written by Diffblue Cover.
|
||||
@Test
|
||||
public void print_json_diffInputNotNullZeroNotNullZeroNotNullOutputIllegalArgumentException2()
|
||||
throws InvocationTargetException {
|
||||
|
||||
// Arrange
|
||||
final LogBuffer buffer = new LogBuffer();
|
||||
buffer.position = 15;
|
||||
buffer.semival = 0;
|
||||
final byte[] myByteArray = {
|
||||
(byte)1, (byte)1, (byte)0, (byte)0, (byte)1, (byte)1, (byte)1, (byte)1, (byte)1, (byte)1,
|
||||
(byte)0, (byte)1, (byte)1, (byte)1, (byte)1, (byte)0, (byte)1, (byte)1, (byte)0, (byte)0,
|
||||
(byte)1, (byte)1, (byte)1, (byte)1, (byte)1, (byte)1, (byte)1, (byte)0, (byte)1, (byte)1};
|
||||
buffer.buffer = myByteArray;
|
||||
buffer.limit = -1_215_751_986;
|
||||
buffer.origin = 1_215_752_002;
|
||||
final long len = 0L;
|
||||
final String columnName = "foo";
|
||||
final int columnIndex = 0;
|
||||
final String charsetName = "foo";
|
||||
try {
|
||||
|
||||
// Act
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
JsonDiffConversion.print_json_diff(buffer, len, columnName, columnIndex, charsetName);
|
||||
} catch (IllegalArgumentException ex) {
|
||||
|
||||
// Assert side effects
|
||||
Assert.assertNotNull(buffer);
|
||||
Assert.assertEquals(16, buffer.position);
|
||||
Assert.assertEquals(0, buffer.semival);
|
||||
Assert.assertArrayEquals(new byte[] {(byte)1, (byte)1, (byte)0, (byte)0, (byte)1, (byte)1,
|
||||
(byte)1, (byte)1, (byte)1, (byte)1, (byte)0, (byte)1,
|
||||
(byte)1, (byte)1, (byte)1, (byte)0, (byte)1, (byte)1,
|
||||
(byte)0, (byte)0, (byte)1, (byte)1, (byte)1, (byte)1,
|
||||
(byte)1, (byte)1, (byte)1, (byte)0, (byte)1, (byte)1},
|
||||
buffer.buffer);
|
||||
Assert.assertEquals(-1_215_751_986, buffer.limit);
|
||||
Assert.assertEquals(1_215_752_002, buffer.origin);
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
// Test written by Diffblue Cover.
|
||||
@Test
|
||||
public void print_json_diffInputNotNullZeroNotNullZeroNotNullOutputIllegalArgumentException3()
|
||||
throws InvocationTargetException {
|
||||
|
||||
// Arrange
|
||||
final LogBuffer buffer = new LogBuffer();
|
||||
buffer.position = 27;
|
||||
buffer.semival = 0;
|
||||
final byte[] myByteArray = {
|
||||
(byte)0, (byte)0, (byte)0, (byte)0, (byte)0, (byte)0, (byte)0, (byte)0, (byte)0, (byte)0,
|
||||
(byte)0, (byte)0, (byte)0, (byte)0, (byte)0, (byte)0, (byte)0, (byte)0, (byte)0, (byte)0,
|
||||
(byte)0, (byte)0, (byte)0, (byte)0, (byte)0, (byte)0, (byte)0, (byte)0, (byte)1, (byte)0};
|
||||
buffer.buffer = myByteArray;
|
||||
buffer.limit = 31;
|
||||
buffer.origin = -1;
|
||||
final long len = 0L;
|
||||
final String columnName = "foo";
|
||||
final int columnIndex = 0;
|
||||
final String charsetName = "foo";
|
||||
try {
|
||||
|
||||
// Act
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
JsonDiffConversion.print_json_diff(buffer, len, columnName, columnIndex, charsetName);
|
||||
} catch (IllegalArgumentException ex) {
|
||||
|
||||
// Assert side effects
|
||||
Assert.assertNotNull(buffer);
|
||||
Assert.assertEquals(29, buffer.position);
|
||||
Assert.assertEquals(0, buffer.semival);
|
||||
Assert.assertArrayEquals(new byte[] {(byte)0, (byte)0, (byte)0, (byte)0, (byte)0, (byte)0,
|
||||
(byte)0, (byte)0, (byte)0, (byte)0, (byte)0, (byte)0,
|
||||
(byte)0, (byte)0, (byte)0, (byte)0, (byte)0, (byte)0,
|
||||
(byte)0, (byte)0, (byte)0, (byte)0, (byte)0, (byte)0,
|
||||
(byte)0, (byte)0, (byte)0, (byte)0, (byte)1, (byte)0},
|
||||
buffer.buffer);
|
||||
Assert.assertEquals(31, buffer.limit);
|
||||
Assert.assertEquals(-1, buffer.origin);
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
// Test written by Diffblue Cover.
|
||||
@Test
|
||||
public void print_json_diffInputNotNullZeroNotNullZeroNotNullOutputNotNull() {
|
||||
|
||||
// Arrange
|
||||
final LogBuffer buffer = new LogBuffer();
|
||||
final long len = 0L;
|
||||
final String columnName = ",";
|
||||
final int columnIndex = 0;
|
||||
final String charsetName = "1a 2b 3c";
|
||||
|
||||
// Act
|
||||
final StringBuilder actual =
|
||||
JsonDiffConversion.print_json_diff(buffer, len, columnName, columnIndex, charsetName);
|
||||
|
||||
// Assert result
|
||||
Assert.assertNotNull(actual);
|
||||
Assert.assertEquals(",", actual.toString());
|
||||
}
|
||||
}
|
||||
@@ -1,312 +0,0 @@
|
||||
package com.taobao.tddl.dbsync.binlog;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.BigInteger;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
public class LogBufferTest extends TestCase {
|
||||
|
||||
public static final int LOOP = 10000;
|
||||
|
||||
public void testSigned() {
|
||||
byte[] array = { 0, 0, 0, (byte) 0xff };
|
||||
|
||||
LogBuffer buffer = new LogBuffer(array, 0, array.length);
|
||||
|
||||
System.out.println(buffer.getInt32(0));
|
||||
System.out.println(buffer.getUint32(0));
|
||||
|
||||
System.out.println(buffer.getInt24(1));
|
||||
System.out.println(buffer.getUint24(1));
|
||||
}
|
||||
|
||||
public void testBigInteger() {
|
||||
byte[] array = { (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
|
||||
(byte) 0xff };
|
||||
|
||||
LogBuffer buffer = new LogBuffer(array, 0, array.length);
|
||||
|
||||
long tt1 = 0;
|
||||
long l1 = 0;
|
||||
for (int i = 0; i < LOOP; i++) {
|
||||
final long t1 = System.nanoTime();
|
||||
l1 = buffer.getLong64(0);
|
||||
tt1 += System.nanoTime() - t1;
|
||||
}
|
||||
System.out.print(tt1 / LOOP);
|
||||
System.out.print("ns >> ");
|
||||
System.out.println(l1);
|
||||
|
||||
long tt2 = 0;
|
||||
BigInteger l2 = null;
|
||||
for (int i = 0; i < LOOP; i++) {
|
||||
final long t2 = System.nanoTime();
|
||||
l2 = buffer.getUlong64(0);
|
||||
tt2 += System.nanoTime() - t2;
|
||||
}
|
||||
System.out.print(tt2 / LOOP);
|
||||
System.out.print("ns >> ");
|
||||
System.out.println(l2);
|
||||
}
|
||||
|
||||
/* Reads big-endian integer from no more than 4 bytes */
|
||||
private static int convertNBytesToInt(byte[] buffer, int offset, int length) {
|
||||
int ret = 0;
|
||||
for (int i = offset; i < (offset + length); i++) {
|
||||
ret = (ret << 8) | (0xff & buffer[i]);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
private static int convert4BytesToInt(byte[] buffer, int offset) {
|
||||
int value;
|
||||
value = (0xff & buffer[offset + 3]);
|
||||
value += (0xff & buffer[offset + 2]) << 8;
|
||||
value += (0xff & buffer[offset + 1]) << 16;
|
||||
value += (0xff & buffer[offset]) << 24;
|
||||
return value;
|
||||
}
|
||||
|
||||
public static short convert1ByteToShort(byte[] buffer, int offset) {
|
||||
short value;
|
||||
value = (short) buffer[offset + 0];
|
||||
return value;
|
||||
}
|
||||
|
||||
public static short convert2bytesToShort(byte[] buffer, int offset) {
|
||||
short value;
|
||||
value = (short) (buffer[offset + 0] << 8);
|
||||
value += (short) (buffer[offset + 1] & 0xff);
|
||||
return value;
|
||||
}
|
||||
|
||||
public static final BigDecimal extractDecimal(byte[] buffer, int precision, int scale) {
|
||||
//
|
||||
// Decimal representation in binlog seems to be as follows:
|
||||
// 1 byte - 'precision'
|
||||
// 1 byte - 'scale'
|
||||
// remaining n bytes - integer such that value = n / (10^scale)
|
||||
// Integer is represented as follows:
|
||||
// 1st bit - sign such that set == +, unset == -
|
||||
// every 4 bytes represent 9 digits in big-endian order, so that if
|
||||
// you print the values of these quads as big-endian integers one after
|
||||
// another, you get the whole number string representation in decimal.
|
||||
// What remains is to put a sign and a decimal dot.
|
||||
// 13 0a 80 00 00 05 1b 38 b0 60 00 means:
|
||||
// 0x13 - precision = 19
|
||||
// 0x0a - scale = 10
|
||||
// 0x80 - positive
|
||||
// 0x00000005 0x1b38b060 0x00
|
||||
// 5 456700000 0
|
||||
// 54567000000 / 10^{10} = 5.4567
|
||||
//
|
||||
// int_size below shows how long is integer part
|
||||
//
|
||||
// offset = offset + 2; // offset of the number part
|
||||
//
|
||||
int intg = precision - scale;
|
||||
int intg0 = intg / LogBuffer.DIG_PER_INT32;
|
||||
int frac0 = scale / LogBuffer.DIG_PER_INT32;
|
||||
int intg0x = intg - intg0 * LogBuffer.DIG_PER_INT32;
|
||||
int frac0x = scale - frac0 * LogBuffer.DIG_PER_INT32;
|
||||
|
||||
int offset = 0;
|
||||
|
||||
int sign = (buffer[offset] & 0x80) == 0x80 ? 1 : -1;
|
||||
|
||||
// how many bytes are used to represent given amount of digits?
|
||||
int integerSize = intg0 * LogBuffer.SIZE_OF_INT32 + LogBuffer.dig2bytes[intg0x];
|
||||
int decimalSize = frac0 * LogBuffer.SIZE_OF_INT32 + LogBuffer.dig2bytes[frac0x];
|
||||
|
||||
int bin_size = integerSize + decimalSize; // total bytes
|
||||
byte[] d_copy = new byte[bin_size];
|
||||
|
||||
if (bin_size > buffer.length) {
|
||||
throw new ArrayIndexOutOfBoundsException("Calculated bin_size: " + bin_size + ", available bytes: "
|
||||
+ buffer.length);
|
||||
}
|
||||
|
||||
// Invert first bit
|
||||
d_copy[0] = buffer[0];
|
||||
d_copy[0] ^= 0x80;
|
||||
if (sign == -1) {
|
||||
// Invert every byte
|
||||
d_copy[0] ^= 0xFF;
|
||||
}
|
||||
|
||||
for (int i = 1; i < bin_size; i++) {
|
||||
d_copy[i] = buffer[i];
|
||||
if (sign == -1) {
|
||||
// Invert every byte
|
||||
d_copy[i] ^= 0xFF;
|
||||
}
|
||||
}
|
||||
|
||||
// Integer part
|
||||
offset = LogBuffer.dig2bytes[intg0x];
|
||||
|
||||
BigDecimal intPart = new BigDecimal(0);
|
||||
|
||||
if (offset > 0) intPart = BigDecimal.valueOf(convertNBytesToInt(d_copy, 0, offset));
|
||||
|
||||
while (offset < integerSize) {
|
||||
intPart = intPart.movePointRight(LogBuffer.DIG_PER_DEC1).add(BigDecimal.valueOf(convert4BytesToInt(d_copy,
|
||||
offset)));
|
||||
offset += 4;
|
||||
}
|
||||
|
||||
// Decimal part
|
||||
BigDecimal fracPart = new BigDecimal(0);
|
||||
int shift = 0;
|
||||
for (int i = 0; i < frac0; i++) {
|
||||
shift += LogBuffer.DIG_PER_DEC1;
|
||||
fracPart = fracPart.add(BigDecimal.valueOf(convert4BytesToInt(d_copy, offset)).movePointLeft(shift));
|
||||
offset += 4;
|
||||
}
|
||||
|
||||
if (LogBuffer.dig2bytes[frac0x] > 0) {
|
||||
fracPart = fracPart.add(BigDecimal.valueOf(convertNBytesToInt(d_copy, offset, LogBuffer.dig2bytes[frac0x]))
|
||||
.movePointLeft(shift + frac0x));
|
||||
}
|
||||
|
||||
return BigDecimal.valueOf(sign).multiply(intPart.add(fracPart));
|
||||
}
|
||||
|
||||
public static final byte[] array1 = { (byte) 0x80, 0x00, 0x00, 0x05, 0x1b, 0x38, (byte) 0xb0, 0x60, 0x00 };
|
||||
|
||||
public static final byte[] array2 = { (byte) 0x7f, (byte) 0xff, (byte) 0xff, (byte) 0xfb, (byte) 0xe4, (byte) 0xc7,
|
||||
(byte) 0x4f, (byte) 0xa0, (byte) 0xff };
|
||||
|
||||
public static final byte[] array3 = { -128, 0, 6, 20, 113, 56, 6, 26, -123 };
|
||||
|
||||
public static final byte[] array4 = { -128, 7, 0, 0, 0, 1, 0, 0, 3 };
|
||||
|
||||
public static final byte[] array5 = { -128, 0, 0, 0, 0, 1, 1, -122, -96, -108 };
|
||||
|
||||
public void testBigDecimal() throws InterruptedException {
|
||||
do {
|
||||
System.out.println("old extract decimal: ");
|
||||
|
||||
long tt1 = 0;
|
||||
BigDecimal bd1 = null;
|
||||
for (int i = 0; i < LOOP; i++) {
|
||||
final long t1 = System.nanoTime();
|
||||
bd1 = extractDecimal(array2, 19, 10);
|
||||
tt1 += System.nanoTime() - t1;
|
||||
}
|
||||
System.out.print(tt1 / LOOP);
|
||||
System.out.print("ns >> ");
|
||||
System.out.println(bd1);
|
||||
|
||||
long tt2 = 0;
|
||||
BigDecimal bd2 = null;
|
||||
for (int i = 0; i < LOOP; i++) {
|
||||
final long t2 = System.nanoTime();
|
||||
bd2 = extractDecimal(array1, 19, 10);
|
||||
tt2 += System.nanoTime() - t2;
|
||||
}
|
||||
System.out.print(tt2 / LOOP);
|
||||
System.out.print("ns >> ");
|
||||
System.out.println(bd2);
|
||||
|
||||
long tt3 = 0;
|
||||
BigDecimal bd3 = null;
|
||||
for (int i = 0; i < LOOP; i++) {
|
||||
final long t3 = System.nanoTime();
|
||||
bd3 = extractDecimal(array3, 18, 6);
|
||||
tt3 += System.nanoTime() - t3;
|
||||
}
|
||||
System.out.print(tt3 / LOOP);
|
||||
System.out.print("ns >> ");
|
||||
System.out.println(bd3);
|
||||
|
||||
long tt4 = 0;
|
||||
BigDecimal bd4 = null;
|
||||
for (int i = 0; i < LOOP; i++) {
|
||||
final long t4 = System.nanoTime();
|
||||
bd4 = extractDecimal(array4, 18, 6);
|
||||
tt4 += System.nanoTime() - t4;
|
||||
}
|
||||
System.out.print(tt4 / LOOP);
|
||||
System.out.print("ns >> ");
|
||||
System.out.println(bd4);
|
||||
|
||||
long tt5 = 0;
|
||||
BigDecimal bd5 = null;
|
||||
for (int i = 0; i < LOOP; i++) {
|
||||
final long t5 = System.nanoTime();
|
||||
bd5 = extractDecimal(array5, 18, 6);
|
||||
tt5 += System.nanoTime() - t5;
|
||||
}
|
||||
System.out.print(tt5 / LOOP);
|
||||
System.out.print("ns >> ");
|
||||
System.out.println(bd5);
|
||||
} while (false);
|
||||
|
||||
do {
|
||||
System.out.println("new extract decimal: ");
|
||||
|
||||
LogBuffer buffer1 = new LogBuffer(array2, 0, array2.length);
|
||||
LogBuffer buffer2 = new LogBuffer(array1, 0, array1.length);
|
||||
LogBuffer buffer3 = new LogBuffer(array3, 0, array3.length);
|
||||
LogBuffer buffer4 = new LogBuffer(array4, 0, array4.length);
|
||||
LogBuffer buffer5 = new LogBuffer(array5, 0, array5.length);
|
||||
|
||||
long tt1 = 0;
|
||||
BigDecimal bd1 = null;
|
||||
for (int i = 0; i < LOOP; i++) {
|
||||
final long t1 = System.nanoTime();
|
||||
bd1 = buffer1.getDecimal(0, 19, 10);
|
||||
tt1 += System.nanoTime() - t1;
|
||||
}
|
||||
System.out.print(tt1 / LOOP);
|
||||
System.out.print("ns >> ");
|
||||
System.out.println(bd1);
|
||||
|
||||
long tt2 = 0;
|
||||
BigDecimal bd2 = null;
|
||||
for (int i = 0; i < LOOP; i++) {
|
||||
final long t2 = System.nanoTime();
|
||||
bd2 = buffer2.getDecimal(0, 19, 10);
|
||||
tt2 += System.nanoTime() - t2;
|
||||
}
|
||||
System.out.print(tt2 / LOOP);
|
||||
System.out.print("ns >> ");
|
||||
System.out.println(bd2);
|
||||
|
||||
long tt3 = 0;
|
||||
BigDecimal bd3 = null;
|
||||
for (int i = 0; i < LOOP; i++) {
|
||||
final long t3 = System.nanoTime();
|
||||
bd3 = buffer3.getDecimal(0, 18, 6);
|
||||
tt3 += System.nanoTime() - t3;
|
||||
}
|
||||
System.out.print(tt3 / LOOP);
|
||||
System.out.print("ns >> ");
|
||||
System.out.println(bd3);
|
||||
|
||||
long tt4 = 0;
|
||||
BigDecimal bd4 = null;
|
||||
for (int i = 0; i < LOOP; i++) {
|
||||
final long t4 = System.nanoTime();
|
||||
bd4 = buffer4.getDecimal(0, 18, 6);
|
||||
tt4 += System.nanoTime() - t4;
|
||||
}
|
||||
System.out.print(tt4 / LOOP);
|
||||
System.out.print("ns >> ");
|
||||
System.out.println(bd4);
|
||||
|
||||
long tt5 = 0;
|
||||
BigDecimal bd5 = null;
|
||||
for (int i = 0; i < LOOP; i++) {
|
||||
final long t5 = System.nanoTime();
|
||||
bd5 = buffer5.getDecimal(0, 18, 6);
|
||||
tt5 += System.nanoTime() - t5;
|
||||
}
|
||||
System.out.print(tt5 / LOOP);
|
||||
System.out.print("ns >> ");
|
||||
System.out.println(bd5);
|
||||
} while (false);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,534 @@
|
||||
package com.taobao.tddl.dbsync.binlog;
|
||||
|
||||
import com.taobao.tddl.dbsync.binlog.LogEvent;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
import org.junit.rules.Timeout;
|
||||
|
||||
public class LogEventTest {
|
||||
|
||||
@Rule public final ExpectedException thrown = ExpectedException.none();
|
||||
|
||||
@Rule public final Timeout globalTimeout = new Timeout(10000);
|
||||
|
||||
/* testedClasses: LogEvent */
|
||||
// Test written by Diffblue Cover.
|
||||
@Test
|
||||
public void getTypeNameInputPositiveOutputNotNull() {
|
||||
|
||||
// Arrange
|
||||
final int type = 8;
|
||||
|
||||
// Act
|
||||
final String actual = LogEvent.getTypeName(type);
|
||||
|
||||
// Assert result
|
||||
Assert.assertEquals("Create_file", actual);
|
||||
}
|
||||
|
||||
// Test written by Diffblue Cover.
|
||||
@Test
|
||||
public void getTypeNameInputPositiveOutputNotNull2() {
|
||||
|
||||
// Arrange
|
||||
final int type = 12;
|
||||
|
||||
// Act
|
||||
final String actual = LogEvent.getTypeName(type);
|
||||
|
||||
// Assert result
|
||||
Assert.assertEquals("New_load", actual);
|
||||
}
|
||||
|
||||
// Test written by Diffblue Cover.
|
||||
@Test
|
||||
public void getTypeNameInputPositiveOutputNotNull3() {
|
||||
|
||||
// Arrange
|
||||
final int type = 39;
|
||||
|
||||
// Act
|
||||
final String actual = LogEvent.getTypeName(type);
|
||||
|
||||
// Assert result
|
||||
Assert.assertEquals("Update_rows_partial", actual);
|
||||
}
|
||||
|
||||
// Test written by Diffblue Cover.
|
||||
@Test
|
||||
public void getTypeNameInputPositiveOutputNotNull4() {
|
||||
|
||||
// Arrange
|
||||
final int type = 36;
|
||||
|
||||
// Act
|
||||
final String actual = LogEvent.getTypeName(type);
|
||||
|
||||
// Assert result
|
||||
Assert.assertEquals("Unknown", actual);
|
||||
}
|
||||
|
||||
// Test written by Diffblue Cover.
|
||||
@Test
|
||||
public void getTypeNameInputPositiveOutputNotNull5() {
|
||||
|
||||
// Arrange
|
||||
final int type = 7;
|
||||
|
||||
// Act
|
||||
final String actual = LogEvent.getTypeName(type);
|
||||
|
||||
// Assert result
|
||||
Assert.assertEquals("Slave", actual);
|
||||
}
|
||||
|
||||
// Test written by Diffblue Cover.
|
||||
@Test
|
||||
public void getTypeNameInputPositiveOutputNotNull6() {
|
||||
|
||||
// Arrange
|
||||
final int type = 6;
|
||||
|
||||
// Act
|
||||
final String actual = LogEvent.getTypeName(type);
|
||||
|
||||
// Assert result
|
||||
Assert.assertEquals("Load", actual);
|
||||
}
|
||||
|
||||
// Test written by Diffblue Cover.
|
||||
@Test
|
||||
public void getTypeNameInputPositiveOutputNotNull7() {
|
||||
|
||||
// Arrange
|
||||
final int type = 10;
|
||||
|
||||
// Act
|
||||
final String actual = LogEvent.getTypeName(type);
|
||||
|
||||
// Assert result
|
||||
Assert.assertEquals("Exec_load", actual);
|
||||
}
|
||||
|
||||
// Test written by Diffblue Cover.
|
||||
@Test
|
||||
public void getTypeNameInputPositiveOutputNotNull8() {
|
||||
|
||||
// Arrange
|
||||
final int type = 5;
|
||||
|
||||
// Act
|
||||
final String actual = LogEvent.getTypeName(type);
|
||||
|
||||
// Assert result
|
||||
Assert.assertEquals("Intvar", actual);
|
||||
}
|
||||
|
||||
// Test written by Diffblue Cover.
|
||||
@Test
|
||||
public void getTypeNameInputPositiveOutputNotNull9() {
|
||||
|
||||
// Arrange
|
||||
final int type = 11;
|
||||
|
||||
// Act
|
||||
final String actual = LogEvent.getTypeName(type);
|
||||
|
||||
// Assert result
|
||||
Assert.assertEquals("Delete_file", actual);
|
||||
}
|
||||
|
||||
// Test written by Diffblue Cover.
|
||||
@Test
|
||||
public void getTypeNameInputPositiveOutputNotNull10() {
|
||||
|
||||
// Arrange
|
||||
final int type = 4;
|
||||
|
||||
// Act
|
||||
final String actual = LogEvent.getTypeName(type);
|
||||
|
||||
// Assert result
|
||||
Assert.assertEquals("Rotate", actual);
|
||||
}
|
||||
|
||||
// Test written by Diffblue Cover.
|
||||
@Test
|
||||
public void getTypeNameInputPositiveOutputNotNull11() {
|
||||
|
||||
// Arrange
|
||||
final int type = 13;
|
||||
|
||||
// Act
|
||||
final String actual = LogEvent.getTypeName(type);
|
||||
|
||||
// Assert result
|
||||
Assert.assertEquals("RAND", actual);
|
||||
}
|
||||
|
||||
// Test written by Diffblue Cover.
|
||||
@Test
|
||||
public void getTypeNameInputPositiveOutputNotNull12() {
|
||||
|
||||
// Arrange
|
||||
final int type = 34;
|
||||
|
||||
// Act
|
||||
final String actual = LogEvent.getTypeName(type);
|
||||
|
||||
// Assert result
|
||||
Assert.assertEquals("Anonymous_Gtid", actual);
|
||||
}
|
||||
|
||||
// Test written by Diffblue Cover.
|
||||
@Test
|
||||
public void getTypeNameInputPositiveOutputNotNull13() {
|
||||
|
||||
// Arrange
|
||||
final int type = 15;
|
||||
|
||||
// Act
|
||||
final String actual = LogEvent.getTypeName(type);
|
||||
|
||||
// Assert result
|
||||
Assert.assertEquals("Format_desc", actual);
|
||||
}
|
||||
|
||||
// Test written by Diffblue Cover.
|
||||
@Test
|
||||
public void getTypeNameInputPositiveOutputNotNull14() {
|
||||
|
||||
// Arrange
|
||||
final int type = 32;
|
||||
|
||||
// Act
|
||||
final String actual = LogEvent.getTypeName(type);
|
||||
|
||||
// Assert result
|
||||
Assert.assertEquals("Delete_rows", actual);
|
||||
}
|
||||
|
||||
// Test written by Diffblue Cover.
|
||||
@Test
|
||||
public void getTypeNameInputPositiveOutputNotNull15() {
|
||||
|
||||
// Arrange
|
||||
final int type = 16;
|
||||
|
||||
// Act
|
||||
final String actual = LogEvent.getTypeName(type);
|
||||
|
||||
// Assert result
|
||||
Assert.assertEquals("Xid", actual);
|
||||
}
|
||||
|
||||
// Test written by Diffblue Cover.
|
||||
@Test
|
||||
public void getTypeNameInputPositiveOutputNotNull16() {
|
||||
|
||||
// Arrange
|
||||
final int type = 30;
|
||||
|
||||
// Act
|
||||
final String actual = LogEvent.getTypeName(type);
|
||||
|
||||
// Assert result
|
||||
Assert.assertEquals("Write_rows", actual);
|
||||
}
|
||||
|
||||
// Test written by Diffblue Cover.
|
||||
@Test
|
||||
public void getTypeNameInputPositiveOutputNotNull17() {
|
||||
|
||||
// Arrange
|
||||
final int type = 18;
|
||||
|
||||
// Act
|
||||
final String actual = LogEvent.getTypeName(type);
|
||||
|
||||
// Assert result
|
||||
Assert.assertEquals("Execute_load_query", actual);
|
||||
}
|
||||
|
||||
// Test written by Diffblue Cover.
|
||||
@Test
|
||||
public void getTypeNameInputPositiveOutputNotNull18() {
|
||||
|
||||
// Arrange
|
||||
final int type = 29;
|
||||
|
||||
// Act
|
||||
final String actual = LogEvent.getTypeName(type);
|
||||
|
||||
// Assert result
|
||||
Assert.assertEquals("Rows_query", actual);
|
||||
}
|
||||
|
||||
// Test written by Diffblue Cover.
|
||||
@Test
|
||||
public void getTypeNameInputPositiveOutputNotNull19() {
|
||||
|
||||
// Arrange
|
||||
final int type = 19;
|
||||
|
||||
// Act
|
||||
final String actual = LogEvent.getTypeName(type);
|
||||
|
||||
// Assert result
|
||||
Assert.assertEquals("Table_map", actual);
|
||||
}
|
||||
|
||||
// Test written by Diffblue Cover.
|
||||
@Test
|
||||
public void getTypeNameInputPositiveOutputNotNull20() {
|
||||
|
||||
// Arrange
|
||||
final int type = 28;
|
||||
|
||||
// Act
|
||||
final String actual = LogEvent.getTypeName(type);
|
||||
|
||||
// Assert result
|
||||
Assert.assertEquals("Ignorable", actual);
|
||||
}
|
||||
|
||||
// Test written by Diffblue Cover.
|
||||
@Test
|
||||
public void getTypeNameInputPositiveOutputNotNull21() {
|
||||
|
||||
// Arrange
|
||||
final int type = 33;
|
||||
|
||||
// Act
|
||||
final String actual = LogEvent.getTypeName(type);
|
||||
|
||||
// Assert result
|
||||
Assert.assertEquals("Gtid", actual);
|
||||
}
|
||||
|
||||
// Test written by Diffblue Cover.
|
||||
@Test
|
||||
public void getTypeNameInputPositiveOutputNotNull22() {
|
||||
|
||||
// Arrange
|
||||
final int type = 27;
|
||||
|
||||
// Act
|
||||
final String actual = LogEvent.getTypeName(type);
|
||||
|
||||
// Assert result
|
||||
Assert.assertEquals("Heartbeat", actual);
|
||||
}
|
||||
|
||||
// Test written by Diffblue Cover.
|
||||
@Test
|
||||
public void getTypeNameInputPositiveOutputNotNull23() {
|
||||
|
||||
// Arrange
|
||||
final int type = 26;
|
||||
|
||||
// Act
|
||||
final String actual = LogEvent.getTypeName(type);
|
||||
|
||||
// Assert result
|
||||
Assert.assertEquals("Incident", actual);
|
||||
}
|
||||
|
||||
// Test written by Diffblue Cover.
|
||||
@Test
|
||||
public void getTypeNameInputPositiveOutputNotNull24() {
|
||||
|
||||
// Arrange
|
||||
final int type = 31;
|
||||
|
||||
// Act
|
||||
final String actual = LogEvent.getTypeName(type);
|
||||
|
||||
// Assert result
|
||||
Assert.assertEquals("Update_rows", actual);
|
||||
}
|
||||
|
||||
// Test written by Diffblue Cover.
|
||||
@Test
|
||||
public void getTypeNameInputPositiveOutputNotNull25() {
|
||||
|
||||
// Arrange
|
||||
final int type = 25;
|
||||
|
||||
// Act
|
||||
final String actual = LogEvent.getTypeName(type);
|
||||
|
||||
// Assert result
|
||||
Assert.assertEquals("Delete_rows_v1", actual);
|
||||
}
|
||||
|
||||
// Test written by Diffblue Cover.
|
||||
@Test
|
||||
public void getTypeNameInputPositiveOutputNotNull26() {
|
||||
|
||||
// Arrange
|
||||
final int type = 24;
|
||||
|
||||
// Act
|
||||
final String actual = LogEvent.getTypeName(type);
|
||||
|
||||
// Assert result
|
||||
Assert.assertEquals("Update_rows_v1", actual);
|
||||
}
|
||||
|
||||
// Test written by Diffblue Cover.
|
||||
@Test
|
||||
public void getTypeNameInputPositiveOutputNotNull27() {
|
||||
|
||||
// Arrange
|
||||
final int type = 23;
|
||||
|
||||
// Act
|
||||
final String actual = LogEvent.getTypeName(type);
|
||||
|
||||
// Assert result
|
||||
Assert.assertEquals("Write_rows_v1", actual);
|
||||
}
|
||||
|
||||
// Test written by Diffblue Cover.
|
||||
@Test
|
||||
public void getTypeNameInputPositiveOutputNotNull28() {
|
||||
|
||||
// Arrange
|
||||
final int type = 35;
|
||||
|
||||
// Act
|
||||
final String actual = LogEvent.getTypeName(type);
|
||||
|
||||
// Assert result
|
||||
Assert.assertEquals("Previous_gtids", actual);
|
||||
}
|
||||
|
||||
// Test written by Diffblue Cover.
|
||||
@Test
|
||||
public void getTypeNameInputPositiveOutputNotNull29() {
|
||||
|
||||
// Arrange
|
||||
final int type = 22;
|
||||
|
||||
// Act
|
||||
final String actual = LogEvent.getTypeName(type);
|
||||
|
||||
// Assert result
|
||||
Assert.assertEquals("Delete_rows_event_old", actual);
|
||||
}
|
||||
|
||||
// Test written by Diffblue Cover.
|
||||
@Test
|
||||
public void getTypeNameInputPositiveOutputNotNull30() {
|
||||
|
||||
// Arrange
|
||||
final int type = 21;
|
||||
|
||||
// Act
|
||||
final String actual = LogEvent.getTypeName(type);
|
||||
|
||||
// Assert result
|
||||
Assert.assertEquals("Update_rows_event_old", actual);
|
||||
}
|
||||
|
||||
// Test written by Diffblue Cover.
|
||||
@Test
|
||||
public void getTypeNameInputPositiveOutputNotNull31() {
|
||||
|
||||
// Arrange
|
||||
final int type = 20;
|
||||
|
||||
// Act
|
||||
final String actual = LogEvent.getTypeName(type);
|
||||
|
||||
// Assert result
|
||||
Assert.assertEquals("Write_rows_event_old", actual);
|
||||
}
|
||||
|
||||
// Test written by Diffblue Cover.
|
||||
@Test
|
||||
public void getTypeNameInputPositiveOutputNotNull32() {
|
||||
|
||||
// Arrange
|
||||
final int type = 17;
|
||||
|
||||
// Act
|
||||
final String actual = LogEvent.getTypeName(type);
|
||||
|
||||
// Assert result
|
||||
Assert.assertEquals("Begin_load_query", actual);
|
||||
}
|
||||
|
||||
// Test written by Diffblue Cover.
|
||||
@Test
|
||||
public void getTypeNameInputPositiveOutputNotNull33() {
|
||||
|
||||
// Arrange
|
||||
final int type = 14;
|
||||
|
||||
// Act
|
||||
final String actual = LogEvent.getTypeName(type);
|
||||
|
||||
// Assert result
|
||||
Assert.assertEquals("User var", actual);
|
||||
}
|
||||
|
||||
// Test written by Diffblue Cover.
|
||||
@Test
|
||||
public void getTypeNameInputPositiveOutputNotNull34() {
|
||||
|
||||
// Arrange
|
||||
final int type = 9;
|
||||
|
||||
// Act
|
||||
final String actual = LogEvent.getTypeName(type);
|
||||
|
||||
// Assert result
|
||||
Assert.assertEquals("Append_block", actual);
|
||||
}
|
||||
|
||||
// Test written by Diffblue Cover.
|
||||
@Test
|
||||
public void getTypeNameInputPositiveOutputNotNull35() {
|
||||
|
||||
// Arrange
|
||||
final int type = 2;
|
||||
|
||||
// Act
|
||||
final String actual = LogEvent.getTypeName(type);
|
||||
|
||||
// Assert result
|
||||
Assert.assertEquals("Query", actual);
|
||||
}
|
||||
|
||||
// Test written by Diffblue Cover.
|
||||
@Test
|
||||
public void getTypeNameInputPositiveOutputNotNull36() {
|
||||
|
||||
// Arrange
|
||||
final int type = 3;
|
||||
|
||||
// Act
|
||||
final String actual = LogEvent.getTypeName(type);
|
||||
|
||||
// Assert result
|
||||
Assert.assertEquals("Stop", actual);
|
||||
}
|
||||
|
||||
// Test written by Diffblue Cover.
|
||||
@Test
|
||||
public void getTypeNameInputPositiveOutputNotNull37() {
|
||||
|
||||
// Arrange
|
||||
final int type = 1;
|
||||
|
||||
// Act
|
||||
final String actual = LogEvent.getTypeName(type);
|
||||
|
||||
// Assert result
|
||||
Assert.assertEquals("Start_v3", actual);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,231 @@
|
||||
package com.taobao.tddl.dbsync.binlog.event;
|
||||
|
||||
import com.taobao.tddl.dbsync.binlog.event.LogHeader;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
import org.junit.rules.Timeout;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public class LogHeaderTest {
|
||||
|
||||
@Rule public final ExpectedException thrown = ExpectedException.none();
|
||||
|
||||
@Rule public final Timeout globalTimeout = new Timeout(10000);
|
||||
|
||||
/* testedClasses: LogHeader */
|
||||
// Test written by Diffblue Cover.
|
||||
|
||||
@Test
|
||||
public void constructorInputZeroOutputVoid() {
|
||||
|
||||
// Arrange
|
||||
final int type = 0;
|
||||
|
||||
// Act, creating object to test constructor
|
||||
final LogHeader objectUnderTest = new LogHeader(type);
|
||||
|
||||
// Assert side effects
|
||||
final HashMap<String, String> hashMap = new HashMap<String, String>();
|
||||
Assert.assertEquals(hashMap, objectUnderTest.gtidMap);
|
||||
}
|
||||
|
||||
// Test written by Diffblue Cover.
|
||||
@Test
|
||||
public void getChecksumAlgOutputZero() {
|
||||
|
||||
// Arrange
|
||||
final LogHeader objectUnderTest = new LogHeader(0);
|
||||
|
||||
// Act
|
||||
final int actual = objectUnderTest.getChecksumAlg();
|
||||
|
||||
// Assert result
|
||||
Assert.assertEquals(0, actual);
|
||||
}
|
||||
|
||||
// Test written by Diffblue Cover.
|
||||
@Test
|
||||
public void getCrcOutputZero() {
|
||||
|
||||
// Arrange
|
||||
final LogHeader objectUnderTest = new LogHeader(0);
|
||||
|
||||
// Act
|
||||
final long actual = objectUnderTest.getCrc();
|
||||
|
||||
// Assert result
|
||||
Assert.assertEquals(0L, actual);
|
||||
}
|
||||
|
||||
// Test written by Diffblue Cover.
|
||||
@Test
|
||||
public void getCurrentGtidLastCommitOutputNull() {
|
||||
|
||||
// Arrange
|
||||
final LogHeader objectUnderTest = new LogHeader(0);
|
||||
|
||||
// Act
|
||||
final String actual = objectUnderTest.getCurrentGtidLastCommit();
|
||||
|
||||
// Assert result
|
||||
Assert.assertNull(actual);
|
||||
}
|
||||
|
||||
// Test written by Diffblue Cover.
|
||||
@Test
|
||||
public void getCurrentGtidOutputNull() {
|
||||
|
||||
// Arrange
|
||||
final LogHeader objectUnderTest = new LogHeader(0);
|
||||
|
||||
// Act
|
||||
final String actual = objectUnderTest.getCurrentGtid();
|
||||
|
||||
// Assert result
|
||||
Assert.assertNull(actual);
|
||||
}
|
||||
|
||||
// Test written by Diffblue Cover.
|
||||
@Test
|
||||
public void getCurrentGtidSnOutputNull() {
|
||||
|
||||
// Arrange
|
||||
final LogHeader objectUnderTest = new LogHeader(0);
|
||||
|
||||
// Act
|
||||
final String actual = objectUnderTest.getCurrentGtidSn();
|
||||
|
||||
// Assert result
|
||||
Assert.assertNull(actual);
|
||||
}
|
||||
|
||||
// Test written by Diffblue Cover.
|
||||
@Test
|
||||
public void getEventLenOutputZero() {
|
||||
|
||||
// Arrange
|
||||
final LogHeader objectUnderTest = new LogHeader(0);
|
||||
|
||||
// Act
|
||||
final int actual = objectUnderTest.getEventLen();
|
||||
|
||||
// Assert result
|
||||
Assert.assertEquals(0, actual);
|
||||
}
|
||||
|
||||
// Test written by Diffblue Cover.
|
||||
@Test
|
||||
public void getFlagsOutputZero() {
|
||||
|
||||
// Arrange
|
||||
final LogHeader objectUnderTest = new LogHeader(0);
|
||||
|
||||
// Act
|
||||
final int actual = objectUnderTest.getFlags();
|
||||
|
||||
// Assert result
|
||||
Assert.assertEquals(0, actual);
|
||||
}
|
||||
|
||||
// Test written by Diffblue Cover.
|
||||
@Test
|
||||
public void getGtidSetStrOutputNull() {
|
||||
|
||||
// Arrange
|
||||
final LogHeader objectUnderTest = new LogHeader(0);
|
||||
|
||||
// Act
|
||||
final String actual = objectUnderTest.getGtidSetStr();
|
||||
|
||||
// Assert result
|
||||
Assert.assertNull(actual);
|
||||
}
|
||||
|
||||
// Test written by Diffblue Cover.
|
||||
@Test
|
||||
public void getLogFileNameOutputNull() {
|
||||
|
||||
// Arrange
|
||||
final LogHeader objectUnderTest = new LogHeader(0);
|
||||
|
||||
// Act
|
||||
final String actual = objectUnderTest.getLogFileName();
|
||||
|
||||
// Assert result
|
||||
Assert.assertNull(actual);
|
||||
}
|
||||
|
||||
// Test written by Diffblue Cover.
|
||||
@Test
|
||||
public void getLogPosOutputZero() {
|
||||
|
||||
// Arrange
|
||||
final LogHeader objectUnderTest = new LogHeader(0);
|
||||
|
||||
// Act
|
||||
final long actual = objectUnderTest.getLogPos();
|
||||
|
||||
// Assert result
|
||||
Assert.assertEquals(0L, actual);
|
||||
}
|
||||
|
||||
// Test written by Diffblue Cover.
|
||||
@Test
|
||||
public void getServerIdOutputZero() {
|
||||
|
||||
// Arrange
|
||||
final LogHeader objectUnderTest = new LogHeader(0);
|
||||
|
||||
// Act
|
||||
final long actual = objectUnderTest.getServerId();
|
||||
|
||||
// Assert result
|
||||
Assert.assertEquals(0L, actual);
|
||||
}
|
||||
|
||||
// Test written by Diffblue Cover.
|
||||
@Test
|
||||
public void getTypeOutputZero() {
|
||||
|
||||
// Arrange
|
||||
final LogHeader objectUnderTest = new LogHeader(0);
|
||||
|
||||
// Act
|
||||
final int actual = objectUnderTest.getType();
|
||||
|
||||
// Assert result
|
||||
Assert.assertEquals(0, actual);
|
||||
}
|
||||
|
||||
// Test written by Diffblue Cover.
|
||||
@Test
|
||||
public void getWhenOutputZero() {
|
||||
|
||||
// Arrange
|
||||
final LogHeader objectUnderTest = new LogHeader(0);
|
||||
|
||||
// Act
|
||||
final long actual = objectUnderTest.getWhen();
|
||||
|
||||
// Assert result
|
||||
Assert.assertEquals(0L, actual);
|
||||
}
|
||||
|
||||
// Test written by Diffblue Cover.
|
||||
@Test
|
||||
public void setLogFileNameInputNotNullOutputVoid() {
|
||||
|
||||
// Arrange
|
||||
final LogHeader objectUnderTest = new LogHeader(0);
|
||||
final String logFileName = "3";
|
||||
|
||||
// Act
|
||||
objectUnderTest.setLogFileName(logFileName);
|
||||
|
||||
// Assert side effects
|
||||
Assert.assertEquals("3", objectUnderTest.getLogFileName());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user