Java Code Examples for org.apache.directory.api.ldap.model.schema.AttributeType#setSubstringOid()

The following examples show how to use org.apache.directory.api.ldap.model.schema.AttributeType#setSubstringOid() . 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: SchemaManagerAddTest.java    From directory-ldap-api with Apache License 2.0 6 votes vote down vote up
/**
 * Try to inject an AttributeType without any superior nor Syntax : it's invalid
 */
@Test
public void testAddAttributeTypeNoSupNoSyntaxNoSuperior() throws Exception
{
    SchemaManager schemaManager = loadSystem();
    int atrSize = schemaManager.getAttributeTypeRegistry().size();
    int goidSize = schemaManager.getGlobalOidRegistry().size();

    AttributeType attributeType = new AttributeType( "1.1.0" );
    attributeType.setEqualityOid( SchemaConstants.DISTINGUISHED_NAME_MATCH_MR_OID );
    attributeType.setOrderingOid( null );
    attributeType.setSubstringOid( null );

    // It should fail
    assertFalse( schemaManager.add( attributeType ) );

    List<Throwable> errors = schemaManager.getErrors();
    assertEquals( 1, errors.size() );
    Throwable error = errors.get( 0 );

    assertTrue( error instanceof LdapSchemaException );

    assertFalse( isATPresent( schemaManager, "1.1.0" ) );
    assertEquals( atrSize, schemaManager.getAttributeTypeRegistry().size() );
    assertEquals( goidSize, schemaManager.getGlobalOidRegistry().size() );
}
 
Example 2
Source File: SchemaManagerAddTest.java    From directory-ldap-api with Apache License 2.0 6 votes vote down vote up
/**
 * Try to inject an AttributeType which is Collective, and userApplication AT
 */
@Test
public void testAddAttributeTypeNoSupCollectiveUser() throws Exception
{
    SchemaManager schemaManager = loadSystem();
    int atrSize = schemaManager.getAttributeTypeRegistry().size();
    int goidSize = schemaManager.getGlobalOidRegistry().size();

    AttributeType attributeType = new AttributeType( "1.1.0" );
    attributeType.setEqualityOid( SchemaConstants.DISTINGUISHED_NAME_MATCH_MR_OID );
    attributeType.setOrderingOid( null );
    attributeType.setSubstringOid( null );
    attributeType.setSyntaxOid( "1.3.6.1.4.1.1466.115.121.1.26" );
    attributeType.setUsage( UsageEnum.USER_APPLICATIONS );
    attributeType.setCollective( true );

    // It should not fail
    assertTrue( schemaManager.add( attributeType ) );

    assertTrue( isATPresent( schemaManager, "1.1.0" ) );
    assertEquals( atrSize + 1, schemaManager.getAttributeTypeRegistry().size() );
    assertEquals( goidSize + 1, schemaManager.getGlobalOidRegistry().size() );
}
 
Example 3
Source File: SchemaManagerDelTest.java    From directory-ldap-api with Apache License 2.0 6 votes vote down vote up
/**
 * Try to delete an AttributeType not existing in the schemaManager
 */
@Test
public void testDeleteNonExistingAttributeType() throws Exception
{
    SchemaManager schemaManager = loadSchema( "Core" );
    int atrSize = schemaManager.getAttributeTypeRegistry().size();
    int goidSize = schemaManager.getGlobalOidRegistry().size();

    AttributeType attributeType = new AttributeType( "1.1.0" );
    attributeType.setEqualityOid( SchemaConstants.DISTINGUISHED_NAME_MATCH_MR_OID );
    attributeType.setOrderingOid( null );
    attributeType.setSubstringOid( null );

    // It should fail
    assertFalse( schemaManager.delete( attributeType ) );

    List<Throwable> errors = schemaManager.getErrors();
    assertFalse( errors.isEmpty() );

    assertEquals( atrSize, schemaManager.getAttributeTypeRegistry().size() );
    assertEquals( goidSize, schemaManager.getGlobalOidRegistry().size() );
}
 
