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


Java LdifAttributesReader.parseEntry方法代码示例

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


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

示例1: testLdifComments

import org.apache.directory.api.ldap.model.ldif.LdifAttributesReader; //导入方法依赖的package包/类
@Test
public void testLdifComments() throws LdapLdifException, IOException
{
    String ldif = 
          "#Comment 1\r" 
        + "#\r" 
        + " th\n" 
        + " is is still a comment\n" 
        + "\n";

    LdifAttributesReader reader = new LdifAttributesReader();
    Entry entry = reader.parseEntry( ldif );

    assertNull( entry );
    reader.close();
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:17,代码来源:LdifAttributesReaderTest.java

示例2: testLdifVersionStart

import org.apache.directory.api.ldap.model.ldif.LdifAttributesReader; //导入方法依赖的package包/类
@Test
public void testLdifVersionStart() throws LdapLdifException, IOException
{
    String ldif = 
          "cn: app1\n" 
        + "objectClass: top\n" 
        + "objectClass: apApplication\n" 
        + "displayName:   app1   \n"
        + "dependencies:\n" 
        + "envVars:";

    LdifAttributesReader reader = new LdifAttributesReader();
    Entry entry = reader.parseEntry( ldif );

    assertEquals( 1, reader.getVersion() );
    assertNotNull( entry );

    Attribute attr = entry.get( "displayname" );
    assertTrue( attr.contains( "app1" ) );
    reader.close();
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:22,代码来源:LdifAttributesReaderTest.java

示例3: testLdifParserEndSpaces

import org.apache.directory.api.ldap.model.ldif.LdifAttributesReader; //导入方法依赖的package包/类
/**
 * Spaces at the end of values should not be included into values.
 * 
 * @throws NamingException
 */
@Test
public void testLdifParserEndSpaces() throws LdapLdifException, IOException
{
    String ldif = 
          "cn: app1\n" 
        + "objectClass: top\n" 
        + "objectClass: apApplication\n" 
        + "displayName:   app1   \n"
        + "dependencies:\n" 
        + "envVars:";

    LdifAttributesReader reader = new LdifAttributesReader();

    Entry entry = reader.parseEntry( ldif );
    assertNotNull( entry );

    Attribute attr = entry.get( "displayname" );
    assertTrue( attr.contains( "app1" ) );
    reader.close();
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:26,代码来源:LdifAttributesReaderTest.java

示例4: testLdifNull

import org.apache.directory.api.ldap.model.ldif.LdifAttributesReader; //导入方法依赖的package包/类
@Test
public void testLdifNull() throws LdapLdifException, IOException
{
    String ldif = null;

    LdifAttributesReader reader = new LdifAttributesReader();
    Entry entry = reader.parseEntry( ldif );

    assertEquals( 0, entry.size() );
    reader.close();
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:12,代码来源:LdifAttributesReaderTest.java

示例5: testLdifEmpty

import org.apache.directory.api.ldap.model.ldif.LdifAttributesReader; //导入方法依赖的package包/类
@Test
public void testLdifEmpty() throws LdapLdifException, IOException
{
    String ldif = "";

    LdifAttributesReader reader = new LdifAttributesReader();
    Entry entry = reader.parseEntry( ldif );

    assertEquals( 0, entry.size() );
    reader.close();
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:12,代码来源:LdifAttributesReaderTest.java

示例6: testLdifEmptyLines

import org.apache.directory.api.ldap.model.ldif.LdifAttributesReader; //导入方法依赖的package包/类
@Test
public void testLdifEmptyLines() throws LdapLdifException, IOException
{
    String ldif = "\n\n\r\r\n";

    LdifAttributesReader reader = new LdifAttributesReader();
    Entry entry = reader.parseEntry( ldif );
    assertNull( entry );
    reader.close();
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:11,代码来源:LdifAttributesReaderTest.java

示例7: testLdifParser

import org.apache.directory.api.ldap.model.ldif.LdifAttributesReader; //导入方法依赖的package包/类
@Test
public void testLdifParser() throws LdapLdifException, LdapInvalidAttributeValueException, IOException
{
    String ldif = 
          "cn: app1\n" 
        + "objectClass: top\n" 
        + "objectClass: apApplication\n" 
        + "displayName: app1   \n"
        + "dependencies:\n" 
        + "envVars:";

    LdifAttributesReader reader = new LdifAttributesReader();
    Entry entry = reader.parseEntry( ldif );

    assertNotNull( entry );

    Attribute attr = entry.get( "cn" );
    assertTrue( attr.contains( "app1" ) );

    attr = entry.get( "objectclass" );
    assertTrue( attr.contains( "top" ) );
    assertTrue( attr.contains( "apApplication" ) );

    attr = entry.get( "displayname" );
    assertTrue( attr.contains( "app1" ) );

    attr = entry.get( "dependencies" );
    assertEquals( "", attr.get().getValue() );

    attr = entry.get( "envvars" );
    assertEquals( "", attr.get().getValue() );
    reader.close();
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:34,代码来源:LdifAttributesReaderTest.java

示例8: testLdifParserMuiltiLineComments

import org.apache.directory.api.ldap.model.ldif.LdifAttributesReader; //导入方法依赖的package包/类
@Test
public void testLdifParserMuiltiLineComments() throws LdapLdifException, IOException
{
    String ldif = 
          "#comment\n" 
        + " still a comment\n" 
        + "cn: app1#another comment\n" 
        + "objectClass: top\n"
        + "objectClass: apApplication\n" 
        + "displayName: app1\n" 
        + "serviceType: http\n" 
        + "dependencies:\n"
        + "httpHeaders:\n" 
        + "startupOptions:\n" 
        + "envVars:";

    LdifAttributesReader reader = new LdifAttributesReader();
    Entry entry = reader.parseEntry( ldif );

    assertNotNull( entry );

    Attribute attr = entry.get( "cn" );
    assertTrue( attr.contains( "app1#another comment" ) );

    attr = entry.get( "objectclass" );
    assertTrue( attr.contains( "top" ) );
    assertTrue( attr.contains( "apApplication" ) );

    attr = entry.get( "displayname" );
    assertTrue( attr.contains( "app1" ) );

    attr = entry.get( "dependencies" );
    assertEquals( "", attr.get().getValue() );

    attr = entry.get( "envvars" );
    assertEquals( "", attr.get().getValue() );
    reader.close();
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:39,代码来源:LdifAttributesReaderTest.java

示例9: testLdifParserMultiLineEntries

import org.apache.directory.api.ldap.model.ldif.LdifAttributesReader; //导入方法依赖的package包/类
@Test
public void testLdifParserMultiLineEntries() throws LdapLdifException, IOException
{
    String ldif = 
          "#comment\n" 
        + "cn: app1#another comment\n" 
        + "objectClass: top\n" 
        + "objectClass: apAppli\n"
        + " cation\n" 
        + "displayName: app1\n" 
        + "serviceType: http\n" 
        + "dependencies:\n" 
        + "httpHeaders:\n"
        + "startupOptions:\n" 
        + "envVars:";

    LdifAttributesReader reader = new LdifAttributesReader();
    Entry entry = reader.parseEntry( ldif );

    assertNotNull( entry );

    Attribute attr = entry.get( "cn" );
    assertTrue( attr.contains( "app1#another comment" ) );

    attr = entry.get( "objectclass" );
    assertTrue( attr.contains( "top" ) );
    assertTrue( attr.contains( "apApplication" ) );

    attr = entry.get( "displayname" );
    assertTrue( attr.contains( "app1" ) );

    attr = entry.get( "dependencies" );
    assertEquals( "", attr.get().getValue() );

    attr = entry.get( "envvars" );
    assertEquals( "", attr.get().getValue() );
    reader.close();
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:39,代码来源:LdifAttributesReaderTest.java

示例10: testLdifParserBase64

import org.apache.directory.api.ldap.model.ldif.LdifAttributesReader; //导入方法依赖的package包/类
@Test
public void testLdifParserBase64() throws LdapLdifException, IOException
{
    String ldif = 
          "#comment\n" 
        + "cn:: RW1tYW51ZWwgTMOpY2hhcm55\n" 
        + "objectClass: top\n"
        + "objectClass: apApplication\n" 
        + "displayName: app1\n" 
        + "serviceType: http\n" 
        + "dependencies:\n"
        + "httpHeaders:\n" 
        + "startupOptions:\n" 
        + "envVars:";

    LdifAttributesReader reader = new LdifAttributesReader();
    Entry entry = reader.parseEntry( ldif );

    assertNotNull( entry );

    Attribute attr = entry.get( "cn" );
    assertTrue( attr.contains( "Emmanuel L\u00e9charny".getBytes( StandardCharsets.UTF_8 ) ) );

    attr = entry.get( "objectclass" );
    assertTrue( attr.contains( "top" ) );
    assertTrue( attr.contains( "apApplication" ) );

    attr = entry.get( "displayname" );
    assertTrue( attr.contains( "app1" ) );

    attr = entry.get( "dependencies" );
    assertEquals( "", attr.get().getValue() );

    attr = entry.get( "envvars" );
    assertEquals( "", attr.get().getValue() );
    reader.close();
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:38,代码来源:LdifAttributesReaderTest.java

示例11: testLdifParserBase64MultiLine

import org.apache.directory.api.ldap.model.ldif.LdifAttributesReader; //导入方法依赖的package包/类
@Test
public void testLdifParserBase64MultiLine() throws LdapLdifException, IOException
{
    String ldif = 
          "#comment\n" 
        + "cn:: RW1tYW51ZWwg\n" 
        + " TMOpY2hhcm55ICA=\n" 
        + "objectClass: top\n"
        + "objectClass: apApplication\n" 
        + "displayName: app1\n" 
        + "serviceType: http\n" 
        + "dependencies:\n"
        + "httpHeaders:\n" 
        + "startupOptions:\n" 
        + "envVars:";

    LdifAttributesReader reader = new LdifAttributesReader();
    Entry entry = reader.parseEntry( ldif );

    assertNotNull( entry );

    Attribute attr = entry.get( "cn" );
    assertTrue( attr.contains( "Emmanuel L\u00e9charny  ".getBytes( StandardCharsets.UTF_8 ) ) );

    attr = entry.get( "objectclass" );
    assertTrue( attr.contains( "top" ) );
    assertTrue( attr.contains( "apApplication" ) );

    attr = entry.get( "displayname" );
    assertTrue( attr.contains( "app1" ) );

    attr = entry.get( "dependencies" );
    assertEquals( "", attr.get().getValue() );

    attr = entry.get( "envvars" );
    assertEquals( "", attr.get().getValue() );
    reader.close();
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:39,代码来源:LdifAttributesReaderTest.java

示例12: testLdifParserRFC2849Sample5WithSizeLimit

import org.apache.directory.api.ldap.model.ldif.LdifAttributesReader; //导入方法依赖的package包/类
@Test
public void testLdifParserRFC2849Sample5WithSizeLimit() throws Exception
{
    String ldif = 
          "objectclass: top\n" 
        + "objectclass: person\n" 
        + "objectclass: organizationalPerson\n"
        + "cn: Horatio Jensen\n"
        + "cn: Horatio N Jensen\n" 
        + "sn: Jensen\n" 
        + "uid: hjensen\n"
        + "telephonenumber: +1 408 555 1212\n" 
        + "jpegphoto:< file:" 
        + HJENSEN_JPEG_FILE.getAbsolutePath() 
        + "\n";

    LdifAttributesReader reader = new LdifAttributesReader();
    reader.setSizeLimit( 128 );

    try
    {
        reader.parseEntry( ldif );
        fail();
    }
    catch ( LdapLdifException ne )
    {
        assertTrue( I18n.err( I18n.ERR_12009_ERROR_PARSING_LDIF_BUFFER ), ne.getMessage().startsWith(
            I18n.ERR_12009_ERROR_PARSING_LDIF_BUFFER.getErrorCode() ) );
    }

    reader.close();
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:33,代码来源:LdifAttributesReaderTest.java

示例13: testLdifParserRFC2849Sample1

import org.apache.directory.api.ldap.model.ldif.LdifAttributesReader; //导入方法依赖的package包/类
@Test
public void testLdifParserRFC2849Sample1() throws LdapLdifException, IOException
{
    String ldif = 
          "objectclass: top\n" 
        + "objectclass: person\n" 
        + "objectclass: organizationalPerson\n"
        + "cn: Barbara Jensen\n" 
        + "cn: Barbara J Jensen\n" 
        + "cn: Babs Jensen\n" 
        + "sn: Jensen\n"
        + "uid: bjensen\n" 
        + "telephonenumber: +1 408 555 1212\n" 
        + "description: A big sailing fan.\n";

    LdifAttributesReader reader = new LdifAttributesReader();
    Entry entry = reader.parseEntry( ldif );

    Attribute attr = entry.get( "objectclass" );
    assertTrue( attr.contains( "top" ) );
    assertTrue( attr.contains( "person" ) );
    assertTrue( attr.contains( "organizationalPerson" ) );

    attr = entry.get( "cn" );
    assertTrue( attr.contains( "Barbara Jensen" ) );
    assertTrue( attr.contains( "Barbara J Jensen" ) );
    assertTrue( attr.contains( "Babs Jensen" ) );

    attr = entry.get( "sn" );
    assertTrue( attr.contains( "Jensen" ) );

    attr = entry.get( "uid" );
    assertTrue( attr.contains( "bjensen" ) );

    attr = entry.get( "telephonenumber" );
    assertTrue( attr.contains( "+1 408 555 1212" ) );

    attr = entry.get( "description" );
    assertTrue( attr.contains( "A big sailing fan." ) );
    reader.close();
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:42,代码来源:LdifAttributesReaderTest.java

示例14: testLdifParserRFC2849Sample2

import org.apache.directory.api.ldap.model.ldif.LdifAttributesReader; //导入方法依赖的package包/类
@Test
public void testLdifParserRFC2849Sample2() throws LdapLdifException, IOException
{
    String ldif = 
          "objectclass: top\n" 
        + "objectclass: person\n" 
        + "objectclass: organizationalPerson\n"
        + "cn: Barbara Jensen\n" 
        + "cn: Barbara J Jensen\n" 
        + "cn: Babs Jensen\n" 
        + "sn: Jensen\n"
        + "uid: bjensen\n" 
        + "telephonenumber: +1 408 555 1212\n"
        + "description:Babs is a big sailing fan, and travels extensively in sea\n"
        + " rch of perfect sailing conditions.\n" 
        + "title:Product Manager, Rod and Reel Division";

    LdifAttributesReader reader = new LdifAttributesReader();
    Entry entry = reader.parseEntry( ldif );

    Attribute attr = entry.get( "objectclass" );
    assertTrue( attr.contains( "top" ) );
    assertTrue( attr.contains( "person" ) );
    assertTrue( attr.contains( "organizationalPerson" ) );

    attr = entry.get( "cn" );
    assertTrue( attr.contains( "Barbara Jensen" ) );
    assertTrue( attr.contains( "Barbara J Jensen" ) );
    assertTrue( attr.contains( "Babs Jensen" ) );

    attr = entry.get( "sn" );
    assertTrue( attr.contains( "Jensen" ) );

    attr = entry.get( "uid" );
    assertTrue( attr.contains( "bjensen" ) );

    attr = entry.get( "telephonenumber" );
    assertTrue( attr.contains( "+1 408 555 1212" ) );

    attr = entry.get( "description" );
    assertTrue( attr
        .contains( "Babs is a big sailing fan, and travels extensively in search of perfect sailing conditions." ) );

    attr = entry.get( "title" );
    assertTrue( attr.contains( "Product Manager, Rod and Reel Division" ) );
    reader.close();
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:48,代码来源:LdifAttributesReaderTest.java

示例15: createEntry

import org.apache.directory.api.ldap.model.ldif.LdifAttributesReader; //导入方法依赖的package包/类
private Entry createEntry( SchemaManager schemaManager, Object... elements )
    throws LdapInvalidAttributeValueException, LdapLdifException
{
    StringBuilder sb = new StringBuilder();
    int pos = 0;
    boolean valueExpected = false;

    for ( Object element : elements )
    {
        if ( !valueExpected )
        {
            if ( !( element instanceof String ) )
            {
                throw new LdapInvalidAttributeValueException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, I18n.err(
                    I18n.ERR_12085, ( pos + 1 ) ) );
            }

            String attribute = ( String ) element;
            sb.append( attribute );

            if ( attribute.indexOf( ':' ) != -1 )
            {
                sb.append( '\n' );
            }
            else
            {
                valueExpected = true;
            }
        }
        else
        {
            if ( element instanceof String )
            {
                sb.append( ": " ).append( ( String ) element ).append( '\n' );
            }
            else if ( element instanceof byte[] )
            {
                sb.append( ":: " );
                sb.append( new String( Base64.encode( ( byte[] ) element ) ) );
                sb.append( '\n' );
            }
            else
            {
                throw new LdapInvalidAttributeValueException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, I18n.err(
                    I18n.ERR_12086, ( pos + 1 ) ) );
            }

            valueExpected = false;
        }
    }

    if ( valueExpected )
    {
        throw new LdapInvalidAttributeValueException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, I18n
            .err( I18n.ERR_12087 ) );
    }

    LdifAttributesReader reader = new LdifAttributesReader();
    Entry entry = reader.parseEntry( schemaManager, sb.toString() );

    return entry;
}
 
开发者ID:TremoloSecurity,项目名称:MyVirtualDirectory,代码行数:63,代码来源:DefaultEntry.java


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