}
}
@Test
public void testUpdateLayout() throws IOException {
final KijiTable table = mKiji.openTable("user");
try {
final HBaseKijiTable htable = HBaseKijiTable.downcast(table);
final TableLayoutMonitor monitor = htable.getTableLayoutMonitor();
assertTrue(monitor.getLayoutConsumers().isEmpty());
final KijiTableWriter writer = table.openTableWriter();
try {
assertTrue(monitor.getLayoutConsumers().size() == 1);
// We can write to info:name, but not family:column.
writer.put(table.getEntityId("foo"), "info", "name", "new-val");
try {
writer.put(table.getEntityId("foo"), "family", "column", "foo-val");
fail("writer.put() should have thrown an IOException.");
} catch (NoSuchColumnException nsce) {
assertEquals("family:column", nsce.getMessage());
}
// Update the table layout.
final KijiTableLayout newLayout =
KijiTableLayout.newLayout(KijiTableLayouts.getLayout(KijiTableLayouts.SIMPLE));
monitor.updateLayoutConsumers(newLayout);
// Now we can write to family:column, but not info:name.
writer.put(table.getEntityId("foo"), "family", "column", "foo-val");
try {
writer.put(table.getEntityId("foo"), "info", "name", "two-val");
fail("writer.put() should have thrown an IOException.");
} catch (NoSuchColumnException nsce) {
assertEquals("info:name", nsce.getMessage());
}
} finally {
writer.close();
}
} finally {
table.release();
}
}