@Test public void commitTest() throws Exception { dataTable.put( "1", tableProvider.deserialize(dataTable, "<row><col>98</col><col>bear</col></row>")); dataTable.put( "3", tableProvider.deserialize(dataTable, "<row><col>5</col><col>pig</col></row>")); dataTable.remove("3"); Assert.assertEquals(dataTable.commit(), 1); }
@Test public void rollbackTest() throws Exception { dataTable.put( "7", tableProvider.deserialize(dataTable, "<row><col>5</col><col>text</col></row>")); dataTable.remove("7"); Assert.assertEquals(dataTable.rollback(), 0); dataTable.put( "8", tableProvider.deserialize(dataTable, "<row><col>45</col><col>text</col></row>")); dataTable.remove("7"); Assert.assertEquals(dataTable.rollback(), 1); }
@Test public void sizeTest() throws Exception { Assert.assertEquals(dataTable.size(), 0); dataTable.put( "moo", tableProvider.deserialize(dataTable, "<row><col>5</col><col>text</col></row>")); dataTable.remove("moo"); dataTable.remove("foo"); dataTable.put( "newValue", tableProvider.deserialize(dataTable, "<row><col>78</col><col>car</col></row>")); Assert.assertEquals(dataTable.size(), 1); }
@Before public void setUp() throws Exception { types = new ArrayList<Class<?>>(); types.add(Integer.class); types.add(String.class); if (!testedFile.exists()) { testedFile.mkdir(); } tableProvider = new StoreableTableProvider(testedFile); dataTable = tableProvider.createTable(TESTED_TABLE, types); tableProvider.setCurTable(TESTED_TABLE); }