Search in sources :

Example 31 with DdlResult

use of com.alibaba.otter.canal.parse.inbound.mysql.ddl.DdlResult in project canal by alibaba.

the class DdlResultTest method cloneOutputNotNull.

/* testedClasses: DdlResult */
// Test written by Diffblue Cover.
@Test
public void cloneOutputNotNull() {
    // Arrange
    final DdlResult objectUnderTest = new DdlResult();
    // Act
    final DdlResult actual = objectUnderTest.clone();
    // Assert result
    Assert.assertNotNull(actual);
    Assert.assertNull(actual.getSchemaName());
    Assert.assertNull(actual.getType());
    Assert.assertNull(actual.getOriSchemaName());
    Assert.assertNull(actual.getTableName());
    Assert.assertNull(actual.getRenameTableResult());
    Assert.assertNull(actual.getOriTableName());
}
Also used : DdlResult(com.alibaba.otter.canal.parse.inbound.mysql.ddl.DdlResult) Test(org.junit.Test)

Example 32 with DdlResult

use of com.alibaba.otter.canal.parse.inbound.mysql.ddl.DdlResult in project canal by alibaba.

the class DruidDdlParserTest method testDrop.

@Test
public void testDrop() {
    String queryString = "DROP TABLE retl_mark";
    DdlResult result = DruidDdlParser.parse(queryString, "retl").get(0);
    Assert.assertNotNull(result);
    Assert.assertEquals("retl", result.getSchemaName());
    Assert.assertEquals("retl_mark", result.getTableName());
    queryString = "DROP TABLE IF EXISTS test.retl_mark;";
    result = DruidDdlParser.parse(queryString, "retl").get(0);
    Assert.assertNotNull(result);
    Assert.assertEquals("test", result.getSchemaName());
    Assert.assertEquals("retl_mark", result.getTableName());
    queryString = "DROP TABLE IF EXISTS \n \"test\".`retl_mark`;";
    result = DruidDdlParser.parse(queryString, "retl").get(0);
    Assert.assertNotNull(result);
    Assert.assertEquals("test", result.getSchemaName());
    Assert.assertEquals("retl_mark", result.getTableName());
    queryString = "DROP TABLE IF EXISTS \n retl.retl_mark , retl_test";
    result = DruidDdlParser.parse(queryString, "test").get(0);
    Assert.assertNotNull(result);
    Assert.assertEquals("retl", result.getSchemaName());
    Assert.assertEquals("retl_mark", result.getTableName());
    result = DruidDdlParser.parse(queryString, "test").get(1);
    Assert.assertNotNull(result);
    Assert.assertEquals("test", result.getSchemaName());
    Assert.assertEquals("retl_test", result.getTableName());
    queryString = "DROP /*!40005 TEMPORARY */ TABLE IF EXISTS `temp_bond_keys`.`temp_bond_key_id`;";
    result = DruidDdlParser.parse(queryString, "retl").get(0);
    Assert.assertNotNull(result);
    Assert.assertEquals("temp_bond_keys", result.getSchemaName());
    Assert.assertEquals("temp_bond_key_id", result.getTableName());
}
Also used : DdlResult(com.alibaba.otter.canal.parse.inbound.mysql.ddl.DdlResult) Test(org.junit.Test)

Example 33 with DdlResult

use of com.alibaba.otter.canal.parse.inbound.mysql.ddl.DdlResult in project canal by alibaba.

the class DruidDdlParserTest method testAlert.

@Test
public void testAlert() {
    String queryString = "alter table retl_mark drop index emp_name";
    DdlResult result = DruidDdlParser.parse(queryString, "retl").get(0);
    Assert.assertNotNull(result);
    Assert.assertEquals("retl_mark", result.getTableName());
    queryString = "alter table retl.retl_mark drop index emp_name";
    result = DruidDdlParser.parse(queryString, "retl").get(0);
    Assert.assertNotNull(result);
    Assert.assertEquals("retl_mark", result.getTableName());
    queryString = "alter table \n retl.`retl_mark` drop index emp_name;";
    result = DruidDdlParser.parse(queryString, "retl").get(0);
    Assert.assertNotNull(result);
    Assert.assertEquals("retl_mark", result.getTableName());
    queryString = "alter table retl.retl_mark drop index emp_name , add index emp_name(id)";
    result = DruidDdlParser.parse(queryString, "retl").get(0);
    Assert.assertNotNull(result);
    Assert.assertEquals("retl_mark", result.getTableName());
    Assert.assertEquals(EventType.DINDEX, result.getType());
    result = DruidDdlParser.parse(queryString, "retl").get(1);
    Assert.assertNotNull(result);
    Assert.assertEquals("retl_mark", result.getTableName());
    Assert.assertEquals(EventType.CINDEX, result.getType());
}
Also used : DdlResult(com.alibaba.otter.canal.parse.inbound.mysql.ddl.DdlResult) Test(org.junit.Test)

Aggregations

DdlResult (com.alibaba.otter.canal.parse.inbound.mysql.ddl.DdlResult)33 Test (org.junit.Test)29 CanalParseException (com.alibaba.otter.canal.parse.exception.CanalParseException)3 ByteString (com.google.protobuf.ByteString)3 EventType (com.alibaba.otter.canal.protocol.CanalEntry.EventType)2 MetaHistoryDO (com.alibaba.otter.canal.parse.inbound.mysql.tsdb.dao.MetaHistoryDO)1 Header (com.alibaba.otter.canal.protocol.CanalEntry.Header)1 RowChange (com.alibaba.otter.canal.protocol.CanalEntry.RowChange)1 TransactionBegin (com.alibaba.otter.canal.protocol.CanalEntry.TransactionBegin)1 TransactionEnd (com.alibaba.otter.canal.protocol.CanalEntry.TransactionEnd)1 EntryPosition (com.alibaba.otter.canal.protocol.position.EntryPosition)1 LogHeader (com.taobao.tddl.dbsync.binlog.event.LogHeader)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 HashMap (java.util.HashMap)1 List (java.util.List)1