use of co.cask.cdap.api.dataset.lib.IntegerStore in project cdap by caskdata.
the class ObjectStoreDatasetTest method testSubclass.
@Test
public void testSubclass() throws Exception {
DatasetId intsInstance = DatasetFrameworkTestUtil.NAMESPACE_ID.dataset("ints");
addIntegerStoreInstance(intsInstance);
final IntegerStore ints = dsFrameworkUtil.getInstance(intsInstance);
TransactionExecutor txnl = dsFrameworkUtil.newInMemoryTransactionExecutor(ints);
txnl.execute(new TransactionExecutor.Subroutine() {
@Override
public void apply() throws Exception {
ints.write(42, 101);
}
});
txnl.execute(new TransactionExecutor.Subroutine() {
@Override
public void apply() throws Exception {
Assert.assertEquals((Integer) 101, ints.read(42));
}
});
// test delete
txnl.execute(new TransactionExecutor.Subroutine() {
@Override
public void apply() throws Exception {
ints.delete(42);
}
});
txnl.execute(new TransactionExecutor.Subroutine() {
@Override
public void apply() throws Exception {
Assert.assertNull(ints.read(42));
}
});
dsFrameworkUtil.deleteInstance(intsInstance);
}
Aggregations