Example 4
Source File: SchemaManagerAddTest.java    From directory-ldap-api with Apache License 2.0 6 votes vote down vote up
/**
 * Try to inject an AttributeType with a superior and no Syntax : it should
 * take its superior' syntax and MR
 */
@Test
public void testAddAttributeTypeSupNoSyntaxNoSuperior() throws Exception
{
    SchemaManager schemaManager = loadSystem();
    int atrSize = schemaManager.getAttributeTypeRegistry().size();
    int goidSize = schemaManager.getGlobalOidRegistry().size();

    AttributeType attributeType = new AttributeType( "1.1.0" );
    attributeType.setEqualityOid( null );
    attributeType.setOrderingOid( null );
    attributeType.setSubstringOid( null );
    attributeType.setSuperiorOid( "2.5.18.4" );
    attributeType.setUsage( UsageEnum.DIRECTORY_OPERATION );

    // It should not fail
    assertTrue( schemaManager.add( attributeType ) );

    AttributeType result = schemaManager.lookupAttributeTypeRegistry( "1.1.0" );

    assertEquals( "1.3.6.1.4.1.1466.115.121.1.12", result.getSyntaxOid() );
    assertEquals( SchemaConstants.DISTINGUISHED_NAME_MATCH_MR_OID, result.getEqualityOid() );
    assertEquals( atrSize + 1, schemaManager.getAttributeTypeRegistry().size() );
    assertEquals( goidSize + 1, schemaManager.getGlobalOidRegistry().size() );
}
 
Example 5
Source File: SchemaManagerAddTest.java    From directory-ldap-api with Apache License 2.0 6 votes vote down vote up
/**
 * Try to inject an AttributeType which is a NO-USER-MODIFICATION and is operational
 */
@Test
public void testAddAttributeTypeNoSupNoUserModificationOpAttr() throws Exception
{
    SchemaManager schemaManager = loadSystem();
    int atrSize = schemaManager.getAttributeTypeRegistry().size();
    int goidSize = schemaManager.getGlobalOidRegistry().size();

    AttributeType attributeType = new AttributeType( "1.1.0" );
    attributeType.setEqualityOid( SchemaConstants.DISTINGUISHED_NAME_MATCH_MR_OID );
    attributeType.setOrderingOid( null );
    attributeType.setSubstringOid( null );
    attributeType.setSyntaxOid( "1.3.6.1.4.1.1466.115.121.1.26" );
    attributeType.setUsage( UsageEnum.DISTRIBUTED_OPERATION );
    attributeType.setUserModifiable( false );

    // It should not fail
    assertTrue( schemaManager.add( attributeType ) );

    assertTrue( isATPresent( schemaManager, "1.1.0" ) );
    assertEquals( atrSize + 1, schemaManager.getAttributeTypeRegistry().size() );
    assertEquals( goidSize + 1, schemaManager.getGlobalOidRegistry().size() );
}
 
Example 6
Source File: SchemaManagerAddTest.java    From directory-ldap-api with Apache License 2.0 6 votes vote down vote up
/**
 * Try to inject an AttributeType with valid MRs
 */
@Test
public void testAddAttributeTypeNoSupValidMR() throws Exception
{
    SchemaManager schemaManager = loadSystem();
    int atrSize = schemaManager.getAttributeTypeRegistry().size();
    int goidSize = schemaManager.getGlobalOidRegistry().size();

    AttributeType attributeType = new AttributeType( "1.1.0" );
    attributeType.setEqualityOid( SchemaConstants.DISTINGUISHED_NAME_MATCH_MR_OID );
    attributeType.setOrderingOid( SchemaConstants.DISTINGUISHED_NAME_MATCH_MR_OID );
    attributeType.setSubstringOid( SchemaConstants.DISTINGUISHED_NAME_MATCH_MR_OID );
    attributeType.setSyntaxOid( "1.3.6.1.4.1.1466.115.121.1.26" );
    attributeType.setUsage( UsageEnum.USER_APPLICATIONS );

    // It should not fail
    assertTrue( schemaManager.add( attributeType ) );

    assertTrue( isATPresent( schemaManager, "1.1.0" ) );
    assertEquals( atrSize + 1, schemaManager.getAttributeTypeRegistry().size() );
    assertEquals( goidSize + 1, schemaManager.getGlobalOidRegistry().size() );
}
 
