### Question:
IsolatedServiceLoader implements Iterable<S> { public boolean update() { log.entry(); final Enumeration<URL> urls; try { urls = classLoader.getResources(SERVICES_PREFIX + service.getName()); } catch (final IOException e) { log.warn("Unable to find {} services", service.getSimpleName(), e); return log.exit(false); } final Set<String> resources = new HashSet<>(); while (urls.hasMoreElements()) { resources.add(urls.nextElement().toString()); } if (configLoaded.containsAll(resources)) { log.debug("No new {} services found", service.getSimpleName()); return log.exit(false); } serviceLoader.reload(); configLoaded.addAll(resources); return log.exit(true); } IsolatedServiceLoader(@Nonnull final Class<S> service, @Nonnull final URLClassLoader loader); @Nonnull @Override Iterator<S> iterator(); @Override String toString(); boolean update();  }### Answer:
@Test @SuppressWarnings({"squid:S2112", "unchecked"}) public void testUpdate() { final Set<URL> resources = new HashSet<>(); final URLClassLoader classLoader = new URLClassLoader(new URL[0]) { @Override public Enumeration<URL> findResources(final String name) { return Collections.enumeration(resources); } }; final IsolatedServiceLoader<FileSystem> loader = new IsolatedServiceLoader<>(FileSystem.class, classLoader); boolean result = loader.update(); Assert.assertFalse(result); Assert.assertEquals(0, Iterables.size(loader)); resources.add(getClass().getResource("file-system-services-1.txt")); result = loader.update(); Assert.assertTrue(result); Assert.assertEquals(1, Iterables.size(loader)); Assert.assertThat(loader, CoreMatchers.hasItem(CoreMatchers.<FileSystem>instanceOf(MockFileSystem.class))); result = loader.update(); Assert.assertFalse(result); Assert.assertEquals(1, Iterables.size(loader)); Assert.assertThat(loader, CoreMatchers.hasItem(CoreMatchers.<FileSystem>instanceOf(MockFileSystem.class))); resources.add(getClass().getResource("file-system-services-2.txt")); result = loader.update(); Assert.assertTrue(result); Assert.assertEquals(2, Iterables.size(loader)); Matcher[] matchers = new Matcher[] {CoreMatchers.instanceOf(MockFileSystem.class), CoreMatchers.instanceOf(LocalFileSystem.class)}; Assert.assertThat(loader, CoreMatchers.hasItems(matchers)); }