driverPath,
dbUrl,
"select * from " + sourceTable);
jdbcInputFormat.configure(null);
Record record = new Record();
while (!jdbcInputFormat.reachedEnd()) {
jdbcInputFormat.nextRecord(record);
jdbcOutputFormat.writeRecord(record);
}
jdbcOutputFormat.close();
jdbcInputFormat.close();
jdbcInputFormat = new JDBCInputFormat(
driverPath,
dbUrl,
"select * from " + targetTable);
jdbcInputFormat.configure(null);
int recordCount = 0;
while (!jdbcInputFormat.reachedEnd()) {
jdbcInputFormat.nextRecord(record);
Assert.assertEquals(5, record.getNumFields());
Assert.assertEquals("Field 0 should be int", IntValue.class, record.getField(0, IntValue.class).getClass());
Assert.assertEquals("Field 1 should be String", StringValue.class, record.getField(1, StringValue.class).getClass());
Assert.assertEquals("Field 2 should be String", StringValue.class, record.getField(2, StringValue.class).getClass());
Assert.assertEquals("Field 3 should be float", DoubleValue.class, record.getField(3, DoubleValue.class).getClass());
Assert.assertEquals("Field 4 should be int", IntValue.class, record.getField(4, IntValue.class).getClass());
int[] pos = {0, 1, 2, 3, 4};
Value[] values = {new IntValue(), new StringValue(), new StringValue(), new DoubleValue(), new IntValue()};
Assert.assertTrue(record.equalsFields(pos, dbData[recordCount], values));
recordCount++;
}
Assert.assertEquals(5, recordCount);