Example 7
Source File: SchemaManagerAddTest.java    From directory-ldap-api with Apache License 2.0 5 votes vote down vote up
/**
 * Try to inject an AttributeType with a bad superior
 */
@Test
public void testAddAttributeTypeSupBadSup() throws Exception
{
    SchemaManager schemaManager = loadSystem();
    int atrSize = schemaManager.getAttributeTypeRegistry().size();
    int goidSize = schemaManager.getGlobalOidRegistry().size();

    AttributeType attributeType = new AttributeType( "1.1.0" );
    attributeType.setEqualityOid( null );
    attributeType.setOrderingOid( null );
    attributeType.setSubstringOid( null );
    attributeType.setSuperiorOid( "0.0" );
    attributeType.setUsage( UsageEnum.DISTRIBUTED_OPERATION );

    // It should fail
    assertFalse( schemaManager.add( attributeType ) );

    List<Throwable> errors = schemaManager.getErrors();
    assertEquals( 1, errors.size() );
    Throwable error = errors.get( 0 );

    assertTrue( error instanceof LdapSchemaException );

    assertFalse( isATPresent( schemaManager, "1.1.0" ) );
    assertEquals( atrSize, schemaManager.getAttributeTypeRegistry().size() );
    assertEquals( goidSize, schemaManager.getGlobalOidRegistry().size() );
}
 
Example 8
Source File: SchemaManagerAddTest.java    From directory-ldap-api with Apache License 2.0 5 votes vote down vote up
/**
 * Try to inject an AttributeType with itself as a superior
 */
@Test
public void testAddAttributeTypeSupWithOwnSup() throws Exception
{
    SchemaManager schemaManager = loadSystem();
    int atrSize = schemaManager.getAttributeTypeRegistry().size();
    int goidSize = schemaManager.getGlobalOidRegistry().size();

    AttributeType attributeType = new AttributeType( "1.1.0" );
    attributeType.setEqualityOid( null );
    attributeType.setOrderingOid( null );
    attributeType.setSubstringOid( null );
    attributeType.setSuperiorOid( "1.1.0" );
    attributeType.setUsage( UsageEnum.DISTRIBUTED_OPERATION );

    // It should fail
    assertFalse( schemaManager.add( attributeType ) );

    List<Throwable> errors = schemaManager.getErrors();
    assertEquals( 1, errors.size() );
    Throwable error = errors.get( 0 );

    assertTrue( error instanceof LdapSchemaException );

    assertFalse( isATPresent( schemaManager, "1.1.0" ) );
    assertEquals( atrSize, schemaManager.getAttributeTypeRegistry().size() );
    assertEquals( goidSize, schemaManager.getGlobalOidRegistry().size() );
}
 
Example 9
Source File: SchemaManagerAddTest.java    From directory-ldap-api with Apache License 2.0 5 votes vote down vote up
/**
 * Try to inject an AttributeType with a superior and different USAGE
 */
@Test
public void testAddAttributeTypeSupDifferentUsage() throws Exception
{
    SchemaManager schemaManager = loadSystem();
    int atrSize = schemaManager.getAttributeTypeRegistry().size();
    int goidSize = schemaManager.getGlobalOidRegistry().size();

    AttributeType attributeType = new AttributeType( "1.1.0" );
    attributeType.setEqualityOid( null );
    attributeType.setOrderingOid( null );
    attributeType.setSubstringOid( null );
    attributeType.setSuperiorOid( "2.5.18.4" );
    attributeType.setUsage( UsageEnum.DISTRIBUTED_OPERATION );

    // It should fail
    assertFalse( schemaManager.add( attributeType ) );

    List<Throwable> errors = schemaManager.getErrors();
    assertEquals( 1, errors.size() );
    Throwable error = errors.get( 0 );

    assertTrue( error instanceof LdapSchemaException );

    assertFalse( isATPresent( schemaManager, "1.1.0" ) );
    assertEquals( atrSize, schemaManager.getAttributeTypeRegistry().size() );
    assertEquals( goidSize, schemaManager.getGlobalOidRegistry().size() );
}
 
