コード例 #1
0
 @Test(expected = IllegalStateException.class)
 public void closeTablePutValueShouldFail() throws Exception {
   dataTable.close();
   Storeable value = new StoreableDataValue(types);
   value.setColumnAt(0, 5);
   value.setColumnAt(1, "book");
   dataTable.put("key", value);
 }
コード例 #2
0
 @Test
 public void removeValidKeyTest() {
   Assert.assertNull(dataTable.remove("chair"));
   Storeable firstValue = new StoreableDataValue(types);
   firstValue.setColumnAt(0, 2);
   firstValue.setColumnAt(1, "black");
   dataTable.put("cats", firstValue);
   Assert.assertEquals(dataTable.remove("cats"), firstValue);
 }
コード例 #3
0
 @Test
 public void getValidKey() throws Exception {
   Assert.assertNull(dataTable.get("one"));
   Storeable value = new StoreableDataValue(types);
   value.setColumnAt(0, 5);
   value.setColumnAt(1, "book");
   dataTable.put("favourite", value);
   Assert.assertEquals(dataTable.get("favourite"), value);
 }
コード例 #4
0
 @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);
 }
コード例 #5
0
 @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);
 }
コード例 #6
0
 @Test
 public void putValidValueTest() {
   Storeable firstValue = new StoreableDataValue(types);
   firstValue.setColumnAt(0, 56);
   firstValue.setColumnAt(1, "pages");
   Storeable secondValue = new StoreableDataValue(types);
   secondValue.setColumnAt(0, 40);
   secondValue.setColumnAt(1, "pages");
   dataTable.put("qwerty", secondValue);
   Assert.assertEquals(dataTable.put("qwerty", firstValue), secondValue);
   Assert.assertNull(dataTable.put("key", firstValue));
 }
コード例 #7
0
 @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);
 }
コード例 #8
0
 @Test(expected = IllegalArgumentException.class)
 public void removeNullKeyShouldFail() {
   dataTable.remove(null);
 }
コード例 #9
0
 @Test(expected = IllegalArgumentException.class)
 public void putNullKeyShouldFail() throws IOException {
   dataTable.put(null, new StoreableDataValue(types));
 }
コード例 #10
0
 @Test(expected = IllegalArgumentException.class)
 public void putNullValueShouldFail() throws Exception {
   dataTable.put("moo", null);
 }
コード例 #11
0
 @Test(expected = IllegalArgumentException.class)
 public void getNullKeyShouldFail() throws Exception {
   dataTable.get(null);
 }
コード例 #12
0
 @Test
 public void getNameTest() throws Exception {
   Assert.assertEquals(dataTable.getName(), TESTED_TABLE);
 }
コード例 #13
0
 @Test(expected = IllegalStateException.class)
 public void closeTableGetShouldFail() throws Exception {
   dataTable.close();
   dataTable.get("key");
 }
コード例 #14
0
 @Test(expected = IndexOutOfBoundsException.class)
 public void getNotExistingColumnTypeShouldFail() {
   dataTable.getColumnType(35);
 }
コード例 #15
0
 @Test
 public void getValidColumnType() throws Exception {
   Assert.assertEquals(dataTable.getColumnType(0), Integer.class);
   Assert.assertEquals(dataTable.getColumnType(1), String.class);
 }
コード例 #16
0
 @Test
 public void getColumnsCountTest() throws Exception {
   Assert.assertEquals(dataTable.getColumnsCount(), types.size());
 }