@After public void teardown() { storage.shutdown(); try { InitializeStorage.cleanup(); } catch (IOException e) { fail(); e.printStackTrace(); } }
@Test public void testPutAndGetObject() { String myObj = "This is a test"; storage.putObject("test-obj", "test-key", myObj); String s = storage.getObject("test-obj", "test-key"); storage.shutdown(); Assert.assertThat(s, Is.is(myObj)); }
@Test public void testPutAndGetNext() throws NoMoreElementsException { String myObj = "This is a test"; boolean success = storage.putNext("test-obj", myObj); Assert.assertTrue(success); String s = storage.getNext("test-obj"); storage.shutdown(); Assert.assertThat(s, Is.is(myObj)); }
@Test(expected = RuntimeException.class) public void testWriteAfterClose() throws NoMoreElementsException { String myObj1 = "Test1"; String myObj2 = "Test2"; boolean success1 = storage.putNext("bar", myObj1); Assert.assertTrue(success1); storage.shutdown(); storage.putNext("bar", myObj2); fail("Should not be reachable."); }