Example 10
Source File: SchemaManagerAddTest.java    From directory-ldap-api with Apache License 2.0 5 votes vote down vote up
/**
 * Try to inject an AttributeType with an ObjectClass name
 */
@Test
public void testAddAttributeTypeNameOfAnObjectClass() throws Exception
{
    SchemaManager schemaManager = loadSystem();
    int atrSize = schemaManager.getAttributeTypeRegistry().size();
    int goidSize = schemaManager.getGlobalOidRegistry().size();

    AttributeType attributeType = new AttributeType( "1.1.1.0" );
    attributeType.setEqualityOid( SchemaConstants.DISTINGUISHED_NAME_MATCH_MR_OID );
    attributeType.setOrderingOid( SchemaConstants.DISTINGUISHED_NAME_MATCH_MR_OID );
    attributeType.setSubstringOid( SchemaConstants.DISTINGUISHED_NAME_MATCH_MR_OID );
    attributeType.setSyntaxOid( "1.3.6.1.4.1.1466.115.121.1.26" );
    attributeType.setNames( "Test", "referral" );

    // It should be ok
    assertTrue( schemaManager.add( attributeType ) );

    List<Throwable> errors = schemaManager.getErrors();
    assertEquals( 0, errors.size() );

    // The AT must be present
    assertTrue( isATPresent( schemaManager, "1.1.1.0" ) );

    assertEquals( atrSize + 1, schemaManager.getAttributeTypeRegistry().size() );
    assertEquals( goidSize + 1, schemaManager.getGlobalOidRegistry().size() );

    AttributeType added = schemaManager.lookupAttributeTypeRegistry( "referral" );
    assertNotNull( added );
    assertEquals( "1.1.1.0", added.getOid() );
    assertTrue( added.getNames().contains( "referral" ) );
}
 
Example 11
Source File: SchemaManagerAddTest.java    From directory-ldap-api with Apache License 2.0 5 votes vote down vote up
/**
 * Try to inject an AttributeType with an already attributed name
 */
@Test
public void testAddAttributeTypeNameAlreadyExist() throws Exception
{
    SchemaManager schemaManager = loadSystem();
    int atrSize = schemaManager.getAttributeTypeRegistry().size();
    int goidSize = schemaManager.getGlobalOidRegistry().size();

    AttributeType attributeType = new AttributeType( "1.1.1.0" );
    attributeType.setEqualityOid( SchemaConstants.DISTINGUISHED_NAME_MATCH_MR_OID );
    attributeType.setOrderingOid( SchemaConstants.DISTINGUISHED_NAME_MATCH_MR_OID );
    attributeType.setSubstringOid( SchemaConstants.DISTINGUISHED_NAME_MATCH_MR_OID );
    attributeType.setSyntaxOid( "1.3.6.1.4.1.1466.115.121.1.26" );
    attributeType.setNames( "Test", "cn" );

    // It should fail
    assertFalse( schemaManager.add( attributeType ) );

    List<Throwable> errors = schemaManager.getErrors();
    assertEquals( 1, errors.size() );
    Throwable error = errors.get( 0 );

    assertTrue( error instanceof LdapSchemaException );

    // The AT must not be there
    assertFalse( isATPresent( schemaManager, "1.1.1.0" ) );

    assertEquals( atrSize, schemaManager.getAttributeTypeRegistry().size() );
    assertEquals( goidSize, schemaManager.getGlobalOidRegistry().size() );
}
 
Example 12
Source File: SchemaManagerAddTest.java    From directory-ldap-api with Apache License 2.0 5 votes vote down vote up
/**
 * Try to inject an AttributeType which already exist
 */
