### Question:
SpringBeanNameResolver implements ELBeanNameResolver { public boolean init(ServletContext servletContext, ClassLoader classLoader) { webAppContext = servletContext.getAttribute("org.springframework.web.context.WebApplicationContext.ROOT"); if (webAppContext == null) { if (log.isDebugEnabled()) { log.debug("WebApplicationContext not found in ServletContext. Resolver has been disabled."); } return false; } try { Class<?> webAppContextClass = classLoader.loadClass(WEB_APP_CONTEXT_CLASS); getBeanNamesMethod = webAppContextClass.getMethod(GET_BEAN_NAMES_METHOD, Class.class); if (log.isDebugEnabled()) { log.debug("Spring detected. Enabling Spring bean name resolving."); } getTargetBeanNameMethod = getProxyTargetBeanNameMethod(classLoader); return true; } catch (ClassNotFoundException e) { if (log.isDebugEnabled()) { log.debug("WebApplicationContext class could not be found. Resolver has been disabled."); } } catch (NoSuchMethodException e) { log.warn("Cannot find getBeanNamesByType() method.", e); } catch (SecurityException e) { log.warn("Unable to init resolver due to security restrictions", e); } return false; }  boolean init(ServletContext servletContext, ClassLoader classLoader); String getBeanName(Class<?> clazz);  }### Answer:
@Test public void testNoSpringEnvironment() throws Exception { ServletContext servletContext = EasyMock.createNiceMock(ServletContext.class); ClassLoader classLoader = EasyMock.createNiceMock(ClassLoader.class); EasyMock.expect(classLoader.loadClass((String) EasyMock.anyObject())).andThrow(new ClassNotFoundException()) .anyTimes(); EasyMock.replay(classLoader); SpringBeanNameResolver resolver = new SpringBeanNameResolver(); boolean initCompleted = resolver.init(servletContext, classLoader); assertFalse(initCompleted); }