### Question:
CredentialProviderToken extends PasswordToken { @Override public void init(Properties properties) { char[] nameCharArray = properties.get(NAME_PROPERTY), credentialProvidersCharArray = properties.get(CREDENTIAL_PROVIDERS_PROPERTY); if (nameCharArray != null && credentialProvidersCharArray != null) { try { this.setWithCredentialProviders(new String(nameCharArray), new String(credentialProvidersCharArray)); } catch (IOException e) { throw new IllegalArgumentException("Could not extract password from CredentialProvider", e); } return; } throw new IllegalArgumentException( "Expected " + NAME_PROPERTY + " and " + CREDENTIAL_PROVIDERS_PROPERTY + " properties."); } CredentialProviderToken();  CredentialProviderToken(String name, String credentialProviders); String getName(); String getCredentialProviders(); @Override void init(Properties properties); @Override Set<TokenProperty> getProperties(); @Override CredentialProviderToken clone(); static final String NAME_PROPERTY; }### Answer:
@Test public void testEqualityAfterInit() throws Exception { CredentialProviderToken token = new CredentialProviderToken("root.password", keystorePath); CredentialProviderToken uninitializedToken = new CredentialProviderToken(); Properties props = new Properties(); props.put(CredentialProviderToken.NAME_PROPERTY, "root.password"); props.put(CredentialProviderToken.CREDENTIAL_PROVIDERS_PROPERTY, keystorePath); uninitializedToken.init(props); assertArrayEquals(token.getPassword(), uninitializedToken.getPassword()); }
@Test(expected = IllegalArgumentException.class) public void missingProperties() { CredentialProviderToken token = new CredentialProviderToken(); token.init(new Properties()); }
@Test(expected = IllegalArgumentException.class) public void missingNameProperty() { CredentialProviderToken token = new CredentialProviderToken(); Properties props = new Properties(); props.put(CredentialProviderToken.NAME_PROPERTY, "root.password"); token.init(props); }
@Test(expected = IllegalArgumentException.class) public void missingProviderProperty() { CredentialProviderToken token = new CredentialProviderToken(); Properties props = new Properties(); props.put(CredentialProviderToken.CREDENTIAL_PROVIDERS_PROPERTY, keystorePath); token.init(props); }