CachingPasswordEncoder implements PasswordEncoder { @Override public String encode(CharSequence rawPassword) throws AuthenticationException { return passwordEncoder.encode(rawPassword); } CachingPasswordEncoder(final PasswordEncoder passwordEncoder); @Override String encode(CharSequence rawPassword); @Override boolean matches(CharSequence rawPassword, String encodedPassword);  }
@Test void encode() { String encode1 = cachingPasswordEncoder.encode(password); String encode2 = passwordEncoder.encode(password); assertNotEquals(encode1, encode2); assertTrue(passwordEncoder.matches(password, encode1)); assertTrue(passwordEncoder.matches(password, encode2)); assertTrue(cachingPasswordEncoder.matches(password, encode1)); assertTrue(cachingPasswordEncoder.matches(password, encode2)); }