### Question:
MapServiceLocator implements ServiceLocator { @Override public <T> T resolve(final Class<T> clazz) { final Object component = resolve(clazz, true); return clazz.cast(component); } MapServiceLocator();   MapServiceLocator(final Map<Class<?>, Object> initialComponents); @Override T resolve(final Class<T> clazz); MapServiceLocator register(final Class<T> target, final Object service);  }### Answer:
@Test public void withDefaultLoggerAndEC() throws Exception { final Map<Class<?>, Object> initialComponents = new HashMap<Class<?>, Object>(); final ExecutorService executorService = Executors.newSingleThreadExecutor(); initialComponents.put(ExecutorService.class, executorService); final Logger logger = LoggerFactory.getLogger("test-logger"); initialComponents.put(Logger.class, logger); final MapServiceLocator mapServiceLocator = new MapServiceLocator(initialComponents); assertSame("Executor matches", executorService, mapServiceLocator.resolve(ExecutorService.class)); assertSame("Logger matches", logger, mapServiceLocator.resolve(Logger.class)); }