@Test
public void testAddCredential() throws IOException {

    User user1 = Mockito.mock(User.class);
    Dictionary<String, Object> credentials = new Hashtable<String, Object>();
    Mockito.when(userAdmin.getRole("user1")).thenReturn(user1);
    Mockito.when(user1.getType()).thenReturn(Role.USER);
    Mockito.when(user1.getCredentials()).thenReturn(credentials);
    mbean.addCredential("password", new byte[] { 1, 2 }, "user1");
    Assert.assertArrayEquals(new byte[] { 1, 2 }, (byte[]) credentials.get("password"));
}