@Test
public void testAddAttributeTypeAlreadyExist() throws Exception
{
    SchemaManager schemaManager = loadSystem();
    int atrSize = schemaManager.getAttributeTypeRegistry().size();
    int goidSize = schemaManager.getGlobalOidRegistry().size();

    AttributeType attributeType = new AttributeType( "2.5.18.4" );
    attributeType.setEqualityOid( SchemaConstants.DISTINGUISHED_NAME_MATCH_MR_OID );
    attributeType.setOrderingOid( SchemaConstants.DISTINGUISHED_NAME_MATCH_MR_OID );
    attributeType.setSubstringOid( SchemaConstants.DISTINGUISHED_NAME_MATCH_MR_OID );

    // It should fail
    assertFalse( schemaManager.add( attributeType ) );

    List<Throwable> errors = schemaManager.getErrors();
    assertEquals( 1, errors.size() );
    Throwable error = errors.get( 0 );

    assertTrue( error instanceof LdapSchemaException );

    // The AT must be there
    assertTrue( isATPresent( schemaManager, "2.5.18.4" ) );

    // Check that it hasen't changed
    AttributeType original = schemaManager.lookupAttributeTypeRegistry( "2.5.18.4" );
    assertEquals( "distinguishedNameMatch", original.getEqualityOid() );
    assertEquals( atrSize, schemaManager.getAttributeTypeRegistry().size() );
    assertEquals( goidSize, schemaManager.getGlobalOidRegistry().size() );
}
 
Example 13
Source File: SchemaManagerAddTest.java    From directory-ldap-api with Apache License 2.0 5 votes vote down vote up
/**
 * Try to inject an AttributeType with an invalid SUBSTR MR
 */
@Test
public void testAddAttributeTypeNoSupInvalidSubstringMR() throws Exception
{
    SchemaManager schemaManager = loadSystem();
    int atrSize = schemaManager.getAttributeTypeRegistry().size();
    int goidSize = schemaManager.getGlobalOidRegistry().size();

    AttributeType attributeType = new AttributeType( "1.1.0" );
    attributeType.setEqualityOid( null );
    attributeType.setOrderingOid( null );
    attributeType.setSubstringOid( "0.0" );
    attributeType.setSyntaxOid( "1.3.6.1.4.1.1466.115.121.1.26" );
    attributeType.setUsage( UsageEnum.USER_APPLICATIONS );

    // It should fail
    assertFalse( schemaManager.add( attributeType ) );

    List<Throwable> errors = schemaManager.getErrors();
    assertEquals( 1, errors.size() );
    Throwable error = errors.get( 0 );

    assertTrue( error instanceof LdapSchemaException );

    assertFalse( isATPresent( schemaManager, "1.1.0" ) );
    assertEquals( atrSize, schemaManager.getAttributeTypeRegistry().size() );
    assertEquals( goidSize, schemaManager.getGlobalOidRegistry().size() );
}
 
Example 14
Source File: SchemaManagerAddTest.java    From directory-ldap-api with Apache License 2.0 5 votes vote down vote up
/**
 * Try to inject an AttributeType with an invalid ORDERING MR
 */
@Test
public void testAddAttributeTypeNoSupInvalidOrderingMR() throws Exception
{
    SchemaManager schemaManager = loadSystem();
    int atrSize = schemaManager.getAttributeTypeRegistry().size();
    int goidSize = schemaManager.getGlobalOidRegistry().size();

    AttributeType attributeType = new AttributeType( "1.1.0" );
    attributeType.setEqualityOid( null );
    attributeType.setOrderingOid( "0.0" );
    attributeType.setSubstringOid( null );
    attributeType.setSyntaxOid( "1.3.6.1.4.1.1466.115.121.1.26" );
    attributeType.setUsage( UsageEnum.USER_APPLICATIONS );

    // It should fail
    assertFalse( schemaManager.add( attributeType ) );

    List<Throwable> errors = schemaManager.getErrors();
    assertEquals( 1, errors.size() );
    Throwable error = errors.get( 0 );

    assertTrue( error instanceof LdapSchemaException );

    assertFalse( isATPresent( schemaManager, "1.1.0" ) );
    assertEquals( atrSize, schemaManager.getAttributeTypeRegistry().size() );
    assertEquals( goidSize, schemaManager.getGlobalOidRegistry().size() );
}
 
Example 15
Source File: SchemaManagerAddTest.java    From directory-ldap-api with Apache License 2.0 5 votes vote down vote up
/**
 * Try to inject an AttributeType with an invalid EQUALITY MR
 */
