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


Java Attribute.getString方法代码示例

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


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

示例1: testGetString

import org.apache.directory.api.ldap.model.entry.Attribute; //导入方法依赖的package包/类
/**
 * Test method getString()
 */
@Test
public void testGetString() throws LdapInvalidAttributeValueException
{
    Attribute attr1 = new DefaultAttribute( atDC );

    assertEquals( 1, attr1.add( ( String ) null ) );

    Attribute attr2 = new DefaultAttribute( atDC );

    attr2.add( "a" );
    assertEquals( "a", attr2.getString() );

    Attribute attr3 = new DefaultAttribute( atPwd );

    attr3.add( BYTES1, BYTES2 );

    try
    {
        attr3.getString();
        fail();
    }
    catch ( LdapInvalidAttributeValueException ivae )
    {
        assertTrue( true );
    }
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:30,代码来源:SchemaAwareAttributeTest.java

示例2: testAnonymizeModify

import org.apache.directory.api.ldap.model.entry.Attribute; //导入方法依赖的package包/类
@Test
public void testAnonymizeModify() throws Exception
{
    String ldif = 
        "dn: [email protected],ou=Email,ou=Services,o=acme,dc=com\n" +
        "changetype: modify\n" +
        "replace: cn\n" +
        "cn::QUNNRSBJbmMuIExlZ2FsIFRlYW0=\n" +
        "-";
    LdifAnonymizer anonymizer = new LdifAnonymizer( schemaManager );
    anonymizer.addNamingContext( "o=acm,dc=com" );
    String result = anonymizer.anonymize( ldif );
    
    List<LdifEntry> entries = ldifReader.parseLdif( result );
    
    assertEquals( 1, entries.size() );
    
    LdifEntry entry = entries.get( 0 );
    assertTrue( entry.isChangeModify() );
    assertEquals( 1, entry.getModifications().size() );
    
    Modification modification = entry.getModifications().get( 0 );
    assertEquals( ModificationOperation.REPLACE_ATTRIBUTE, modification.getOperation() );

    Attribute attribute = modification.getAttribute();
    assertEquals( "cn", attribute.getUpId() );
    assertEquals( 1, attribute.size() );
    
    String value = attribute.getString();
    
    // We can only test the length and the fact the values are not equal (as the value has been anonymized)
    assertEquals( "AAAAAAAAAAAAAAAAAAAA".length(), value.length() );
    assertEquals( "AAAAAAAAAAAAAAAAAAAA", value );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:35,代码来源:LdifAnonymizerTest.java

示例3: getFqcn

import org.apache.directory.api.ldap.model.entry.Attribute; //导入方法依赖的package包/类
/**
 * Process the FQCN attribute
 * @throws LdapInvalidAttributeValueException
 */
private String getFqcn( Entry entry, String objectType ) throws LdapInvalidAttributeValueException
{
    // The FQCN
    Attribute mFqcn = entry.get( MetaSchemaConstants.M_FQCN_AT );

    if ( mFqcn == null )
    {
        String msg = I18n.err( I18n.ERR_10028, objectType, MetaSchemaConstants.M_FQCN_AT );
        LOG.warn( msg );
        throw new IllegalArgumentException( msg );
    }

    return mFqcn.getString();
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:19,代码来源:SchemaEntityFactory.java


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