Java Code Examples for org.apache.directory.api.ldap.model.schema.AttributeType#addName()
The following examples show how to use
org.apache.directory.api.ldap.model.schema.AttributeType#addName() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AttributeTypeRegistryTest.java From directory-ldap-api with Apache License 2.0 | 6 votes |
@Test public void testUnregister() throws LdapException { AttributeType at0 = new AttributeType( "1.1" ); at0.addName( "t", "test", "Test", "T" ); atRegistry.register( at0 ); atRegistry.unregister( "1.1" ); assertFalse( atRegistry.contains( "1.1" ) ); assertFalse( atRegistry.contains( "t" ) ); assertFalse( atRegistry.contains( "T" ) ); assertFalse( atRegistry.contains( "tEsT" ) ); try { atRegistry.getOidByName( "T" ); fail(); } catch ( LdapException ne ) { assertTrue( true ); } }
Example 2
Source File: AttributeTypeRegistryTest.java From directory-ldap-api with Apache License 2.0 | 6 votes |
@Test public void testRegister() throws LdapException { AttributeType at0 = new AttributeType( "1.1" ); at0.addName( "t", "test", "Test", "T" ); atRegistry.register( at0 ); assertTrue( atRegistry.contains( "1.1" ) ); assertTrue( atRegistry.contains( "t" ) ); assertTrue( atRegistry.contains( "T" ) ); assertTrue( atRegistry.contains( "tEsT" ) ); assertEquals( "1.1", atRegistry.getOidByName( "T" ) ); try { atRegistry.register( at0 ); fail(); } catch ( LdapException ne ) { assertTrue( true ); } }
Example 3
Source File: TestEntryUtils.java From directory-ldap-api with Apache License 2.0 | 4 votes |
static AttributeType getIA5StringAttributeType() { AttributeType attributeType = new AttributeType( "1.1" ); attributeType.addName( "1.1" ); LdapSyntax syntax = new LdapSyntax( "1.1.1", "", true ); syntax.setSyntaxChecker( new SyntaxChecker( "1.1.2" ) { /** The mandatory serialVersionUID field */ public static final long serialVersionUID = 1L; public boolean isValidSyntax( Object value ) { String trimmedValue = Strings.deepTrim( ( String )value ); return ( trimmedValue == null ) || ( trimmedValue.length() < 7 ); } } ); MatchingRule matchingRule = new MatchingRule( "1.1.2" ); matchingRule.setSyntax( syntax ); matchingRule.setLdapComparator( new LdapComparator<String>( matchingRule.getOid() ) { /** The mandatory serialVersionUID field */ 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; }
Example 4
Source File: EntryUtils.java From directory-ldap-api with Apache License 2.0 | 4 votes |
static AttributeType getIA5StringAttributeType() { AttributeType attributeType = new AttributeType( "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 ); } } ); MatchingRule matchingRule = new MatchingRule( "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; }