@@ -0,0 +1,2909 @@
+package org.opennms.dashboard.server;%0A%0Aimport org.acegisecurity.Authentication;%0Aimport org.acegisecurity.GrantedAuthority;%0Aimport org.acegisecurity.context.SecurityContextHolder;%0Aimport org.acegisecurity.providers.UsernamePasswordAuthenticationToken;%0Aimport org.acegisecurity.userdetails.User;%0Aimport org.acegisecurity.userdetails.UserDetails;%0Aimport org.opennms.test.ThrowableAnticipator;%0A%0Aimport junit.framework.TestCase;%0A%0Apublic class DefaultSurveillanceServiceTest extends TestCase %7B%0A    private DefaultSurveillanceService m_service;%0A%0A    @Override%0A    protected void setUp() throws Exception %7B%0A        super.setUp();%0A        %0A        m_service = new DefaultSurveillanceService();%0A        %0A        /*%0A         * Since the SecurityContext is stored in a ThreadLocal we need to%0A         * be sure to clear it after every test.%0A         */%0A        SecurityContextHolder.clearContext();%0A    %7D%0A    %0A    public void testGetUsernameWithUserDetails() %7B%0A        UserDetails details = new User(%22user%22, %22password%22, true, true, true, true, new GrantedAuthority%5B0%5D);%0A        Authentication auth = new UsernamePasswordAuthenticationToken(details, null, details.getAuthorities());%0A        SecurityContextHolder.getContext().setAuthentication(auth);%0A        %0A        String user = m_service.getUsername();%0A        assertNotNull(%22user should not be null%22, user);%0A        assertEquals(%22user name%22, details.getUsername(), user);%0A    %7D%0A    %0A    public void testGetUsernameWithStringPrincipal() %7B%0A        Authentication auth = new UsernamePasswordAuthenticationToken(%22user%22, null, new GrantedAuthority%5B0%5D);%0A        SecurityContextHolder.getContext().setAuthentication(auth);%0A        %0A        String user = m_service.getUsername();%0A        assertNotNull(%22user should not be null%22, user);%0A        assertEquals(%22user name%22, %22user%22, user);%0A    %7D%0A    %0A    public void testGetUsernameNoAuthenticationObject() %7B%0A        ThrowableAnticipator ta = new ThrowableAnticipator();%0A        ta.anticipate(new IllegalStateException(%22No Authentication object found when calling getAuthentication on our SecurityContext object%22));%0A        %0A        try %7B%0A            m_service.getUsername();%0A        %7D catch (Throwable t) %7B%0A            ta.throwableReceived(t);%0A        %7D%0A        %0A        ta.verifyAnticipated();%0A    %7D%0A    %0A    public void testGetUsernameNoPrincipalObject() %7B%0A        Authentication auth = new UsernamePasswordAuthenticationToken(null, null, new GrantedAuthority%5B0%5D);%0A        SecurityContextHolder.getContext().setAuthentication(auth);%0A        %0A        ThrowableAnticipator ta = new ThrowableAnticipator();%0A        ta.anticipate(new IllegalStateException(%22No principal object found when calling getPrinticpal on our Authentication object%22));%0A        %0A        try %7B%0A            m_service.getUsername();%0A        %7D catch (Throwable t) %7B%0A            ta.throwableReceived(t);%0A        %7D%0A        %0A        ta.verifyAnticipated();%0A    %7D%0A%7D%0A

Add some tests for getting he user's username for the DefaultSurveillanceService