ApplicationAccess { public static void register(ApplicationContext applicationContext) { applicationContext.getApplicationScope().put( APPLICATION_CONTEXT_ATTRIBUTE, applicationContext); } private  ApplicationAccess(); static void register(ApplicationContext applicationContext); static final String APPLICATION_CONTEXT_ATTRIBUTE; }
@SuppressWarnings("unchecked") @Test public void testRegister() { ApplicationContext applicationContext = createMock(ApplicationContext.class); Map<String, Object> applicationScope = createMock(Map.class); expect(applicationContext.getApplicationScope()).andReturn(applicationScope); expect(applicationScope.put(ApplicationAccess .APPLICATION_CONTEXT_ATTRIBUTE, applicationContext)).andReturn(null); replay(applicationContext, applicationScope); ApplicationAccess.register(applicationContext); verify(applicationContext, applicationScope); }