### Question:
NodeManager extends CompositeService implements
    ServiceStateChangeListener { @Override public void init(Configuration conf) { conf.setBoolean(Dispatcher.DISPATCHER_EXIT_ON_ERROR_KEY, true); NMContainerTokenSecretManager containerTokenSecretManager = null; if (UserGroupInformation.isSecurityEnabled()) { LOG.info("Security is enabled on NodeManager. " + "Creating ContainerTokenSecretManager"); containerTokenSecretManager = new NMContainerTokenSecretManager(conf); } this.context = new NMContext(containerTokenSecretManager); this.aclsManager = new ApplicationACLsManager(conf); ContainerExecutor exec = ReflectionUtils.newInstance( conf.getClass(YarnConfiguration.NM_CONTAINER_EXECUTOR, DefaultContainerExecutor.class, ContainerExecutor.class), conf); try { exec.init(); } catch (IOException e) { throw new YarnException("Failed to initialize container executor", e); } DeletionService del = new DeletionService(exec); addService(del); this.dispatcher = new AsyncDispatcher(); nodeHealthChecker = new NodeHealthCheckerService(); addService(nodeHealthChecker); dirsHandler = nodeHealthChecker.getDiskHandler(); NodeStatusUpdater nodeStatusUpdater = createNodeStatusUpdater(context, dispatcher, nodeHealthChecker); nodeStatusUpdater.register(this); NodeResourceMonitor nodeResourceMonitor = createNodeResourceMonitor(); addService(nodeResourceMonitor); containerManager = createContainerManager(context, exec, del, nodeStatusUpdater, this.aclsManager, dirsHandler); addService(containerManager); Service webServer = createWebServer(context, containerManager .getContainersMonitor(), this.aclsManager, dirsHandler); addService(webServer); dispatcher.register(ContainerManagerEventType.class, containerManager); addService(dispatcher); DefaultMetricsSystem.initialize("NodeManager"); addService(nodeStatusUpdater); waitForContainersOnShutdownMillis = conf.getLong(YarnConfiguration.NM_SLEEP_DELAY_BEFORE_SIGKILL_MS, YarnConfiguration.DEFAULT_NM_SLEEP_DELAY_BEFORE_SIGKILL_MS) + conf.getLong(YarnConfiguration.NM_PROCESS_KILL_WAIT_MS, YarnConfiguration.DEFAULT_NM_PROCESS_KILL_WAIT_MS) + SHUTDOWN_CLEANUP_SLOP_MS; super.init(conf); } NodeManager(); @Override void init(Configuration conf); @Override void start(); @Override void stop(); NodeHealthCheckerService getNodeHealthChecker(); @Override void stateChanged(Service service); static void main(String[] args); static final int SHUTDOWN_HOOK_PRIORITY; }### Answer:
@Test public void testContainerExecutorInitCall() { NodeManager nm = new NodeManager(); YarnConfiguration conf = new YarnConfiguration(); conf.setClass(YarnConfiguration.NM_CONTAINER_EXECUTOR, InvalidContainerExecutor.class, ContainerExecutor.class); try { nm.init(conf); fail("Init should fail"); } catch (YarnException e) { assert(e.getCause().getMessage().contains("dummy executor init called")); } }