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


Java Attribute类代码示例

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


Attribute类属于org.apache.directory.api.ldap.model.entry包,在下文中一共展示了Attribute类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testGetId

import org.apache.directory.api.ldap.model.entry.Attribute; //导入依赖的package包/类
/**
 * Test method getId()
 */
@Test
public void testGetId()
{
    Attribute attr = new DefaultAttribute( atCN );

    assertEquals( "2.5.4.3", attr.getId() );

    attr.setUpId( "  CN  " );
    assertEquals( "2.5.4.3", attr.getId() );
    assertEquals( "  CN  ", attr.getUpId() );

    attr.setUpId( "  CommonName  " );
    assertEquals( "2.5.4.3", attr.getId() );
    assertEquals( "  CommonName  ", attr.getUpId() );

    attr.setUpId( "  2.5.4.3  " );
    assertEquals( "2.5.4.3", attr.getId() );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:22,代码来源:SchemaAwareAttributeTest.java

示例2: testGetUpId

import org.apache.directory.api.ldap.model.entry.Attribute; //导入依赖的package包/类
/**
 * Test method getUpId
 */
@Test
public void testGetUpId()
{
    Attribute attr = new DefaultAttribute( atCN );

    assertNotNull( attr.getUpId() );
    assertEquals( "cn", attr.getUpId() );

    attr.setUpId( "CN" );
    assertEquals( "CN", attr.getUpId() );

    attr.setUpId( "  Cn  " );
    assertEquals( "  Cn  ", attr.getUpId() );

    attr.setUpId( "  2.5.4.3  " );
    assertEquals( "  2.5.4.3  ", attr.getUpId() );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:21,代码来源:SchemaAwareAttributeTest.java

示例3: testApplyRemoveModificationFromEntrySameAttributeSameValue

import org.apache.directory.api.ldap.model.entry.Attribute; //导入依赖的package包/类
/**
 * Test the deletion of an attribute into an entry which contains the attribute.
 * 
 * The entry should not contain the attribute after the operation
 */
@Test
public void testApplyRemoveModificationFromEntrySameAttributeSameValue() throws LdapException
{
    Entry entry = new DefaultEntry();
    entry.put( "cn", "test" );

    Attribute attr = new DefaultAttribute( "cn", "test" );

    Modification modification = new DefaultModification( ModificationOperation.REMOVE_ATTRIBUTE, attr );

    AttributeUtils.applyModification( entry, modification );

    assertNull( entry.get( "cn" ) );
    assertEquals( 0, entry.size() );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:21,代码来源:AttributeUtilsTest.java

示例4: loadComparators

import org.apache.directory.api.ldap.model.entry.Attribute; //导入依赖的package包/类
private void loadComparators( Attribute comparators ) throws LdapException
{
    if ( comparators == null )
    {
        return;
    }

    for ( Value value : comparators )
    {
        String desc = value.getValue();

        try
        {
            LdapComparatorDescription comparator = C_DESCR_SCHEMA_PARSER.parseComparatorDescription( desc );

            updateSchemas( comparator );
        }
        catch ( ParseException pe )
        {
            throw new LdapException( pe );
        }
    }
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:24,代码来源:DefaultSchemaLoader.java

示例5: testIterator

import org.apache.directory.api.ldap.model.entry.Attribute; //导入依赖的package包/类
/**
 * Test method iterator()
 */
@Test
public void testIterator() throws LdapException
{
    Attribute attr1 = new DefaultAttribute( atCN );
    attr1.add( "a", "b", "c" );

    Iterator<Value> iter = attr1.iterator();

    assertTrue( iter.hasNext() );

    String[] values = new String[]
        { "a", "b", "c" };
    int pos = 0;

    for ( Value val : attr1 )
    {
        assertTrue( val instanceof Value );
        assertEquals( values[pos++], val.getValue() );
    }
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:24,代码来源:SchemaAwareAttributeTest.java

示例6: testToString

import org.apache.directory.api.ldap.model.entry.Attribute; //导入依赖的package包/类
/**
 * Test method toString
 */
@Test
public void testToString() throws LdapException
{
    Attribute attr = new DefaultAttribute( atEMail );

    assertEquals( "email: (null)", attr.toString() );

    attr.setUpId( "EMail" );
    assertEquals( "EMail: (null)", attr.toString() );

    attr.add( ( String ) null );
    assertEquals( "EMail: ''", attr.toString() );

    attr.clear();
    attr.add( "a", "b" );
    assertEquals( "EMail: a\nEMail: b", attr.toString() );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:21,代码来源:SchemaAwareAttributeTest.java

示例7: testNotEqualDiffModCount

import org.apache.directory.api.ldap.model.entry.Attribute; //导入依赖的package包/类
/**
 * Test for inequality when only the number of mods are different.
 */
@Test
public void testNotEqualDiffModCount() throws LdapException
{
    ModifyRequestImpl req0 = getRequest();
    Attribute attr = new DefaultAttribute( "attr3" );
    attr.add( "val0" );
    attr.add( "val1" );
    attr.add( "val2" );
    Modification item = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, attr );
    req0.addModification( item );

    ModifyRequestImpl req1 = getRequest();

    assertFalse( req0.equals( req1 ) );
    assertFalse( req1.equals( req0 ) );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:20,代码来源:ModifyRequestImplTest.java

示例8: nameToLdif

import org.apache.directory.api.ldap.model.entry.Attribute; //导入依赖的package包/类
/**
 * @return the Names as Ldif lines
 * @throws org.apache.directory.api.ldap.model.exception.LdapException If the conversion goes wrong
 */
private String nameToLdif() throws LdapException
{
    if ( names.isEmpty() )
    {
        return "";
    }
    else
    {
        Entry entry = new DefaultEntry();
        Attribute attribute = new DefaultAttribute( "m-name" );

        for ( String name : names )
        {
            attribute.add( name );
        }

        entry.put( attribute );

        return LdifUtils.convertAttributesToLdif( entry );
    }
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:26,代码来源:SchemaElementImpl.java

示例9: testDefaultServerAttributeAttributeTypeByteArray

import org.apache.directory.api.ldap.model.entry.Attribute; //导入依赖的package包/类
/**
 * Test method DefaultEntryAttribute( AttributeType, byte[]... )
 */
@Test
public void testDefaultServerAttributeAttributeTypeByteArray() throws LdapException
{
    Attribute attr1 = new DefaultAttribute( atPwd, BYTES1, BYTES2, ( byte[] ) null );

    assertFalse( attr1.isHumanReadable() );
    assertEquals( 3, attr1.size() );
    assertEquals( "2.5.4.35", attr1.getId() );
    assertEquals( "userPassword", attr1.getUpId() );
    assertEquals( atPwd, attr1.getAttributeType() );
    assertTrue( attr1.contains( BYTES1, BYTES2 ) );
    assertTrue( attr1.contains( nullBinaryValue ) );

    Attribute attr2 = new DefaultAttribute( atPwd, stringValue1, binaryValue2, nullBinaryValue );

    assertFalse( attr2.isHumanReadable() );
    assertEquals( 2, attr2.size() );
    assertEquals( "2.5.4.35", attr2.getId() );
    assertEquals( "userPassword", attr2.getUpId() );
    assertEquals( atPwd, attr2.getAttributeType() );
    assertTrue( attr2.contains( BYTES2 ) );
    assertTrue( attr2.contains( nullBinaryValue ) );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:27,代码来源:SchemaAwareAttributeTest.java

示例10: testClone

import org.apache.directory.api.ldap.model.entry.Attribute; //导入依赖的package包/类
/**
 * Test method testClone()
 */
@Test
public void testClone() throws LdapException
{
    Attribute attr = new DefaultAttribute( atDC );

    Attribute clone = attr.clone();

    assertEquals( attr, clone );
    attr.setUpId( "DomainComponent" );
    assertEquals( "0.9.2342.19200300.100.1.25", clone.getId() );

    attr.add( "a", ( String ) null, "b" );
    clone = attr.clone();
    assertEquals( attr, clone );

    attr.remove( "a" );
    assertNotSame( attr, clone );

    clone = attr.clone();
    assertEquals( attr, clone );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:25,代码来源:SchemaAwareAttributeTest.java

示例11: testCopyConstructorServerAttribute

import org.apache.directory.api.ldap.model.entry.Attribute; //导入依赖的package包/类
/**
 * Test the copy constructor of a EntryAttribute
 */
@Test
public void testCopyConstructorServerAttribute() throws LdapException
{
    Attribute attribute = new DefaultAttribute( atCN );

    Attribute copy = new DefaultAttribute( atCN, attribute );

    assertEquals( copy, attribute );

    Attribute attribute2 = new DefaultAttribute( atCN, "test" );

    Attribute copy2 = new DefaultAttribute( atCN, attribute2 );

    assertEquals( copy2, attribute2 );
    attribute2.add( "test2" );
    assertNotSame( copy2, attribute2 );
    assertEquals( "test", copy2.getString() );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:22,代码来源:SchemaAwareAttributeTest.java

示例12: testCopyConstructorClientAttribute

import org.apache.directory.api.ldap.model.entry.Attribute; //导入依赖的package包/类
/**
 * Test the copy constructor of a ClientAttribute
 */
@Test
public void testCopyConstructorClientAttribute() throws LdapException
{
    Attribute attribute = new DefaultAttribute( "commonName" );
    attribute.add( "test" );

    Attribute copy = new DefaultAttribute( atCN, attribute );

    assertEquals( atCN, copy.getAttributeType() );
    assertEquals( "test", copy.getString() );
    assertTrue( copy.isHumanReadable() );

    attribute.add( "test2" );
    assertFalse( copy.contains( "test2" ) );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:19,代码来源:SchemaAwareAttributeTest.java

示例13: extensionsToLdif

import org.apache.directory.api.ldap.model.entry.Attribute; //导入依赖的package包/类
/**
 * Return the extensions formated as Ldif lines
 *
 * @param id The attributeId : can be m-objectClassExtension or
 * m-attributeTypeExtension
 * @return The extensions formated as ldif lines
 * @throws org.apache.directory.api.ldap.model.exception.LdapException If the conversion goes wrong
 */
protected String extensionsToLdif( String id ) throws LdapException
{
    StringBuilder sb = new StringBuilder();

    Entry entry = new DefaultEntry();
    Attribute attribute = new DefaultAttribute( id );

    for ( String extension : extensions.keySet() )
    {
        attribute.add( extension );
    }

    sb.append( LdifUtils.convertAttributesToLdif( entry ) );

    return sb.toString();
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:25,代码来源:SchemaElementImpl.java

示例14: createEntry

import org.apache.directory.api.ldap.model.entry.Attribute; //导入依赖的package包/类
/**
 * Helper method which creates an entry with 4 attributes.
 */
private Entry createEntry()
{
    try
    {
        Entry entry = new DefaultEntry( exampleDn );

        Attribute attrOC = new DefaultAttribute( "objectClass", "top", "person" );
        Attribute attrCN = new DefaultAttribute( "cn", "test1", "test2" );
        Attribute attrSN = new DefaultAttribute( "sn", "Test1", "Test2" );
        Attribute attrPWD = new DefaultAttribute( "userPassword", BYTES1, BYTES2 );

        entry.put( attrOC, attrCN, attrSN, attrPWD );

        return entry;
    }
    catch ( LdapException ne )
    {
        // Do nothing
        return null;
    }
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:25,代码来源:SchemaAwareEntryTest.java

示例15: testApplyAddModificationToEntry

import org.apache.directory.api.ldap.model.entry.Attribute; //导入依赖的package包/类
/**
 * Test a addModification applied to an entry 
 */
@Test
public void testApplyAddModificationToEntry() throws LdapException
{
    Entry entry = new DefaultEntry();
    entry.add( "dc", "apache" );
    assertEquals( 1, entry.size() );

    Attribute attr = new DefaultAttribute( "cn", "test" );
    Modification modification = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, attr );

    AttributeUtils.applyModification( entry, modification );
    assertNotNull( entry.get( "cn" ) );
    assertEquals( 2, entry.size() );
    assertEquals( attr, entry.get( "cn" ) );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:19,代码来源:AttributeUtilsTest.java


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