final Subject playerSubject = new Subject();
playerSubject.getPrincipals().addAll(playerPrincipals);
MockControl playerControl = MockControl.createControl(Player.class);
final Player mockPlayer = (Player) playerControl.getMock();
mockPlayer.getSubject();
playerControl.setDefaultReturnValue(playerSubject);
mockPlayer.setSubject(mockSubject);
playerControl.setDefaultVoidCallable();
mockPlayer.setSubject(mockSubject);
playerControl.setDefaultVoidCallable();
mockPlayer.setPlayerCredentials(mockCredentials);
playerControl.setDefaultVoidCallable();
playerControl.replay();
MudLoginModule mockMod = new MudLoginModule() {
@Override
public char[] getPassword() {
// TODO Auto-generated method stub
return password.toCharArray();
}
@Override
public Set<Principal> getPlayerPrincipals() {
// TODO Auto-generated method stub
return playerPrincipals;
}
@Override
public Subject getSubject() {
// TODO Auto-generated method stub
return mockSubject;
}
protected void cleanup() {
assertTrue(hasSucceeded());
cleanupCalled = true;
}
@Override
public String getUsername() {
// TODO Auto-generated method stub
return username;
}
@Override
public Player getPlayer() {
// TODO Auto-generated method stub
return mockPlayer;
}
};
mockMod.setSucceeded(true);
mockMod.commit();
mockPlayer.getSubject().getPrincipals().contains(playerPrincipal);
mockPlayer.getSubject().getPrincipals().contains(new MudPrincipal("player"));
mockPlayer.getSubject().getPrincipals().contains(new MudPrincipal("guest"));
assertTrue(mockMod.hasCommitSucceeded());
playerControl.verify();
}