// Since "content" is an optional field, we are forced to reopen the DataStore
// to retrieve the union correctly
// Test writing+reading a null value. FIELD in HBASE MUST become DELETED
WebPage page = webPageStore.get("com.example/http") ;
page.setContent(null) ;
webPageStore.put("com.example/http", page) ;
webPageStore.close() ;
webPageStore = testDriver.createDataStore(String.class, WebPage.class);
page = webPageStore.get("com.example/http") ;
assertNull(page.getContent()) ;
// Check directly with HBase
table = new HTable(conf,"WebPage");
get = new Get(Bytes.toBytes("com.example/http"));
result = table.get(get);
actualBytes = result.getValue(Bytes.toBytes("content"), null);
assertNull(actualBytes);
table.close();
// Test writing+reading an empty bytes field. FIELD in HBASE MUST
// become EMPTY (byte[0])
page = webPageStore.get("com.example/http") ;
page.setContent(ByteBuffer.wrap("".getBytes())) ;
webPageStore.put("com.example/http", page) ;
webPageStore.close() ;
webPageStore = testDriver.createDataStore(String.class, WebPage.class);
page = webPageStore.get("com.example/http") ;
assertTrue(Arrays.equals("".getBytes(),page.getContent().array())) ;
// Check directly with HBase
table = new HTable(conf,"WebPage");
get = new Get(Bytes.toBytes("com.example/http"));
result = table.get(get);
actualBytes = result.getValue(Bytes.toBytes("content"), null);