### Question:
ConcurrentRuntime implements PostConstruct, PreDestroy { public synchronized ManagedThreadFactoryImpl getManagedThreadFactory(ResourceInfo resource, ManagedThreadFactoryConfig config) { String jndiName = config.getJndiName(); if (managedThreadFactoryMap != null && managedThreadFactoryMap.containsKey(jndiName)) { return managedThreadFactoryMap.get(jndiName); } ManagedThreadFactoryImpl managedThreadFactory = new ManagedThreadFactoryImpl(config.getJndiName(), createContextService(config.getJndiName() + "-contextservice", config.getContextInfo(), config.getContextInfoEnabled(), true), config.getThreadPriority()); if (managedThreadFactoryMap == null) { managedThreadFactoryMap = new HashMap(); } managedThreadFactoryMap.put(jndiName, managedThreadFactory); return managedThreadFactory; } ConcurrentRuntime(); static ConcurrentRuntime getRuntime(); ComponentEnvManager getCompEnvMgr(); synchronized ContextServiceImpl getContextService(ResourceInfo resource, ContextServiceConfig config); void shutdownContextService(String jndiName); synchronized ManagedExecutorServiceImpl getManagedExecutorService(ResourceInfo resource, ManagedExecutorServiceConfig config); void shutdownManagedExecutorService(String jndiName); synchronized ManagedScheduledExecutorServiceImpl getManagedScheduledExecutorService(ResourceInfo resource,
                                                                                               ManagedScheduledExecutorServiceConfig config); void shutdownScheduledManagedExecutorService(String jndiName); synchronized ManagedThreadFactoryImpl getManagedThreadFactory(ResourceInfo resource, ManagedThreadFactoryConfig config); void shutdownManagedThreadFactory(String jndiName); @Override void postConstruct(); @Override void preDestroy(); static final String CONTEXT_INFO_CLASSLOADER; static final String CONTEXT_INFO_JNDI; static final String CONTEXT_INFO_SECURITY; static final String CONTEXT_INFO_WORKAREA; }### Answer:
@Ignore @Test public void testCreateManagedThreadFactory() throws Exception { final int THREAD_PRIORITY = 8; expect(managedThreadFactoryConfig.getJndiName()).andReturn("concurrent/mtf").anyTimes(); expect(managedThreadFactoryConfig.getContextInfo()).andReturn("Classloader, JNDI, Security").anyTimes(); expect(managedThreadFactoryConfig.getContextInfoEnabled()).andReturn("true").anyTimes(); expect(managedThreadFactoryConfig.getThreadPriority()).andReturn(THREAD_PRIORITY).anyTimes(); replay(managedThreadFactoryConfig); ConcurrentRuntime concurrentRuntime = new ConcurrentRuntime(); ResourceInfo resource = new ResourceInfo("test"); ManagedThreadFactoryImpl managedThreadFactory = concurrentRuntime.getManagedThreadFactory(resource, managedThreadFactoryConfig); ContextServiceImpl contextService = (ContextServiceImpl) Util.getdFieldValue(managedThreadFactory, "contextService"); ContextSetupProviderImpl contextSetupProvider = (ContextSetupProviderImpl) contextService.getContextSetupProvider(); assertTrue((Boolean) Util.getdFieldValue(contextSetupProvider, "classloading")); assertTrue((Boolean) Util.getdFieldValue(contextSetupProvider, "naming")); assertTrue((Boolean) Util.getdFieldValue(contextSetupProvider, "security")); assertFalse((Boolean) Util.getdFieldValue(contextSetupProvider, "workArea")); int threadPriority = (Integer)Util.getdFieldValue(managedThreadFactory, "priority"); assertEquals(THREAD_PRIORITY, threadPriority); }