### Question:
ServiceUtil { public static Set<String> classNamesNamedIn(ClassLoader classLoader, String fileName) throws IOException { final Set<String> classNames = new LinkedHashSet<>(); ClassPathUtils.consumeAsStreams(classLoader, fileName, classFile -> { try (InputStreamReader reader = new InputStreamReader(classFile, StandardCharsets.UTF_8)) { try (BufferedReader br = new BufferedReader(reader)) { readStream(classNames, br); } } catch (IOException e) { throw new UncheckedIOException(e); } }); return Collections.unmodifiableSet(classNames); } private  ServiceUtil(); static Iterable<Class<?>> classesNamedIn(ClassLoader classLoader, String fileName); static Set<String> classNamesNamedIn(ClassLoader classLoader, String fileName); static Set<String> classNamesNamedIn(Path path);  }### Answer:
@Test public void testNamesNamedIn() throws IOException { String fileName = "META-INF/services/test.javax.servlet.ServletContainerInitializer"; String[] classNames = new String[] { "org.apache.logging.log4j.web.Log4jServletContainerInitializer", "org.apache.logging.log4j.core.Appender", "org.apache.logging.log4j.core.Core", "org.apache.logging.log4j.core.Core2", "org.apache.logging.log4j.core.Core3", "org.apache.logging.log4j.core.Layout", "org.apache.logging.log4j.core.Layout2" }; Set<String> classes = ServiceUtil.classNamesNamedIn(Thread.currentThread().getContextClassLoader(), fileName); assertEquals(7, classes.size()); assertThat(classes).contains(classNames); }