/** * E.g. when using the reader in the processing phase reading might not have been attempted at all before the job * crashed (BATCH-1798). */ @Test public void testRestartAfterFailureWithoutRead() throws Exception { // save reader state without calling read tested.open(ctx); tested.update(ctx); tested.close(); // restart should work OK tested.open(ctx); assertEquals("1", tested.read()); }
@Test public void testRestartWhenStateNotSaved() throws Exception { tested.setSaveState(false); tested.open(ctx); assertEquals("1", tested.read()); tested.update(ctx); assertEquals("2", tested.read()); assertEquals("3", tested.read()); tested.close(); tested.open(ctx); assertEquals("1", tested.read()); }
/** * Restore from saved state. */ @Test public void testRestart() throws Exception { tested.open(ctx); assertEquals("1", tested.read()); assertEquals("2", tested.read()); assertEquals("3", tested.read()); assertEquals("4", tested.read()); tested.update(ctx); assertEquals("5", tested.read()); assertEquals("6", tested.read()); tested.close(); tested.open(ctx); assertEquals("5", tested.read()); assertEquals("6", tested.read()); assertEquals("7", tested.read()); assertEquals("8", tested.read()); assertEquals(null, tested.read()); }