### Question:
ServiceLocator implements ApplicationContextAware { public static ApplicationContext getFactory() { Assert.notNull(factory, "没有注入spring factory"); return factory; }  static ApplicationContext getFactory(); static void setFactory(ApplicationContext context); @SuppressWarnings("unchecked") static T getBean(String beanName); static Map<String, T> getBeansOfType(Class<T> type); static Map<String, T> getBeansOfType(Class<T> type,
			boolean includeNonSingletons, boolean allowEagerInit); static T getBean(Class<T> clazz); static boolean containsBean(String name); static boolean isSingleton(String name); static Class<?> getType(String name); static String[] getAliases(String name); void setApplicationContext(ApplicationContext applicationContext);  }### Answer:
@Test public void testGetFactory() { try { ServiceLocator.getBean("test"); } catch (IllegalArgumentException e) { assertEquals(e.getMessage(), "没有注入spring factory"); } }