Unit test for ThreadLocalAuthenticationSource

This commit is contained in:
Mattias Arthursson
2007-03-01 18:46:30 +00:00
parent c4b6243995
commit 97037a89c8

View File

@@ -0,0 +1,41 @@
package org.springframework.ldap.authentication;
import junit.framework.TestCase;
public class ThreadLocalAuthenticationSourceTest extends TestCase {
private ThreadLocalAuthenticationSource tested;
protected void setUp() throws Exception {
ThreadLocalAuthenticationHolder.setPrincipal(null);
ThreadLocalAuthenticationHolder.setCredentials(null);
tested = new ThreadLocalAuthenticationSource();
}
public void testGetPrincipal() {
ThreadLocalAuthenticationHolder.setPrincipal("cn=john doe");
String result = tested.getPrincipal();
assertEquals("cn=john doe", result);
}
public void testGetPrincipal_NoDataBound() {
String result = tested.getPrincipal();
assertNull("Should be null", result);
}
public void testGetCredentials() {
ThreadLocalAuthenticationHolder.setCredentials("secret");
String result = tested.getCredentials();
assertEquals("secret", result);
}
public void testGetCredentials_NoDataBound() {
String result = tested.getCredentials();
assertNull("Should be null", result);
}
}