Search in sources :

Example 36 with Normalizer

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

the class DeepTrimNormalizerTest method testInsignifiantSpacesStringCharsSpaces.

@Test
public void testInsignifiantSpacesStringCharsSpaces() throws LdapException {
    Normalizer normalizer = new DeepTrimNormalizer("1.1.1");
    assertEquals(" a ", normalizer.normalize(" a"));
    assertEquals(" a ", normalizer.normalize("a "));
    assertEquals(" a ", normalizer.normalize(" a "));
    assertEquals(" a  a ", normalizer.normalize("a a"));
    assertEquals(" a  a ", normalizer.normalize(" a a"));
    assertEquals(" a  a ", normalizer.normalize("a a "));
    assertEquals(" a  a ", normalizer.normalize("a  a"));
    assertEquals(" a  a ", normalizer.normalize(" a   a "));
    assertEquals(" aaa  aaa  aaa ", normalizer.normalize("  aaa   aaa   aaa  "));
}
Also used : DeepTrimNormalizer(org.apache.directory.api.ldap.model.schema.normalizers.DeepTrimNormalizer) Normalizer(org.apache.directory.api.ldap.model.schema.Normalizer) DeepTrimNormalizer(org.apache.directory.api.ldap.model.schema.normalizers.DeepTrimNormalizer) Test(org.junit.Test)

Example 37 with Normalizer

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

the class DeepTrimNormalizerTest method testNormalizeCharsCombiningSpaces.

@Test
public void testNormalizeCharsCombiningSpaces() throws LdapException {
    Normalizer normalizer = new DeepTrimToLowerNormalizer("1.1.1");
    char[] chars = new char[] { 'a', 'm', ' ', 'e', 0x0301, 'l', 'i', 'e' };
    char[] expected = new char[] { ' ', 'a', 'm', ' ', ' ', '\u00e9', 'l', 'i', 'e', ' ' };
    String expectedStr = new String(expected);
    String charsStr = new String(chars);
    assertEquals(expectedStr, normalizer.normalize(charsStr));
}
Also used : DeepTrimNormalizer(org.apache.directory.api.ldap.model.schema.normalizers.DeepTrimNormalizer) Normalizer(org.apache.directory.api.ldap.model.schema.Normalizer) Test(org.junit.Test)

Example 38 with Normalizer

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

the class DeepTrimNormalizerTest method testInsignifiantSpacesStringTwoChars.

@Test
public void testInsignifiantSpacesStringTwoChars() throws LdapException {
    Normalizer normalizer = new DeepTrimNormalizer("1.1.1");
    assertEquals(" aa ", normalizer.normalize("aa"));
}
Also used : DeepTrimNormalizer(org.apache.directory.api.ldap.model.schema.normalizers.DeepTrimNormalizer) Normalizer(org.apache.directory.api.ldap.model.schema.Normalizer) DeepTrimNormalizer(org.apache.directory.api.ldap.model.schema.normalizers.DeepTrimNormalizer) Test(org.junit.Test)

Example 39 with Normalizer

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

the class DeepTrimNormalizerTest method testMapToSpace.

@Test
public void testMapToSpace() throws Exception {
    Normalizer normalizer = new DeepTrimNormalizer("1.1.1");
    char[] chars = new char[] { 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0085, 0x00A0, 0x1680, 0x2000, 0x2001, 0x2002, 0x2003, 0x2004, 0x2005, 0x2006, 0x2007, 0x2008, 0x2009, 0x200A, 0x2028, 0x2029, 0x202F, 0x205F };
    assertEquals("  ", normalizer.normalize(new String(chars)));
}
Also used : DeepTrimNormalizer(org.apache.directory.api.ldap.model.schema.normalizers.DeepTrimNormalizer) Normalizer(org.apache.directory.api.ldap.model.schema.Normalizer) DeepTrimNormalizer(org.apache.directory.api.ldap.model.schema.normalizers.DeepTrimNormalizer) Test(org.junit.Test)

Example 40 with Normalizer

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

the class DeepTrimNormalizerTest method testDeepTrimNormalizerNull.

@Test
public void testDeepTrimNormalizerNull() throws LdapException {
    Normalizer normalizer = new DeepTrimNormalizer("1.1.1");
    assertEquals(null, normalizer.normalize((String) null));
}
Also used : DeepTrimNormalizer(org.apache.directory.api.ldap.model.schema.normalizers.DeepTrimNormalizer) Normalizer(org.apache.directory.api.ldap.model.schema.Normalizer) DeepTrimNormalizer(org.apache.directory.api.ldap.model.schema.normalizers.DeepTrimNormalizer) Test(org.junit.Test)

Aggregations

Normalizer (org.apache.directory.api.ldap.model.schema.Normalizer)78 Test (org.junit.Test)59 DeepTrimToLowerNormalizer (org.apache.directory.api.ldap.model.schema.normalizers.DeepTrimToLowerNormalizer)20 DeepTrimNormalizer (org.apache.directory.api.ldap.model.schema.normalizers.DeepTrimNormalizer)15 TelephoneNumberNormalizer (org.apache.directory.api.ldap.model.schema.normalizers.TelephoneNumberNormalizer)12 LdapException (org.apache.directory.api.ldap.model.exception.LdapException)10 NumericNormalizer (org.apache.directory.api.ldap.model.schema.normalizers.NumericNormalizer)9 SchemaManager (org.apache.directory.api.ldap.model.schema.SchemaManager)7 NoOpNormalizer (org.apache.directory.api.ldap.model.schema.normalizers.NoOpNormalizer)7 DefaultSchemaManager (org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager)7 MutableAttributeType (org.apache.directory.api.ldap.model.schema.MutableAttributeType)6 PrepareString (org.apache.directory.api.ldap.model.schema.PrepareString)6 LdapSchemaException (org.apache.directory.api.ldap.model.exception.LdapSchemaException)5 LdapSyntax (org.apache.directory.api.ldap.model.schema.LdapSyntax)5 MatchingRule (org.apache.directory.api.ldap.model.schema.MatchingRule)5 MutableMatchingRule (org.apache.directory.api.ldap.model.schema.MutableMatchingRule)4 SyntaxChecker (org.apache.directory.api.ldap.model.schema.SyntaxChecker)4 ByteArrayComparator (org.apache.directory.api.ldap.model.schema.comparators.ByteArrayComparator)4 BooleanNormalizer (org.apache.directory.api.ldap.model.schema.normalizers.BooleanNormalizer)4 LdapProtocolErrorException (org.apache.directory.api.ldap.model.exception.LdapProtocolErrorException)3