@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."); }
@Test(expected = RuntimeException.class) public void testPutBadName() throws NoMoreElementsException { storage.putNext("\0", "data"); Assert.fail(); }
@Test(expected = NoMoreElementsException.class) public void testMultipleReadWrites() throws NoMoreElementsException { String myObj = "This is a test"; boolean success = storage.putNext("test-obj", myObj); Assert.assertTrue(success); success = storage.putNext("test-obj", "This-is-second-test"); Assert.assertTrue(success); Serializable s = storage.getNext("test-obj"); Assert.assertThat(s, Is.is(myObj)); s = storage.getNext("test-obj"); Assert.assertThat(s, Is.is("This-is-second-test")); storage.getNext("test-obj"); Assert.fail(); }
@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)); }