ExtensionsLoader { List<Extension> loadExtensions() { List<Extension> result = new LinkedList<Extension>(); ServiceLoader<Extension> loader = ServiceLoader.load(Extension.class); Iterator<Extension> loaded = loader.iterator(); while(loaded.hasNext()) result.add(loaded.next()); return result; }    }
@Test public void testLoadExtension() { List<Extension> extensions = loader.loadExtensions(); Assert.assertEquals(1, extensions.size()); Assert.assertEquals(DummyExtension.class, extensions.get(0).getClass()); }