SEC-2690: String[]->List<String>

Use Collections rather than Arrays since Collections can be immutable.
This commit is contained in:
Rob Winch
2014-07-28 11:15:48 -05:00
parent 15c837d5de
commit 1761b29e58
6 changed files with 53 additions and 49 deletions

View File

@@ -4,7 +4,9 @@ import org.junit.Before;
import org.junit.Test;
import org.springframework.security.ldap.SpringSecurityLdapTemplate;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static org.junit.Assert.assertEquals;
@@ -20,9 +22,9 @@ public class LdapAuthorityTests {
@Before
public void setUp() {
Map<String, String[]> attributes = new HashMap<String, String[]>();
attributes.put(SpringSecurityLdapTemplate.DN_KEY, new String[]{DN});
attributes.put("mail", new String[]{"filip@ldap.test.org", "filip@ldap.test2.org"});
Map<String, List<String>> attributes = new HashMap<String, List<String>>();
attributes.put(SpringSecurityLdapTemplate.DN_KEY, Arrays.asList(DN));
attributes.put("mail", Arrays.asList("filip@ldap.test.org", "filip@ldap.test2.org"));
authority = new LdapAuthority("testRole", DN, attributes);
}
@@ -30,7 +32,7 @@ public class LdapAuthorityTests {
public void testGetDn() throws Exception {
assertEquals(DN, authority.getDn());
assertNotNull(authority.getAttributeValues(SpringSecurityLdapTemplate.DN_KEY));
assertEquals(1, authority.getAttributeValues(SpringSecurityLdapTemplate.DN_KEY).length);
assertEquals(1, authority.getAttributeValues(SpringSecurityLdapTemplate.DN_KEY).size());
assertEquals(DN, authority.getFirstAttributeValue(SpringSecurityLdapTemplate.DN_KEY));
}
@@ -38,10 +40,10 @@ public class LdapAuthorityTests {
public void testGetAttributes() throws Exception {
assertNotNull(authority.getAttributes());
assertNotNull(authority.getAttributeValues("mail"));
assertEquals(2, authority.getAttributeValues("mail").length);
assertEquals(2, authority.getAttributeValues("mail").size());
assertEquals("filip@ldap.test.org", authority.getFirstAttributeValue("mail"));
assertEquals("filip@ldap.test.org", authority.getAttributeValues("mail")[0]);
assertEquals("filip@ldap.test2.org", authority.getAttributeValues("mail")[1]);
assertEquals("filip@ldap.test.org", authority.getAttributeValues("mail").get(0));
assertEquals("filip@ldap.test2.org", authority.getAttributeValues("mail").get(1));
}
@Test