### Question:
SpyMemcachedAdapter implements MemcachedAdapter { void authenticate(ConnectionFactoryBuilder builder, OverridableReadOnlyProperties properties) { String authGeneratorClassName = properties.getProperty(AUTH_GENERATOR_PROPERTY_KEY); if (StringUtils.isEmpty(authGeneratorClassName)) { return; } try { Class<AuthDescriptorGenerator> authGeneratorClass = (Class<AuthDescriptorGenerator>) Class.forName(authGeneratorClassName); AuthDescriptorGenerator authDescriptorGenerator = authGeneratorClass.newInstance(); builder.setAuthDescriptor(authDescriptorGenerator.generate(properties)); } catch (ClassNotFoundException e) { throw new IllegalArgumentException(authGeneratorClassName + " does not exists.", e); } catch (InstantiationException e) { throw new IllegalArgumentException(authGeneratorClassName + " class can not be instanticated", e); } catch (IllegalAccessException e) { throw new IllegalArgumentException(authGeneratorClassName + " class can not be instanticated", e); } String authWaitTimeMillis = properties.getProperty(AUTH_WAIT_TIME_MILLIS_PROPERTY_KEY, String.valueOf(DEFAULT_AUTH_WAIT_TIME_MILLIS)); builder.setAuthWaitTime(Long.parseLong(authWaitTimeMillis)); }  void setMemcachedClient(MemcachedClientIF memcachedClient); void setCacheKeyPrefix(String cacheKeyPrefix); @Override void init(OverridableReadOnlyProperties properties); @Override void destroy(); @Override Object get(CacheNamespace cacheNamespace, String key); @Override void set(CacheNamespace cacheNamespace, String key, Object value, int expirySeconds); @Override void delete(CacheNamespace cacheNamespace, String key); @Override long increaseCounter(CacheNamespace cacheNamespace, String key, long by, long defaultValue, int expirySeconds); @Override long getCounter(CacheNamespace cacheNamespace, String key, long defaultValue, int expirySeconds); @Override void evictAll(CacheNamespace cacheNamespace); static final String PROPERTY_KEY_PREFIX; static final String HOST_PROPERTY_KEY; static final String HASH_ALGORITHM_PROPERTY_KEY; static final String OPERATION_TIMEOUT_MILLIS_PROPERTY_KEY; static final String TRANSCODER_PROPERTY_KEY; static final String CACHE_KEY_PREFIX_PROPERTY_KEY; static final String AUTH_GENERATOR_PROPERTY_KEY; static final String AUTH_WAIT_TIME_MILLIS_PROPERTY_KEY; static final String NAMESPACE_NAME_SQUENCE_SEPARATOR; static final int DEFAULT_NAMESPACE_SEQUENCE_EXPIRY_SECONDS; static final long DEFAULT_AUTH_WAIT_TIME_MILLIS; }### Answer:
@Test public void authenticate_no_authentication_property() throws Exception { Properties props = new Properties(); ConnectionFactoryBuilder builder = new ConnectionFactoryBuilder(); spyMemcachedAdapter.authenticate(builder, new OverridableReadOnlyPropertiesImpl(props)); assertThat(builder.build().getAuthDescriptor()).isNull(); }
@Test public void authenticate_with_authentication_proerty() throws Exception { Properties props = new Properties(); props.setProperty(SpyMemcachedAdapter.AUTH_GENERATOR_PROPERTY_KEY, FakeAuthDescriptorGenerator.class.getName()); ConnectionFactoryBuilder builder = new ConnectionFactoryBuilder(); spyMemcachedAdapter.authenticate(builder, new OverridableReadOnlyPropertiesImpl(props)); ConnectionFactory connectionFactory = builder.build(); assertThat(connectionFactory.getAuthDescriptor().getMechs()).isEqualTo(FakeAuthDescriptorGenerator.FAKE_MECHS); assertThat(connectionFactory.getAuthWaitTime()).isEqualTo(SpyMemcachedAdapter.DEFAULT_AUTH_WAIT_TIME_MILLIS); }
@Test public void authenticate_with_authWaitTimeMillis_property() throws Exception { Properties props = new Properties(); props.setProperty(SpyMemcachedAdapter.AUTH_GENERATOR_PROPERTY_KEY, FakeAuthDescriptorGenerator.class.getName()); props.setProperty(SpyMemcachedAdapter.AUTH_WAIT_TIME_MILLIS_PROPERTY_KEY, String.valueOf(9999L)); ConnectionFactoryBuilder builder = new ConnectionFactoryBuilder(); spyMemcachedAdapter.authenticate(builder, new OverridableReadOnlyPropertiesImpl(props)); ConnectionFactory connectionFactory = builder.build(); assertThat(connectionFactory.getAuthDescriptor().getMechs()).isEqualTo(FakeAuthDescriptorGenerator.FAKE_MECHS); assertThat(connectionFactory.getAuthWaitTime()).isEqualTo(9999L); }