use of com.alibaba.datax.core.job.JobContainer in project DataX by alibaba.
the class JobContainerTest method testPreHandler.
@Test
public void testPreHandler() throws Exception {
JobContainer jobContainer = new JobContainer(this.configuration);
Method initMethod = jobContainer.getClass().getDeclaredMethod("preHandle");
initMethod.setAccessible(true);
initMethod.invoke(jobContainer, new Object[] {});
System.out.println(this.configuration.get("job.preHandler.test"));
Assert.assertEquals("writePreDone", this.configuration.get("job.preHandler.test"));
}
use of com.alibaba.datax.core.job.JobContainer in project DataX by alibaba.
the class JobContainerTest method testErrorLimitCountCheck.
@Test(expected = Exception.class)
public void testErrorLimitCountCheck() throws Exception {
this.configuration.remove(CoreConstant.DATAX_JOB_SETTING_ERRORLIMIT_PERCENT);
this.configuration.set(CoreConstant.DATAX_JOB_SETTING_ERRORLIMIT_RECORD, 1);
JobContainer jobContainer = new JobContainer(this.configuration);
Communication communication = new Communication();
communication.setLongCounter(CommunicationTool.READ_SUCCEED_RECORDS, 100);
communication.setLongCounter(CommunicationTool.WRITE_RECEIVED_RECORDS, 98);
communication.setLongCounter(CommunicationTool.WRITE_FAILED_RECORDS, 2);
// LocalTaskGroupCommunicationManager.updateTaskGroupCommunication(0, communication);
Method initMethod = jobContainer.getClass().getDeclaredMethod("checkLimit");
initMethod.setAccessible(true);
initMethod.invoke(jobContainer);
initMethod.setAccessible(false);
}
use of com.alibaba.datax.core.job.JobContainer in project DataX by alibaba.
the class JobContainerTest method testPreHandlerByReader.
@Test
public void testPreHandlerByReader() throws Exception {
Configuration copyConfig = this.configuration.clone();
copyConfig.set(CoreConstant.DATAX_JOB_PREHANDLER_PLUGINTYPE, "reader");
copyConfig.set(CoreConstant.DATAX_JOB_PREHANDLER_PLUGINNAME, "fakereader");
JobContainer jobContainer = new JobContainer(copyConfig);
Method initMethod = jobContainer.getClass().getDeclaredMethod("preHandle");
initMethod.setAccessible(true);
initMethod.invoke(jobContainer, new Object[] {});
System.out.println(copyConfig.get("job.preHandler.test"));
Assert.assertEquals("readPreDone", copyConfig.get("job.preHandler.test"));
}
use of com.alibaba.datax.core.job.JobContainer in project DataX by alibaba.
the class JobContainerTest method testMergeReaderAndWriterSlicesConfigsException.
@Test(expected = Exception.class)
public void testMergeReaderAndWriterSlicesConfigsException() throws Exception {
JobContainer jobContainer = new JobContainer(this.configuration);
Method initMethod = jobContainer.getClass().getDeclaredMethod("init");
initMethod.setAccessible(true);
initMethod.invoke(jobContainer, new Object[] {});
initMethod.setAccessible(false);
int readerSplitNumber = 100;
int writerSplitNumber = readerSplitNumber + 1;
List<Configuration> readerSplitConfigurations = new ArrayList<Configuration>();
List<Configuration> writerSplitConfigurations = new ArrayList<Configuration>();
for (int i = 0; i < readerSplitNumber; i++) {
Configuration readerOneConfig = Configuration.newDefault();
readerSplitConfigurations.add(readerOneConfig);
}
for (int i = 0; i < writerSplitNumber; i++) {
Configuration readerOneConfig = Configuration.newDefault();
writerSplitConfigurations.add(readerOneConfig);
}
initMethod = jobContainer.getClass().getDeclaredMethod("mergeReaderAndWriterSlicesConfigs", List.class, List.class);
initMethod.setAccessible(true);
initMethod.invoke(jobContainer, readerSplitConfigurations, writerSplitConfigurations);
}
use of com.alibaba.datax.core.job.JobContainer in project DataX by alibaba.
the class JobContainerTest method testPostHandlerByReader.
@Test
public void testPostHandlerByReader() throws Exception {
Configuration copyConfig = this.configuration.clone();
copyConfig.set(CoreConstant.DATAX_JOB_POSTHANDLER_PLUGINTYPE, "reader");
copyConfig.set(CoreConstant.DATAX_JOB_POSTHANDLER_PLUGINNAME, "fakereader");
JobContainer jobContainer = new JobContainer(copyConfig);
Method initMethod = jobContainer.getClass().getDeclaredMethod("postHandle");
initMethod.setAccessible(true);
initMethod.invoke(jobContainer, new Object[] {});
System.out.println(copyConfig.get("job.postHandler.test"));
Assert.assertEquals("readPostDone", copyConfig.get("job.postHandler.test"));
}
Aggregations