// declared reader schemas. This test will be updated accordingly.
@Test
public void testWSchemaWhenSpecRecClassNF() throws Exception {
final Kiji kiji = mKiji;
kiji.createTable(KijiTableLayouts.getLayout(WRITER_SCHEMA_TEST));
final KijiTable table = kiji.openTable("writer_schema");
try {
// Write a (generic) record:
final Schema writerSchema = Schema.createRecord("Found", null, "class.not", false);
writerSchema.setFields(Lists.newArrayList(
new Field("field", Schema.create(Schema.Type.STRING), null, null)));
final KijiTableWriter writer = table.openTableWriter();
try {
final GenericData.Record record = new GenericRecordBuilder(writerSchema)
.set("field", "value")
.build();
writer.put(table.getEntityId("eid"), "family", "qualifier", 1L, record);
} finally {
writer.close();
}
// Read the record back (should be a generic record):
final KijiTableReader reader = table.openTableReader();
try {
final KijiDataRequest dataRequest = KijiDataRequest.builder()
.addColumns(ColumnsDef.create().add("family", "qualifier"))
.build();
final KijiRowData row = reader.get(table.getEntityId("eid"), dataRequest);
final GenericData.Record record = row.getValue("family", "qualifier", 1L);
assertEquals(writerSchema, record.getSchema());
assertEquals("value", record.get("field").toString());
} finally {
reader.close();
}
} finally {
table.release();
}
}