diff --git a/sandbox/src/test/java/org/springframework/ldap/authentication/ThreadLocalAuthenticationSourceTest.java b/sandbox/src/test/java/org/springframework/ldap/authentication/ThreadLocalAuthenticationSourceTest.java new file mode 100644 index 00000000..ab092983 --- /dev/null +++ b/sandbox/src/test/java/org/springframework/ldap/authentication/ThreadLocalAuthenticationSourceTest.java @@ -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); + } +}