use of co.cask.cdap.etl.batch.StructuredRecordWritable in project cdap by caskdata.
the class StructuredRecordWritableTest method testNonAsciiString.
@Test
public void testNonAsciiString() throws IOException {
Schema schema = Schema.recordOf("rec", Schema.Field.of("x", Schema.of(Schema.Type.STRING)));
StructuredRecord record = StructuredRecord.builder(schema).set("x", "идыло").build();
StructuredRecordWritable writableOut = new StructuredRecordWritable(record);
ByteArrayOutputStream os = new ByteArrayOutputStream();
DataOutput output = new DataOutputStream(os);
writableOut.write(output);
os.flush();
StructuredRecordWritable writableIn = new StructuredRecordWritable();
ByteArrayInputStream is = new ByteArrayInputStream(os.toByteArray());
DataInput input = new DataInputStream(is);
writableIn.readFields(input);
Assert.assertEquals(writableIn.get(), record);
}
Aggregations