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


Java DefaultAttribute.add方法代码示例

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


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

示例1: testGetAttribute

import org.apache.directory.api.ldap.model.entry.DefaultAttribute; //导入方法依赖的package包/类
@Test
public void testGetAttribute() throws Exception
{
    AttributeType at = TestEntryUtils.getIA5StringAttributeType();

    DefaultAttribute attr = new DefaultAttribute( at );

    attr.add( "Test1" );
    attr.add( "Test2" );
    attr.add( "Test3" );

    assertEquals( "1.1", attr.getId() );
    assertEquals( 3, attr.size() );
    assertTrue( attr.contains( "Test1" ) );
    assertTrue( attr.contains( "Test2" ) );
    assertTrue( attr.contains( "Test3" ) );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:18,代码来源:SchemaAwareAttributeTest.java

示例2: testContains

import org.apache.directory.api.ldap.model.entry.DefaultAttribute; //导入方法依赖的package包/类
/**
 * Test the contains() method
 */
@Test
public void testContains() throws Exception
{
    AttributeType at = TestEntryUtils.getIA5StringAttributeType();

    DefaultAttribute attr = new DefaultAttribute( at );

    attr.add( "Test  1" );
    attr.add( "Test  2" );
    attr.add( "Test  3" );

    assertTrue( attr.contains( "test 1" ) );
    assertTrue( attr.contains( "Test 2" ) );
    assertTrue( attr.contains( "TEST     3" ) );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:19,代码来源:SchemaAwareAttributeTest.java

示例3: testSerializeCompleteAttribute

import org.apache.directory.api.ldap.model.entry.DefaultAttribute; //导入方法依赖的package包/类
/**
 * Test the serialization of a complete server attribute
 */
@Test
public void testSerializeCompleteAttribute() throws LdapException, IOException, ClassNotFoundException
{
    DefaultAttribute dsa = new DefaultAttribute( atCN );
    dsa.setUpId( "CommonName" );
    dsa.add( "test1", "test2" );

    DefaultAttribute dsaSer = deserializeValue( serializeValue( dsa ), atCN );
    assertEquals( dsa.toString(), dsaSer.toString() );
    assertEquals( "2.5.4.3", dsaSer.getId() );
    assertEquals( "CommonName", dsaSer.getUpId() );
    assertEquals( "test1", dsaSer.getString() );
    assertTrue( dsaSer.contains( "test2", "test1" ) );
    assertTrue( dsaSer.isHumanReadable() );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:19,代码来源:SchemaAwareAttributeTest.java

示例4: testSerializeAttributeNullValue

import org.apache.directory.api.ldap.model.entry.DefaultAttribute; //导入方法依赖的package包/类
/**
 * Test the serialization of a server attribute with a null value
 */
@Test
public void testSerializeAttributeNullValue() throws LdapException, IOException, ClassNotFoundException
{
    DefaultAttribute dsa = new DefaultAttribute( atDC );
    dsa.setUpId( "DomainComponent" );
    dsa.add( ( String ) null );

    DefaultAttribute dsaSer = deserializeValue( serializeValue( dsa ), atDC );
    assertEquals( dsa.toString(), dsaSer.toString() );
    assertEquals( "0.9.2342.19200300.100.1.25", dsaSer.getId() );
    assertEquals( "DomainComponent", dsaSer.getUpId() );
    assertNull( dsaSer.getString() );
    assertEquals( 1, dsaSer.size() );
    assertTrue( dsaSer.contains( ( String ) null ) );
    assertTrue( dsaSer.isHumanReadable() );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:20,代码来源:SchemaAwareAttributeTest.java

示例5: testSerializeAttributeBinaryValue

import org.apache.directory.api.ldap.model.entry.DefaultAttribute; //导入方法依赖的package包/类
/**
 * Test the serialization of a server attribute with a binary value
 */
@Test
public void testSerializeAttributeBinaryValue() throws LdapException, IOException, ClassNotFoundException
{
    DefaultAttribute dsa = new DefaultAttribute( atPwd );
    byte[] password = Strings.getBytesUtf8( "secret" );
    dsa.add( password );

    DefaultAttribute dsaSer = deserializeValue( serializeValue( dsa ), atPwd );
    assertEquals( dsa.toString(), dsaSer.toString() );
    assertEquals( "2.5.4.35", dsaSer.getId() );
    assertEquals( "userPassword", dsaSer.getUpId() );
    assertTrue( Arrays.equals( dsa.getBytes(), dsaSer.getBytes() ) );
    assertEquals( 1, dsaSer.size() );
    assertTrue( dsaSer.contains( password ) );
    assertFalse( dsaSer.isHumanReadable() );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:20,代码来源:SchemaAwareAttributeTest.java

示例6: testAddTwoValue

import org.apache.directory.api.ldap.model.entry.DefaultAttribute; //导入方法依赖的package包/类
@Test
public void testAddTwoValue() throws Exception
{
    AttributeType at = TestEntryUtils.getIA5StringAttributeType();

    DefaultAttribute attr = new DefaultAttribute( at );

    // Add String values
    attr.add( "test" );
    attr.add( "test2" );

    assertEquals( 2, attr.size() );

    assertTrue( attr.getAttributeType().getSyntax().isHumanReadable() );

    Set<String> expected = new HashSet<String>();
    expected.add( "test" );
    expected.add( "test2" );

    for ( Value val : attr )
    {
        if ( expected.contains( val.getValue() ) )
        {
            expected.remove( val.getValue() );
        }
        else
        {
            fail();
        }
    }

    assertEquals( 0, expected.size() );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:34,代码来源:SchemaAwareAttributeTest.java

示例7: testAddOneValue

import org.apache.directory.api.ldap.model.entry.DefaultAttribute; //导入方法依赖的package包/类
@Test
public void testAddOneValue() throws Exception
{
    AttributeType at = TestEntryUtils.getIA5StringAttributeType();

    DefaultAttribute attr = new DefaultAttribute( at );

    // Add a String value
    attr.add( "test" );

    assertEquals( 1, attr.size() );

    assertTrue( attr.getAttributeType().getSyntax().isHumanReadable() );

    Value value = attr.get();

    assertTrue( value instanceof Value );
    assertEquals( "test", ( ( Value ) value ).getValue() );

    // Add a binary value
    assertEquals( 0, attr.add( new byte[]
        { 0x01 } ) );

    // Add a Value
    Value ssv = new Value( at, "test2" );

    attr.add( ssv );

    assertEquals( 2, attr.size() );

    Set<String> expected = new HashSet<String>();
    expected.add( "test" );
    expected.add( "test2" );

    for ( Value val : attr )
    {
        if ( expected.contains( val.getValue() ) )
        {
            expected.remove( val.getValue() );
        }
        else
        {
            fail();
        }
    }

    assertEquals( 0, expected.size() );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:49,代码来源:SchemaAwareAttributeTest.java

示例8: testAddNullValue

import org.apache.directory.api.ldap.model.entry.DefaultAttribute; //导入方法依赖的package包/类
@Test
public void testAddNullValue() throws Exception
{
    AttributeType at = TestEntryUtils.getIA5StringAttributeType();

    DefaultAttribute attr = new DefaultAttribute( at );

    // Add a null value
    attr.add( new Value( at, (String)null ) );

    assertEquals( 1, attr.size() );

    assertTrue( attr.getAttributeType().getSyntax().isHumanReadable() );

    Value value = attr.get();

    assertTrue( value instanceof Value );
    assertNull( ( ( Value ) value ).getValue() );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:20,代码来源:SchemaAwareAttributeTest.java


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