@Test
public void testAuthenticateWithFailedAuthenticationShouldFail() throws Exception {

	when(contextSourceMock.getReadOnlyContext()).thenReturn(dirContextMock);
	Object expectedObject = new DirContextAdapter(new BasicAttributes(), LdapUtils.newLdapName("cn=john doe"),
               LdapUtils.newLdapName("dc=jayway, dc=se"));
	SearchResult searchResult = new SearchResult("", expectedObject, new BasicAttributes());
	singleSearchResult(searchControlsRecursive(), searchResult);
	when(contextSourceMock.getContext("cn=john doe,dc=jayway,dc=se", "password"))
               .thenThrow(new UncategorizedLdapException("Authentication failed"));
	boolean result = tested.authenticate(nameMock, "(ou=somevalue)", "password", entryContextCallbackMock);
       verify(dirContextMock).close();
       assertThat(result).isFalse();
}