public final void testGetGrantedAuthoritiesToUpperCase() { String[] roles = {"Role1", "Role2"}; String[] expectedGas = {"ROLE1", "ROLE2"}; SimpleAttributes2GrantedAuthoritiesMapper mapper = getDefaultMapper(); mapper.setConvertAttributeToUpperCase(true); testGetGrantedAuthorities(mapper, roles, expectedGas); }
public final void testGetGrantedAuthoritiesCombination1() { String[] roles = {"Role1", "Role2", "role_Role3"}; String[] expectedGas = {"ROLE_ROLE1", "ROLE_ROLE2", "ROLE_ROLE3"}; SimpleAttributes2GrantedAuthoritiesMapper mapper = getDefaultMapper(); mapper.setAddPrefixIfAlreadyExisting(false); mapper.setConvertAttributeToUpperCase(true); mapper.setAttributePrefix("ROLE_"); testGetGrantedAuthorities(mapper, roles, expectedGas); }
private SimpleAttributes2GrantedAuthoritiesMapper getDefaultMapper() { SimpleAttributes2GrantedAuthoritiesMapper mapper = new SimpleAttributes2GrantedAuthoritiesMapper(); mapper.setAttributePrefix(""); mapper.setConvertAttributeToLowerCase(false); mapper.setConvertAttributeToUpperCase(false); mapper.setAddPrefixIfAlreadyExisting(false); return mapper; }
public final void testAfterPropertiesSetConvertToUpperAndLowerCase() { SimpleAttributes2GrantedAuthoritiesMapper mapper = new SimpleAttributes2GrantedAuthoritiesMapper(); mapper.setConvertAttributeToLowerCase(true); mapper.setConvertAttributeToUpperCase(true); try { mapper.afterPropertiesSet(); fail("Expected exception not thrown"); } catch (IllegalArgumentException expected) { } catch (Exception unexpected) { fail("Unexpected exception: " + unexpected); } }