当前位置: 首页>>代码示例>>Java>>正文


Java LdifEntry.getModifications方法代码示例

本文整理汇总了Java中org.apache.directory.api.ldap.model.ldif.LdifEntry.getModifications方法的典型用法代码示例。如果您正苦于以下问题:Java LdifEntry.getModifications方法的具体用法?Java LdifEntry.getModifications怎么用?Java LdifEntry.getModifications使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.directory.api.ldap.model.ldif.LdifEntry的用法示例。


在下文中一共展示了LdifEntry.getModifications方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testReverseModifyDelExistingOuValue

import org.apache.directory.api.ldap.model.ldif.LdifEntry; //导入方法依赖的package包/类
/**
 * Test a reversed Modify adding a existing value from an existing attribute
 */
@Test
public void testReverseModifyDelExistingOuValue() throws LdapException
{
    Entry modifiedEntry = buildEntry();

    modifiedEntry.put( "ou", "apache", "acme corp" );

    Dn dn = new Dn( "cn=test, ou=system" );

    Modification mod = new DefaultModification(
        ModificationOperation.REMOVE_ATTRIBUTE,
        new DefaultAttribute( "ou", "acme corp" ) );

    LdifEntry reversed = LdifRevertor.reverseModify( dn,
        Collections.<Modification> singletonList( mod ), modifiedEntry );

    assertNotNull( reversed );
    assertEquals( dn.getName(), reversed.getDn().getName() );
    assertEquals( ChangeType.Modify, reversed.getChangeType() );
    assertNull( reversed.getEntry() );

    List<Modification> mods = reversed.getModifications();

    assertNotNull( mods );
    assertEquals( 1, mods.size() );

    Modification modif = mods.get( 0 );

    assertEquals( ModificationOperation.ADD_ATTRIBUTE, modif.getOperation() );

    Attribute attr = modif.getAttribute();

    assertNotNull( attr );

    assertEquals( "ou", attr.getId() );
    assertEquals( "acme corp", attr.getString() );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:41,代码来源:LdifRevertorTest.java

示例2: testReverseModifyDeleteOU

import org.apache.directory.api.ldap.model.ldif.LdifEntry; //导入方法依赖的package包/类
/**
 * Test a reversed Modify deleting an existing attribute
 */
@Test
public void testReverseModifyDeleteOU() throws LdapException
{
    Entry modifiedEntry = buildEntry();

    modifiedEntry.put( "ou", "apache", "acme corp" );

    Dn dn = new Dn( "cn=test, ou=system" );

    Modification mod = new DefaultModification(
        ModificationOperation.REMOVE_ATTRIBUTE,
        new DefaultAttribute( "ou" ) );

    LdifEntry reversed = LdifRevertor.reverseModify( dn,
        Collections.<Modification> singletonList( mod ), modifiedEntry );

    assertNotNull( reversed );
    assertEquals( dn.getName(), reversed.getDn().getName() );
    assertEquals( ChangeType.Modify, reversed.getChangeType() );
    assertNull( reversed.getEntry() );

    List<Modification> mods = reversed.getModifications();

    assertNotNull( mods );
    assertEquals( 1, mods.size() );

    Modification modif = mods.get( 0 );

    assertEquals( ModificationOperation.ADD_ATTRIBUTE, modif.getOperation() );

    Attribute attr = modif.getAttribute();

    assertNotNull( attr );
    assertEquals( "ou", attr.getId() );

    assertTrue( attr.contains( "apache", "acme corp" ) );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:41,代码来源:LdifRevertorTest.java

示例3: testReverseModifyDelExistingOuWithAllValues

import org.apache.directory.api.ldap.model.ldif.LdifEntry; //导入方法依赖的package包/类
/**
 * Test a reversed Modify deleting all values of an existing attribute
 */
@Test
public void testReverseModifyDelExistingOuWithAllValues() throws LdapException
{
    Entry modifiedEntry = buildEntry();

    Attribute ou = new DefaultAttribute( "ou", "apache", "acme corp" );
    modifiedEntry.put( ou );

    Dn dn = new Dn( "cn=test, ou=system" );

    Modification mod = new DefaultModification(
        ModificationOperation.REMOVE_ATTRIBUTE, ou );

    LdifEntry reversed = LdifRevertor.reverseModify( dn,
        Collections.<Modification> singletonList( mod ), modifiedEntry );

    assertNotNull( reversed );
    assertEquals( dn.getName(), reversed.getDn().getName() );
    assertEquals( ChangeType.Modify, reversed.getChangeType() );
    assertNull( reversed.getEntry() );

    List<Modification> mods = reversed.getModifications();

    assertNotNull( mods );
    assertEquals( 1, mods.size() );

    Modification modif = mods.get( 0 );

    assertEquals( ModificationOperation.ADD_ATTRIBUTE, modif.getOperation() );

    Attribute attr = modif.getAttribute();

    assertNotNull( attr );
    assertEquals( "ou", attr.getId() );

    assertTrue( ou.contains( "apache", "acme corp" ) );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:41,代码来源:LdifRevertorTest.java

示例4: testReverseModifyReplaceExistingOuValues

import org.apache.directory.api.ldap.model.ldif.LdifEntry; //导入方法依赖的package包/类
/**
 * Test a reversed Modify replacing existing values with new values
 */
@Test
public void testReverseModifyReplaceExistingOuValues() throws LdapException
{
    Entry modifiedEntry = buildEntry();

    Attribute ou = new DefaultAttribute( "ou", "apache", "acme corp" );
    modifiedEntry.put( ou );

    Dn dn = new Dn( "cn=test, ou=system" );

    Attribute ouModified = new DefaultAttribute( "ou", "directory", "BigCompany inc." );

    Modification mod = new DefaultModification(
        ModificationOperation.REPLACE_ATTRIBUTE, ouModified );

    LdifEntry reversed = LdifRevertor.reverseModify( dn,
        Collections.<Modification> singletonList( mod ), modifiedEntry );

    assertNotNull( reversed );
    assertEquals( dn.getName(), reversed.getDn().getName() );
    assertEquals( ChangeType.Modify, reversed.getChangeType() );
    assertNull( reversed.getEntry() );

    List<Modification> mods = reversed.getModifications();

    assertNotNull( mods );
    assertEquals( 1, mods.size() );

    Modification modif = mods.get( 0 );

    assertEquals( ModificationOperation.REPLACE_ATTRIBUTE, modif.getOperation() );

    Attribute attr = modif.getAttribute();

    assertNotNull( attr );
    assertEquals( ou, attr );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:41,代码来源:LdifRevertorTest.java

示例5: testReverseModifyAddNewOuValue

import org.apache.directory.api.ldap.model.ldif.LdifEntry; //导入方法依赖的package包/类
/**
 * Test a reversed Modify adding a new attribute value
 * in an exiting attribute
 */
@Test
public void testReverseModifyAddNewOuValue() throws LdapException
{
    Entry modifiedEntry = buildEntry();

    modifiedEntry.put( "ou", "apache", "acme corp" );

    Dn dn = new Dn( "cn=test, ou=system" );
    Modification mod = new DefaultModification(
        ModificationOperation.ADD_ATTRIBUTE,
        new DefaultAttribute( "ou", "BigCompany inc." ) );

    LdifEntry reversed = LdifRevertor.reverseModify( dn,
        Collections.<Modification> singletonList( mod ), modifiedEntry );

    assertNotNull( reversed );
    assertEquals( dn.getName(), reversed.getDn().getName() );
    assertEquals( ChangeType.Modify, reversed.getChangeType() );
    assertNull( reversed.getEntry() );
    List<Modification> mods = reversed.getModifications();

    assertNotNull( mods );
    assertEquals( 1, mods.size() );

    Modification modif = mods.get( 0 );

    assertEquals( ModificationOperation.REMOVE_ATTRIBUTE, modif.getOperation() );

    Attribute attr = modif.getAttribute();

    assertNotNull( attr );
    assertEquals( "ou", attr.getId() );
    assertEquals( "BigCompany inc.", attr.getString() );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:39,代码来源:LdifRevertorTest.java

示例6: testReverseModifyAddNewOu

import org.apache.directory.api.ldap.model.ldif.LdifEntry; //导入方法依赖的package包/类
/**
 * Test a reversed Modify adding a new attribute
 */
@Test
public void testReverseModifyAddNewOu() throws LdapException
{
    Entry modifiedEntry = buildEntry();

    Dn dn = new Dn( "cn=test, ou=system" );
    Modification mod = new DefaultModification(
        ModificationOperation.ADD_ATTRIBUTE,
        new DefaultAttribute( "ou", "BigCompany inc." ) );

    LdifEntry reversed = LdifRevertor.reverseModify( dn,
        Collections.<Modification> singletonList( mod ), modifiedEntry );

    assertNotNull( reversed );
    assertEquals( dn.getName(), reversed.getDn().getName() );
    assertEquals( ChangeType.Modify, reversed.getChangeType() );
    assertNull( reversed.getEntry() );
    List<Modification> mods = reversed.getModifications();

    assertNotNull( mods );
    assertEquals( 1, mods.size() );

    Modification modif = mods.get( 0 );

    assertEquals( ModificationOperation.REMOVE_ATTRIBUTE, modif.getOperation() );

    Attribute attr = modif.getAttribute();

    assertNotNull( attr );
    assertEquals( "ou", attr.getId() );
    assertEquals( "BigCompany inc.", attr.getString() );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:36,代码来源:LdifRevertorTest.java

示例7: testLdifEntryChangeTypeModifySimple

import org.apache.directory.api.ldap.model.ldif.LdifEntry; //导入方法依赖的package包/类
/**
 * Test a Modify changeType LdifEntry with no control
 */
@Test
public void testLdifEntryChangeTypeModifySimple() throws Exception
{
    String ldif =
        "changetype: modify\n" +
            "add: cn\n" +
            "cn: v1\n" +
            "cn: v2\n" +
            "-";

    LdifEntry ldifEntry = new LdifEntry( "cn=app1,ou=applications,ou=conf,dc=apache,dc=org", ldif );

    assertNotNull( ldifEntry );
    assertEquals( ChangeType.Modify, ldifEntry.getChangeType() );
    assertNull( ldifEntry.getEntry() );
    assertEquals( "cn=app1,ou=applications,ou=conf,dc=apache,dc=org", ldifEntry.getDn().getName() );
    assertFalse( ldifEntry.hasControls() );
    assertTrue( ldifEntry.isLdifChange() );

    // Check the modification
    assertNotNull( ldifEntry.getModifications() );

    for ( Modification modification : ldifEntry.getModifications() )
    {
        assertEquals( ModificationOperation.ADD_ATTRIBUTE, modification.getOperation() );
        Attribute attribute = modification.getAttribute();

        assertNotNull( attribute );
        assertEquals( "cn", attribute.getId() );
        assertTrue( attribute.contains( "v1", "v2" ) );

    }
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:37,代码来源:LdifEntryTest.java

示例8: testLdifEntryChangeTypeModifyNoAttribute

import org.apache.directory.api.ldap.model.ldif.LdifEntry; //导入方法依赖的package包/类
/**
 * Test a Modify changeType LdifEntry with no attributes
 */
@Test
public void testLdifEntryChangeTypeModifyNoAttribute() throws Exception
{
    String ldif =
        "changetype: modify\n" +
            "add: cn\n" +
            "-";

    LdifEntry ldifEntry = new LdifEntry( "cn=app1,ou=applications,ou=conf,dc=apache,dc=org", ldif );

    assertNotNull( ldifEntry );
    assertEquals( ChangeType.Modify, ldifEntry.getChangeType() );
    assertNull( ldifEntry.getEntry() );
    assertEquals( "cn=app1,ou=applications,ou=conf,dc=apache,dc=org", ldifEntry.getDn().getName() );
    assertFalse( ldifEntry.hasControls() );
    assertTrue( ldifEntry.isLdifChange() );

    // Check the modification
    assertNotNull( ldifEntry.getModifications() );

    for ( Modification modification : ldifEntry.getModifications() )
    {
        assertEquals( ModificationOperation.ADD_ATTRIBUTE, modification.getOperation() );
        Attribute attribute = modification.getAttribute();

        assertNotNull( attribute );
        assertEquals( "cn", attribute.getId() );
        assertNotNull( attribute.get() );
        assertTrue( attribute.get().isNull() );
    }
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:35,代码来源:LdifEntryTest.java

示例9: testLdifEntryChangeTypeModifyNoAttributeWithControls

import org.apache.directory.api.ldap.model.ldif.LdifEntry; //导入方法依赖的package包/类
/**
 * Test a Modify changeType LdifEntry with no attributes and controls
 */
@Test
public void testLdifEntryChangeTypeModifyNoAttributeWithControls() throws Exception
{
    String ldif =
        "control: 1.2.840.113556.1.4.805 true\n" +
            "control: 1.2.840.113556.1.4.806 false: test\n" +
            "changetype: modify\n" +
            "add: cn\n" +
            "-";

    LdifEntry ldifEntry = new LdifEntry( "cn=app1,ou=applications,ou=conf,dc=apache,dc=org", ldif );

    assertNotNull( ldifEntry );
    assertEquals( ChangeType.Modify, ldifEntry.getChangeType() );
    assertNull( ldifEntry.getEntry() );
    assertEquals( "cn=app1,ou=applications,ou=conf,dc=apache,dc=org", ldifEntry.getDn().getName() );
    assertTrue( ldifEntry.isLdifChange() );

    // Check the modification
    assertNotNull( ldifEntry.getModifications() );

    for ( Modification modification : ldifEntry.getModifications() )
    {
        assertEquals( ModificationOperation.ADD_ATTRIBUTE, modification.getOperation() );
        Attribute attribute = modification.getAttribute();

        assertNotNull( attribute );
        assertEquals( "cn", attribute.getId() );
        assertEquals( 1, attribute.size() );
        assertTrue( attribute.get().isNull() );
    }

    assertTrue( ldifEntry.hasControls() );

    LdifControl ldifControl = ldifEntry.getControl( "1.2.840.113556.1.4.805" );
    assertNotNull( ldifControl );
    assertEquals( "1.2.840.113556.1.4.805", ldifControl.getOid() );
    assertTrue( ldifControl.isCritical() );
    assertNull( ldifControl.getValue() );

    ldifControl = ldifEntry.getControl( "1.2.840.113556.1.4.806" );
    assertNotNull( ldifControl );
    assertEquals( "1.2.840.113556.1.4.806", ldifControl.getOid() );
    assertFalse( ldifControl.isCritical() );
    assertNotNull( ldifControl.getValue() );
    assertEquals( "test", Strings.utf8ToString( ldifControl.getValue() ) );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:51,代码来源:LdifEntryTest.java

示例10: testReverseModifyReplaceNewAttribute

import org.apache.directory.api.ldap.model.ldif.LdifEntry; //导入方法依赖的package包/类
/**
 * Test a reversed Modify replace by injecting a new attribute
 */
@Test
public void testReverseModifyReplaceNewAttribute() throws LdapException
{
    Entry modifiedEntry = buildEntry();

    Dn dn = new Dn( "cn=test, ou=system" );

    Attribute newOu = new DefaultAttribute( "ou", "apache", "acme corp" );

    Modification mod = new DefaultModification(
        ModificationOperation.REPLACE_ATTRIBUTE, newOu );

    LdifEntry reversed = LdifRevertor.reverseModify( dn,
        Collections.<Modification> singletonList( mod ), modifiedEntry );

    assertNotNull( reversed );
    assertEquals( dn.getName(), reversed.getDn().getName() );
    assertEquals( ChangeType.Modify, reversed.getChangeType() );
    assertNull( reversed.getEntry() );

    List<Modification> mods = reversed.getModifications();

    assertNotNull( mods );
    assertEquals( 1, mods.size() );

    Modification modif = mods.get( 0 );

    assertEquals( ModificationOperation.REPLACE_ATTRIBUTE, modif.getOperation() );

    Attribute attr = modif.getAttribute();

    assertNotNull( attr );
    assertEquals( "ou", attr.getId() );

    assertNull( attr.get() );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:40,代码来源:LdifRevertorTest.java

示例11: testReverseModifyReplaceExistingOuWithNothing

import org.apache.directory.api.ldap.model.ldif.LdifEntry; //导入方法依赖的package包/类
/**
 * Test a reversed Modify replace by removing an attribute
 */
@Test
public void testReverseModifyReplaceExistingOuWithNothing() throws LdapException
{
    Entry modifiedEntry = buildEntry();

    modifiedEntry.put( "ou", "apache", "acme corp" );

    Dn dn = new Dn( "cn=test, ou=system" );

    Modification mod = new DefaultModification(
        ModificationOperation.REPLACE_ATTRIBUTE, new DefaultAttribute( "ou" ) );

    LdifEntry reversed = LdifRevertor.reverseModify( dn,
        Collections.<Modification> singletonList( mod ), modifiedEntry );

    assertNotNull( reversed );
    assertEquals( dn.getName(), reversed.getDn().getName() );
    assertEquals( ChangeType.Modify, reversed.getChangeType() );
    assertNull( reversed.getEntry() );

    List<Modification> mods = reversed.getModifications();

    assertNotNull( mods );
    assertEquals( 1, mods.size() );

    Modification modif = mods.get( 0 );

    assertEquals( ModificationOperation.REPLACE_ATTRIBUTE, modif.getOperation() );

    Attribute attr = modif.getAttribute();

    assertNotNull( attr );
    assertEquals( "ou", attr.getId() );

    assertTrue( attr.contains( "apache", "acme corp" ) );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:40,代码来源:LdifRevertorTest.java


注:本文中的org.apache.directory.api.ldap.model.ldif.LdifEntry.getModifications方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。