use of org.apache.directory.api.ldap.model.schema.MatchingRule in project directory-ldap-api by apache.
the class MatchingRuleTest method testIntegerMatch.
@Test
public void testIntegerMatch() throws Exception {
MatchingRule mr1 = schemaManager.lookupMatchingRuleRegistry("integerMatch");
assertEquals(NumericNormalizer.class.getName(), mr1.getNormalizer().getClass().getName());
assertEquals("1234567890", mr1.getNormalizer().normalize(" 1 234 567 890 "));
// assertEquals( IntegerComparator.class.getName(), mr1.getLdapComparator().getClass().getName() );
// assertEquals( 0, mr1.getLdapComparator().compare( " 1 234 567 890 ", "1234567890" ) );
MatchingRule mr2 = schemaManager.lookupMatchingRuleRegistry("integerOrderingMatch");
assertEquals(NumericNormalizer.class.getName(), mr2.getNormalizer().getClass().getName());
assertEquals("1234567890", mr2.getNormalizer().normalize(" 1 234 567 890 "));
assertEquals(IntegerComparator.class.getName(), mr2.getLdapComparator().getClass().getName());
assertEquals(0, mr2.getLdapComparator().compare(1234567890L, 1234567890L));
assertTrue(mr2.getLdapComparator().compare(123L, 234L) < 0);
assertTrue(mr2.getLdapComparator().compare(1234L, 234L) > 0);
// test a real attribute type: uidNumber
AttributeType at = schemaManager.lookupAttributeTypeRegistry("uidNumber");
assertNotNull(at.getEquality());
assertEquals(NumericNormalizer.class.getName(), at.getEquality().getNormalizer().getClass().getName());
assertEquals("123", at.getEquality().getNormalizer().normalize(" 1 2 3 "));
// assertEquals( 0, at.getEquality().getLdapComparator().compare( " 1 2 3 ", "123" ) );
assertNull(at.getSubstring());
assertNull(at.getOrdering());
}
Aggregations