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:
@@ -39,5 +39,35 @@
|
||||
<artifactId>junit</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,59 @@
|
||||
package com.alibaba.otter.canal.parse.driver.mysql.packets.client;
|
||||
|
||||
import com.alibaba.otter.canal.parse.driver.mysql.packets.client.RegisterSlaveCommandPacket;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
import org.junit.rules.Timeout;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Array;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
public class RegisterSlaveCommandPacketTest {
|
||||
|
||||
@Rule public final ExpectedException thrown = ExpectedException.none();
|
||||
|
||||
@Rule public final Timeout globalTimeout = new Timeout(10000);
|
||||
|
||||
/* testedClasses: RegisterSlaveCommandPacket */
|
||||
// Test written by Diffblue Cover.
|
||||
@Test
|
||||
public void toBytesOutput27() throws IOException, InvocationTargetException {
|
||||
|
||||
// Arrange
|
||||
final RegisterSlaveCommandPacket objectUnderTest = new RegisterSlaveCommandPacket();
|
||||
objectUnderTest.serverId = 0L;
|
||||
objectUnderTest.reportPort = 0;
|
||||
objectUnderTest.reportPasswd = "foo";
|
||||
objectUnderTest.reportHost = "foo";
|
||||
objectUnderTest.reportUser = "foo";
|
||||
objectUnderTest.setCommand((byte)0);
|
||||
|
||||
// Act
|
||||
final byte[] actual = objectUnderTest.toBytes();
|
||||
|
||||
// Assert result
|
||||
Assert.assertArrayEquals(
|
||||
new byte[] {(byte)0, (byte)0, (byte)0, (byte)0, (byte)0, (byte)3, (byte)102,
|
||||
(byte)111, (byte)111, (byte)3, (byte)102, (byte)111, (byte)111, (byte)3,
|
||||
(byte)102, (byte)111, (byte)111, (byte)0, (byte)0, (byte)0, (byte)0,
|
||||
(byte)0, (byte)0, (byte)0, (byte)0, (byte)0, (byte)0},
|
||||
actual);
|
||||
}
|
||||
|
||||
// Test written by Diffblue Cover.
|
||||
@Test
|
||||
public void toLHInputZeroOutput4() {
|
||||
|
||||
// Arrange
|
||||
final int n = 0;
|
||||
|
||||
// Act
|
||||
final byte[] actual = RegisterSlaveCommandPacket.toLH(n);
|
||||
|
||||
// Assert result
|
||||
Assert.assertArrayEquals(new byte[] {(byte)0, (byte)0, (byte)0, (byte)0}, actual);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user