ResourceContext { public Resource consumeResource() { Resource result = null; if (hasChanged()) { setHasChanged(false); result = getResource(); } return result; } ResourceContext(ExecutionContext executionContext, String keyPrefix); void changeResource(Resource resource); Resource consumeResource(); boolean hasChanged(); boolean containsResource(); Resource getResource(); void setResource(Resource resource); void setCurrentIndex(int index); void incrementIndex(); int getCurrentIndex(); ExecutionContext getExecutionContext(); void setRowsToSkip(int rowsToSkip); void clear(); static final String RESOURCE_KEY; static final String HAS_CHANGED_KEY; static final String CURRENT_INDEX_KEY; }
@Test public void testConsumeResource() throws Exception { Resource expected = new FileSystemResource("./"); Resource actual; context.changeResource(expected); actual = context.consumeResource(); Assert.assertEquals(expected, actual); Assert.assertTrue(context.containsResource()); Assert.assertFalse(context.hasChanged()); }