Search in sources :

Example 1 with DeepTrimToLowerNormalizer

use of org.apache.directory.api.ldap.model.schema.normalizers.DeepTrimToLowerNormalizer in project directory-ldap-api by apache.

the class SearchRequestSubstringTest method setUp.

@BeforeClass
public static void setUp() throws Exception {
    // DC normalizer
    OidNormalizer dcOidNormalizer = new OidNormalizer("dc", new DeepTrimToLowerNormalizer(SchemaConstants.DOMAIN_COMPONENT_AT_OID));
    oids.put("dc", dcOidNormalizer);
    oids.put("domaincomponent", dcOidNormalizer);
    oids.put("0.9.2342.19200300.100.1.25", dcOidNormalizer);
    // OU normalizer
    OidNormalizer ouOidNormalizer = new OidNormalizer("ou", new DeepTrimToLowerNormalizer(SchemaConstants.OU_AT_OID));
    oids.put("ou", ouOidNormalizer);
    oids.put("organizationalUnitName", ouOidNormalizer);
    oids.put("2.5.4.11", ouOidNormalizer);
    // ObjectClass normalizer
    OidNormalizer objectClassOidNormalizer = new OidNormalizer("objectClass", new DeepTrimToLowerNormalizer(SchemaConstants.OBJECT_CLASS_AT_OID));
    oids.put("objectclass", objectClassOidNormalizer);
    oids.put("2.5.4.0", objectClassOidNormalizer);
}
Also used : DeepTrimToLowerNormalizer(org.apache.directory.api.ldap.model.schema.normalizers.DeepTrimToLowerNormalizer) OidNormalizer(org.apache.directory.api.ldap.model.schema.normalizers.OidNormalizer) BeforeClass(org.junit.BeforeClass)

Example 2 with DeepTrimToLowerNormalizer

use of org.apache.directory.api.ldap.model.schema.normalizers.DeepTrimToLowerNormalizer in project directory-ldap-api by apache.

the class SearchRequestTest method setUp.

@Before
public void setUp() throws Exception {
    // DC normalizer
    OidNormalizer dcOidNormalizer = new OidNormalizer("dc", new DeepTrimToLowerNormalizer(SchemaConstants.DOMAIN_COMPONENT_AT_OID));
    oids.put("dc", dcOidNormalizer);
    oids.put("domaincomponent", dcOidNormalizer);
    oids.put("0.9.2342.19200300.100.1.25", dcOidNormalizer);
    // OU normalizer
    OidNormalizer ouOidNormalizer = new OidNormalizer("ou", new DeepTrimToLowerNormalizer(SchemaConstants.OU_AT_OID));
    oids.put("ou", ouOidNormalizer);
    oids.put("organizationalUnitName", ouOidNormalizer);
    oids.put("2.5.4.11", ouOidNormalizer);
    // ObjectClass normalizer
    OidNormalizer objectClassOidNormalizer = new OidNormalizer("objectClass", new DeepTrimToLowerNormalizer(SchemaConstants.OBJECT_CLASS_AT_OID));
    oids.put("objectclass", objectClassOidNormalizer);
    oids.put("2.5.4.0", objectClassOidNormalizer);
}
Also used : DeepTrimToLowerNormalizer(org.apache.directory.api.ldap.model.schema.normalizers.DeepTrimToLowerNormalizer) OidNormalizer(org.apache.directory.api.ldap.model.schema.normalizers.OidNormalizer) Before(org.junit.Before)

Example 3 with DeepTrimToLowerNormalizer

use of org.apache.directory.api.ldap.model.schema.normalizers.DeepTrimToLowerNormalizer in project directory-ldap-api by apache.

the class SearchRequestMatchingRuleAssertionTest method setUp.

@BeforeClass
public static void setUp() throws Exception {
    // DC normalizer
    OidNormalizer dcOidNormalizer = new OidNormalizer("dc", new DeepTrimToLowerNormalizer(SchemaConstants.DOMAIN_COMPONENT_AT_OID));
    oids.put("dc", dcOidNormalizer);
    oids.put("domaincomponent", dcOidNormalizer);
    oids.put("0.9.2342.19200300.100.1.25", dcOidNormalizer);
    // OU normalizer
    OidNormalizer ouOidNormalizer = new OidNormalizer("ou", new DeepTrimToLowerNormalizer(SchemaConstants.OU_AT_OID));
    oids.put("ou", ouOidNormalizer);
    oids.put("organizationalUnitName", ouOidNormalizer);
    oids.put("2.5.4.11", ouOidNormalizer);
    // ObjectClass normalizer
    OidNormalizer objectClassOidNormalizer = new OidNormalizer("objectClass", new DeepTrimToLowerNormalizer(SchemaConstants.OBJECT_CLASS_AT_OID));
    oids.put("objectclass", objectClassOidNormalizer);
    oids.put("2.5.4.0", objectClassOidNormalizer);
}
Also used : DeepTrimToLowerNormalizer(org.apache.directory.api.ldap.model.schema.normalizers.DeepTrimToLowerNormalizer) OidNormalizer(org.apache.directory.api.ldap.model.schema.normalizers.OidNormalizer) BeforeClass(org.junit.BeforeClass)