@Test
public void testAddAttributeTypeNoSupInvalidEqualityMR() throws Exception
{
    SchemaManager schemaManager = loadSystem();
    int atrSize = schemaManager.getAttributeTypeRegistry().size();
    int goidSize = schemaManager.getGlobalOidRegistry().size();

    AttributeType attributeType = new AttributeType( "1.1.0" );
    attributeType.setEqualityOid( "0.0" );
    attributeType.setOrderingOid( null );
    attributeType.setSubstringOid( null );
    attributeType.setSyntaxOid( "1.3.6.1.4.1.1466.115.121.1.26" );
    attributeType.setUsage( UsageEnum.USER_APPLICATIONS );

    // It should fail
    assertFalse( schemaManager.add( attributeType ) );

    List<Throwable> errors = schemaManager.getErrors();
    assertEquals( 1, errors.size() );
    Throwable error = errors.get( 0 );

    assertTrue( error instanceof LdapSchemaException );

    assertFalse( isATPresent( schemaManager, "1.1.0" ) );
    assertEquals( atrSize, schemaManager.getAttributeTypeRegistry().size() );
    assertEquals( goidSize, schemaManager.getGlobalOidRegistry().size() );
}
 
Example 16
Source File: SchemaManagerAddTest.java    From directory-ldap-api with Apache License 2.0 5 votes vote down vote up
/**
 * Try to inject an AttributeType which is a NO-USER-MODIFICATION and userApplication
 */
@Test
public void testAddAttributeTypeNoSupNoUserModificationUserAplication() throws Exception
{
    SchemaManager schemaManager = loadSystem();
    int atrSize = schemaManager.getAttributeTypeRegistry().size();
    int goidSize = schemaManager.getGlobalOidRegistry().size();

    AttributeType attributeType = new AttributeType( "1.1.0" );
    attributeType.setEqualityOid( SchemaConstants.DISTINGUISHED_NAME_MATCH_MR_OID );
    attributeType.setOrderingOid( null );
    attributeType.setSubstringOid( null );
    attributeType.setSyntaxOid( "1.3.6.1.4.1.1466.115.121.1.26" );
    attributeType.setUsage( UsageEnum.USER_APPLICATIONS );
    attributeType.setUserModifiable( false );

    // It should fail
    assertFalse( schemaManager.add( attributeType ) );

    List<Throwable> errors = schemaManager.getErrors();
    assertEquals( 1, errors.size() );
    Throwable error = errors.get( 0 );

    assertTrue( error instanceof LdapSchemaException );

    assertFalse( isATPresent( schemaManager, "1.1.0" ) );
    assertEquals( atrSize, schemaManager.getAttributeTypeRegistry().size() );
    assertEquals( goidSize, schemaManager.getGlobalOidRegistry().size() );
}
 
Example 17
Source File: SchemaManagerAddTest.java    From directory-ldap-api with Apache License 2.0 5 votes vote down vote up
/**
 * Try to inject a single valued AttributeType which is Collective
 */
@Test
public void testAddAttributeTypeCollectiveOperationalSigleValue() throws Exception
{
    SchemaManager schemaManager = loadSystem();
    int atrSize = schemaManager.getAttributeTypeRegistry().size();
    int goidSize = schemaManager.getGlobalOidRegistry().size();

    AttributeType attributeType = new AttributeType( "1.1.0" );
    attributeType.setEqualityOid( SchemaConstants.DISTINGUISHED_NAME_MATCH_MR_OID );
    attributeType.setOrderingOid( null );
    attributeType.setSubstringOid( null );
    attributeType.setSyntaxOid( "1.3.6.1.4.1.1466.115.121.1.26" );
    attributeType.setUsage( UsageEnum.USER_APPLICATIONS );
    attributeType.setCollective( true );
    attributeType.setSingleValued( true );

    // It should fail
    assertFalse( schemaManager.add( attributeType ) );

    List<Throwable> errors = schemaManager.getErrors();
    assertEquals( 1, errors.size() );
    Throwable error = errors.get( 0 );

    assertTrue( error instanceof LdapSchemaException );

    assertFalse( isATPresent( schemaManager, "1.1.0" ) );
    assertEquals( atrSize, schemaManager.getAttributeTypeRegistry().size() );
    assertEquals( goidSize, schemaManager.getGlobalOidRegistry().size() );
}
 
