LdapUtils { public static void iterateAttributeValues(Attribute attribute, AttributeValueCallbackHandler callbackHandler) { Assert.notNull(attribute, "Attribute must not be null"); Assert.notNull(callbackHandler, "callbackHandler must not be null"); if (attribute instanceof Iterable) { int i = 0; for (Object obj : (Iterable) attribute) { handleAttributeValue(attribute.getID(), obj, i, callbackHandler); i++; } } else { for (int i = 0; i < attribute.size(); i++) { try { handleAttributeValue(attribute.getID(), attribute.get(i), i, callbackHandler); } catch (javax.naming.NamingException e) { throw convertLdapException(e); } } } } private  LdapUtils(); static void closeContext(DirContext context); static NamingException convertLdapException(javax.naming.NamingException ex); static Class getActualTargetClass(DirContext context); static void collectAttributeValues(Attributes attributes, String name, Collection<Object> collection); static void collectAttributeValues(
            Attributes attributes, String name, Collection<T> collection, Class<T> clazz); static void iterateAttributeValues(Attribute attribute, AttributeValueCallbackHandler callbackHandler); static String convertCompositeNameToString(
			CompositeName compositeName); static LdapName newLdapName(Name name); static LdapName newLdapName(String distinguishedName); static LdapName removeFirst(Name dn, Name pathToRemove); static LdapName prepend(Name dn, Name pathToPrepend); static LdapName emptyLdapName(); static Rdn getRdn(Name name, String key); static Object getValue(Name name, String key); static Object getValue(Name name, int index); static String getStringValue(Name name, int index); static String getStringValue(Name name, String key); static String convertBinarySidToString(byte[] sid); static byte[] convertStringSidToBinary(String string);  }
@Test public void testIterateAttributeValues() { String expectedAttributeName = "someAttribute"; BasicAttribute expectedAttribute = new BasicAttribute(expectedAttributeName); expectedAttribute.add("value1"); expectedAttribute.add("value2"); LdapUtils.iterateAttributeValues(expectedAttribute, handlerMock); verify(handlerMock).handleAttributeValue(expectedAttributeName, "value1", 0); verify(handlerMock).handleAttributeValue(expectedAttributeName, "value2", 1); }
@Test public void testIterateAttributeValuesWithEmptyAttribute() { String expectedAttributeName = "someAttribute"; BasicAttribute expectedAttribute = new BasicAttribute(expectedAttributeName); LdapUtils.iterateAttributeValues(expectedAttribute, handlerMock); }