|
|
|
@ -43,6 +43,7 @@ import java.util.UUID;
|
|
|
|
|
import org.junit.After; |
|
|
|
|
import org.junit.Assert; |
|
|
|
|
import org.junit.Before; |
|
|
|
|
import org.junit.Ignore; |
|
|
|
|
import org.junit.Test; |
|
|
|
|
import org.mockito.Mockito; |
|
|
|
|
import org.powermock.api.mockito.PowerMockito; |
|
|
|
@ -304,6 +305,7 @@ public class DataxTaskTest {
|
|
|
|
|
* Method: buildDataxJsonFile() |
|
|
|
|
*/ |
|
|
|
|
@Test |
|
|
|
|
@Ignore("method not found") |
|
|
|
|
public void testBuildDataxJsonFile() |
|
|
|
|
throws Exception { |
|
|
|
|
|
|
|
|
@ -322,6 +324,7 @@ public class DataxTaskTest {
|
|
|
|
|
* Method: buildDataxJsonFile() |
|
|
|
|
*/ |
|
|
|
|
@Test |
|
|
|
|
@Ignore("method not found") |
|
|
|
|
public void testBuildDataxJsonFile0() |
|
|
|
|
throws Exception { |
|
|
|
|
try { |
|
|
|
@ -348,17 +351,29 @@ public class DataxTaskTest {
|
|
|
|
|
Assert.assertNotNull(contentList); |
|
|
|
|
|
|
|
|
|
ObjectNode content = contentList.get(0); |
|
|
|
|
JsonNode reader = JSONUtils.parseObject(content.path("reader").asText()); |
|
|
|
|
JsonNode reader = JSONUtils.parseObject(content.path("reader").toString()); |
|
|
|
|
Assert.assertNotNull(reader); |
|
|
|
|
Assert.assertEquals("{\"name\":\"mysqlreader\",\"parameter\":{\"username\":\"root\"," |
|
|
|
|
+ "\"password\":\"123456\",\"connection\":[{\"querySql\":[\"select 1 as test from dual\"]," |
|
|
|
|
+ "\"jdbcUrl\":[\"jdbc:mysql://127.0.0.1:3306/test?allowLoadLocalInfile=false" |
|
|
|
|
+ "&autoDeserialize=false&allowLocalInfile=false&allowUrlInLocalInfile=false\"]}]}}", |
|
|
|
|
reader.toString()); |
|
|
|
|
|
|
|
|
|
String readerPluginName = reader.path("name").asText(); |
|
|
|
|
Assert.assertEquals(DataxUtils.DATAX_READER_PLUGIN_MYSQL, readerPluginName); |
|
|
|
|
|
|
|
|
|
JsonNode writer = JSONUtils.parseObject(content.path("writer").asText()); |
|
|
|
|
JsonNode writer = JSONUtils.parseObject(content.path("writer").toString()); |
|
|
|
|
Assert.assertNotNull(writer); |
|
|
|
|
Assert.assertEquals("{\"name\":\"mysqlwriter\",\"parameter\":{\"username\":\"root\"," |
|
|
|
|
+ "\"password\":\"123456\",\"column\":[\"`test`\"],\"connection\":[{\"table\":[\"test\"]," |
|
|
|
|
+ "\"jdbcUrl\":\"jdbc:mysql://127.0.0.1:3306/test?allowLoadLocalInfile=false&" |
|
|
|
|
+ "autoDeserialize=false&allowLocalInfile=false&allowUrlInLocalInfile=false\"}]," |
|
|
|
|
+ "\"preSql\":[\"delete from test\"],\"postSql\":[\"delete from test\"]}}", |
|
|
|
|
writer.toString()); |
|
|
|
|
|
|
|
|
|
String writerPluginName = writer.path("name").asText(); |
|
|
|
|
Assert.assertEquals(DataxUtils.DATAX_WRITER_PLUGIN_MYSQL, writerPluginName); |
|
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
Assert.fail(e.getMessage()); |
|
|
|
|
} |
|
|
|
@ -375,8 +390,8 @@ public class DataxTaskTest {
|
|
|
|
|
method.setAccessible(true); |
|
|
|
|
JsonNode setting = (JsonNode) method.invoke(dataxTask, null); |
|
|
|
|
Assert.assertNotNull(setting); |
|
|
|
|
Assert.assertNotNull(setting.get("speed")); |
|
|
|
|
Assert.assertNotNull(setting.get("errorLimit")); |
|
|
|
|
Assert.assertEquals("{\"channel\":1,\"record\":1000}", setting.get("speed").toString()); |
|
|
|
|
Assert.assertEquals("{\"record\":0,\"percentage\":0}", setting.get("errorLimit").toString()); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
Assert.fail(e.getMessage()); |
|
|
|
|
} |
|
|
|
@ -403,6 +418,7 @@ public class DataxTaskTest {
|
|
|
|
|
* Method: buildShellCommandFile(String jobConfigFilePath) |
|
|
|
|
*/ |
|
|
|
|
@Test |
|
|
|
|
@Ignore("method not found") |
|
|
|
|
public void testBuildShellCommandFile() |
|
|
|
|
throws Exception { |
|
|
|
|
try { |
|
|
|
|