UserStorage { public void add(User user){ this.storage.add(user); } @Autowired  UserStorage(Storage storage); void add(User user);  }
@Test public void whenAddUserInStorageShouldSaveIt() throws Exception { User user = new User(); MemoryStorageImpl memoryStorage = new MemoryStorageImpl(); UserStorage userStorage = new UserStorage(memoryStorage); userStorage.add(user); }
@Test public void whenLoadContextWithDependenciesShouldGetBeans(){ ApplicationContext context = new ClassPathXmlApplicationContext("spring-config.xml"); UserStorage storage = context.getBean(UserStorage.class); storage.add(new User()); assertNotNull(storage); }