@Test
public void testProcessAuthorizedClientIds() throws Exception {

    OAuthCertBoundJwtAccessTokenAuthority authority = new OAuthCertBoundJwtAccessTokenAuthority();
    Method processAuthorizedClientIds = authority.getClass().getDeclaredMethod("processAuthorizedClientIds", String.class, Map.class, Map.class);
    processAuthorizedClientIds.setAccessible(true);
    Map<String, Set<String>> authorizedClientIds = new HashMap<>();
    Map<String, String> authorizedServices = new HashMap<>();
    // empty args
    authorizedClientIds.clear();
    authorizedServices.clear();
    processAuthorizedClientIds.invoke(authority, null, authorizedClientIds, authorizedServices);
    assertEquals(authorizedClientIds.size(), 0);
    assertEquals(authorizedServices.size(), 0);
    authorizedClientIds.clear();
    authorizedServices.clear();
    processAuthorizedClientIds.invoke(authority, "", authorizedClientIds, authorizedServices);
    assertEquals(authorizedClientIds.size(), 0);
    assertEquals(authorizedServices.size(), 0);
    // no such file
    String non_existing_filepath = this.classLoader.getResource("authorized_client_ids.empty.txt").toURI().resolve("./authorized_client_ids.non_existing.txt").getPath();
    authorizedClientIds.clear();
    authorizedServices.clear();
    processAuthorizedClientIds.invoke(authority, non_existing_filepath, authorizedClientIds, authorizedServices);
    assertEquals(authorizedClientIds.size(), 0);
    assertEquals(authorizedServices.size(), 0);
    // empty file
    authorizedClientIds.clear();
    authorizedServices.clear();
    processAuthorizedClientIds.invoke(authority, this.classLoader.getResource("authorized_client_ids.empty.txt").getPath(), authorizedClientIds, authorizedServices);
    assertEquals(authorizedClientIds.size(), 0);
    assertEquals(authorizedServices.size(), 0);
    // authorized_client_ids.txt
    authorizedClientIds.clear();
    authorizedServices.clear();
    Map<String, Set<String>> expectedAuthorizedClientIds = new HashMap<>();
    Map<String, String> expectedAuthorizedServices = new HashMap<>();
    expectedAuthorizedClientIds.put("ui_principal_11", new HashSet<>(Arrays.asList(new String[]{"client_id_11","client_id_12"})));
    expectedAuthorizedServices.put("ui_principal_11", "authorized_service_11");
    expectedAuthorizedClientIds.put("ui_principal_21", new HashSet<>(Arrays.asList(new String[]{"client_id_21"})));
    expectedAuthorizedServices.put("ui_principal_21", "authorized_service_21");
    expectedAuthorizedClientIds.put("ui_principal_31", new HashSet<>(Arrays.asList(new String[]{"client_id_31"})));
    expectedAuthorizedServices.put("ui_principal_31", "authorized_service_31");
    expectedAuthorizedClientIds.put("ui_principal_41", new HashSet<>(Arrays.asList(new String[]{"client_id_41","trailing_comma"})));
    expectedAuthorizedServices.put("ui_principal_41", "authorized_service_41");
    processAuthorizedClientIds.invoke(authority, this.classLoader.getResource("authorized_client_ids.txt").getPath(), authorizedClientIds, authorizedServices);
    assertEquals(authorizedClientIds, expectedAuthorizedClientIds);
    assertEquals(authorizedServices, expectedAuthorizedServices);
}