Example 4 with DeepTrimToLowerNormalizer

use of org.apache.directory.api.ldap.model.schema.normalizers.DeepTrimToLowerNormalizer in project directory-ldap-api by apache.

the class EntryUtils method getIA5StringAttributeType.

/* no protection*/
static AttributeType getIA5StringAttributeType() {
    MutableAttributeType attributeType = new MutableAttributeType("1.1");
    attributeType.addName("1.1");
    LdapSyntax syntax = new LdapSyntax("1.1.1", "", true);
    syntax.setSyntaxChecker(new SyntaxChecker("1.1.2") {

        public static final long serialVersionUID = 1L;

        public boolean isValidSyntax(Object value) {
            String strValue = Strings.deepTrim((String) value);
            return (strValue == null) || (strValue.length() < 7);
        }
    });
    MutableMatchingRule matchingRule = new MutableMatchingRule("1.1.2");
    matchingRule.setSyntax(syntax);
    matchingRule.setLdapComparator(new LdapComparator<String>(matchingRule.getOid()) {

        public static final long serialVersionUID = 1L;

        public int compare(String o1, String o2) {
            return ((o1 == null) ? (o2 == null ? 0 : -1) : (o2 == null ? 1 : o1.compareTo(o2)));
        }
    });
    matchingRule.setNormalizer(new DeepTrimToLowerNormalizer(matchingRule.getOid()));
    attributeType.setEquality(matchingRule);
    attributeType.setSyntax(syntax);
    return attributeType;
}
Also used : MutableMatchingRule(org.apache.directory.api.ldap.model.schema.MutableMatchingRule) SyntaxChecker(org.apache.directory.api.ldap.model.schema.SyntaxChecker) DeepTrimToLowerNormalizer(org.apache.directory.api.ldap.model.schema.normalizers.DeepTrimToLowerNormalizer) LdapSyntax(org.apache.directory.api.ldap.model.schema.LdapSyntax) PrepareString(org.apache.directory.api.ldap.model.schema.PrepareString) MutableAttributeType(org.apache.directory.api.ldap.model.schema.MutableAttributeType)

Example 5 with DeepTrimToLowerNormalizer

use of org.apache.directory.api.ldap.model.schema.normalizers.DeepTrimToLowerNormalizer in project directory-ldap-api by apache.

the class DeepTrimToLowerNormalizerTest method testSpeed.

@Test
@Ignore
public void testSpeed() throws Exception {
    Normalizer normalizer = new DeepTrimToLowerNormalizer();
    String t = "xs crvtbynU  Jikl7897A90";
    normalizer.normalize(t);
    long t0 = System.currentTimeMillis();
    for (int i = 0; i < 100000000; i++) {
        normalizer.normalize(t);
    }
    long t1 = System.currentTimeMillis();
    System.out.println(t1 - t0);
    Strings.deepTrimToLower(t);
    t0 = System.currentTimeMillis();
    for (int i = 0; i < 100000000; i++) {
        Strings.deepTrimToLower(t);
    }
    t1 = System.currentTimeMillis();
    System.out.println(t1 - t0);
}
Also used : DeepTrimToLowerNormalizer(org.apache.directory.api.ldap.model.schema.normalizers.DeepTrimToLowerNormalizer) DeepTrimToLowerNormalizer(org.apache.directory.api.ldap.model.schema.normalizers.DeepTrimToLowerNormalizer) Normalizer(org.apache.directory.api.ldap.model.schema.Normalizer) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

DeepTrimToLowerNormalizer (org.apache.directory.api.ldap.model.schema.normalizers.DeepTrimToLowerNormalizer)24 Normalizer (org.apache.directory.api.ldap.model.schema.Normalizer)17 Test (org.junit.Test)16 PrepareString (org.apache.directory.api.ldap.model.schema.PrepareString)3 StringComparator (org.apache.directory.api.ldap.model.schema.comparators.StringComparator)3 OidNormalizer (org.apache.directory.api.ldap.model.schema.normalizers.OidNormalizer)3 Before (org.junit.Before)3 BeforeClass (org.junit.BeforeClass)3 LdapSyntax (org.apache.directory.api.ldap.model.schema.LdapSyntax)2 MutableAttributeType (org.apache.directory.api.ldap.model.schema.MutableAttributeType)2 MutableMatchingRule (org.apache.directory.api.ldap.model.schema.MutableMatchingRule)2 SyntaxChecker (org.apache.directory.api.ldap.model.schema.SyntaxChecker)2 LdapException (org.apache.directory.api.ldap.model.exception.LdapException)1 ByteArrayComparator (org.apache.directory.api.ldap.model.schema.comparators.ByteArrayComparator)1 Ignore (org.junit.Ignore)1