MultiResourceToReadLocator extends CountingItemResourceLocator<T> { @Override public void onRead(T item, ResourceContext context) throws Exception { super.onRead(item, context); if (item == null && resourceIndex < resources.length) { context.changeResource(resources[resourceIndex++]); } }  @Override void onOpen(ResourceContext context); @Override void onRead(T item, ResourceContext context); void setDirectory(Resource directory); void setFilter(String filter);  }
@Test public void testOnRead() throws Exception { ResourceContext resourceContext = new ResourceContext(new ExecutionContext(), "foo"); Resource expected; Resource actual; locator.onOpen(resourceContext); expected = resourceContext.getResource(); locator.onRead("a", resourceContext); actual = resourceContext.getResource(); Assert.assertTrue(resourceContext.containsResource()); Assert.assertEquals(expected, actual); }