Example 18
Source File: SchemaManagerAddTest.java    From directory-ldap-api with Apache License 2.0 5 votes vote down vote up
/**
 * Try to inject an AttributeType which is Collective, but an operational AT
 */
@Test
public void testAddAttributeTypeNoSupCollectiveOperational() throws Exception
{
    SchemaManager schemaManager = loadSystem();
    int atrSize = schemaManager.getAttributeTypeRegistry().size();
    int goidSize = schemaManager.getGlobalOidRegistry().size();

    AttributeType attributeType = new AttributeType( "1.1.0" );
    attributeType.setEqualityOid( SchemaConstants.DISTINGUISHED_NAME_MATCH_MR_OID );
    attributeType.setOrderingOid( null );
    attributeType.setSubstringOid( null );
    attributeType.setSyntaxOid( "1.3.6.1.4.1.1466.115.121.1.26" );
    attributeType.setUsage( UsageEnum.DIRECTORY_OPERATION );
    attributeType.setCollective( true );

    // It should fail
    assertFalse( schemaManager.add( attributeType ) );

    List<Throwable> errors = schemaManager.getErrors();
    assertEquals( 1, errors.size() );
    Throwable error = errors.get( 0 );

    assertTrue( error instanceof LdapSchemaException );

    assertFalse( isATPresent( schemaManager, "1.1.0" ) );
    assertEquals( atrSize, schemaManager.getAttributeTypeRegistry().size() );
    assertEquals( goidSize, schemaManager.getGlobalOidRegistry().size() );
}
 
Example 19
Source File: SchemaManagerAddTest.java    From directory-ldap-api with Apache License 2.0 4 votes vote down vote up
/**
 * Try to inject an AttributeType which is a subtype of a Collective AT
 */
@Test
public void testAddAttributeTypeSupCollectiveUser() throws Exception
{
    SchemaManager schemaManager = loadSystem();
    int atrSize = schemaManager.getAttributeTypeRegistry().size();
    int goidSize = schemaManager.getGlobalOidRegistry().size();

    // Create the collective attribute first
    AttributeType attributeType = new AttributeType( "1.1.0" );
    attributeType.setEqualityOid( SchemaConstants.DISTINGUISHED_NAME_MATCH_MR_OID );
    attributeType.setOrderingOid( null );
    attributeType.setSubstringOid( null );
    attributeType.setSyntaxOid( "1.3.6.1.4.1.1466.115.121.1.26" );
    attributeType.setUsage( UsageEnum.USER_APPLICATIONS );
    attributeType.setCollective( true );

    // It should not fail
    assertTrue( schemaManager.add( attributeType ) );

    assertTrue( isATPresent( schemaManager, "1.1.0" ) );
    assertEquals( atrSize + 1, schemaManager.getAttributeTypeRegistry().size() );
    assertEquals( goidSize + 1, schemaManager.getGlobalOidRegistry().size() );

    // Now try to create an AT which is a subtype of teh create collective attribute
    AttributeType subType = new AttributeType( "1.1.1" );
    subType.setEqualityOid( SchemaConstants.DISTINGUISHED_NAME_MATCH_MR_OID );
    subType.setOrderingOid( null );
    subType.setSubstringOid( null );
    subType.setSuperiorOid( "1.1.0" );
    subType.setSyntaxOid( "1.3.6.1.4.1.1466.115.121.1.26" );
    subType.setUsage( UsageEnum.USER_APPLICATIONS );
    subType.setCollective( false );

    // It should fail
    assertFalse( schemaManager.add( subType ) );

    assertFalse( isATPresent( schemaManager, "1.1.1" ) );
    assertEquals( atrSize + 1, schemaManager.getAttributeTypeRegistry().size() );
    assertEquals( goidSize + 1, schemaManager.getGlobalOidRegistry().size() );
}