public class TestingAuthenticationProviderTests extends TestCase {
public void testAuthenticates() {
TestingAuthenticationProvider provider = new TestingAuthenticationProvider();
TestingAuthenticationToken token = new TestingAuthenticationToken("Test", "Password","ROLE_ONE","ROLE_TWO");
Authentication result = provider.authenticate(token);
assertTrue(result instanceof TestingAuthenticationToken);
TestingAuthenticationToken castResult = (TestingAuthenticationToken) result;
assertEquals("Test", castResult.getPrincipal());