Package org.apache.directory.shared.ldap.entry

Examples of org.apache.directory.shared.ldap.entry.DefaultServerAttribute


                    adminPrincipal.setUserPassword(passwordToStore.getBytes());

                    InternalModifyDnRequest request = new ModifyDnRequestImpl(0);

                    EntryAttribute passwordAttribute = new DefaultServerAttribute(
                            getAttributeType("userPassword"));
                    passwordAttribute.add(passwordToStore.getBytes());

                    ServerModification serverModification =
                            new ServerModification(ModificationOperation.REPLACE_ATTRIBUTE,
                                                   passwordAttribute);
View Full Code Here


        {
            LOG.warn( "Does not make sense: you're trying to enable {} schema which is already enabled", schemaName );
            return;
        }

        mods.add( new ServerModification( ModificationOperation.REMOVE_ATTRIBUTE, new DefaultServerAttribute(
            MetaSchemaConstants.M_DISABLED_AT, schemaManager.lookupAttributeTypeRegistry( MetaSchemaConstants.M_DISABLED_AT ) ) ) );

        mods.add( new ServerModification( ModificationOperation.ADD_ATTRIBUTE, new DefaultServerAttribute(
            SchemaConstants.MODIFIERS_NAME_AT, schemaManager.lookupAttributeTypeRegistry( SchemaConstants.MODIFIERS_NAME_AT ),
            ServerDNConstants.ADMIN_SYSTEM_DN ) ) );

        mods.add( new ServerModification( ModificationOperation.ADD_ATTRIBUTE, new DefaultServerAttribute(
            SchemaConstants.MODIFY_TIMESTAMP_AT, schemaManager.lookupAttributeTypeRegistry( SchemaConstants.MODIFY_TIMESTAMP_AT ), DateUtils
                .getGeneralizedTime() ) ) );

        partition.modify( new ModifyOperationContext( null, dn, mods ) );
    }
View Full Code Here

     * Test method iterator()
     */
    @Test
    public void testIterator()
    {
        EntryAttribute attr1 = new DefaultServerAttribute( atCN );
        attr1.add"a", "b", "c" );
       
        Iterator<Value<?>> iter = attr1.iterator();
       
        assertTrue( iter.hasNext() );
       
        String[] values = new String[]{ "a", "b", "c" };
        int pos = 0;
View Full Code Here

     * Test method toString
     */
    @Test
    public void testToString()
    {
        EntryAttribute attr = new DefaultServerAttribute( atCN );
       
        assertEquals( "    cn: (null)\n", attr.toString() );
       
        attr.setUpId( "CommonName" );
        assertEquals( "    CommonName: (null)\n", attr.toString() );
       
        attr.add( (String)null );
        assertEquals( "    CommonName: ''\n", attr.toString() );

        attr.put( "a", "b" );
        assertEquals( "    CommonName: a\n    CommonName: b\n", attr.toString() );
    }
View Full Code Here

     * Test method instanceOf()
     */
    @Test
    public void testInstanceOf() throws Exception
    {
        EntryAttribute attr = new DefaultServerAttribute( atCN );
       
        assertTrue( attr.instanceOf( "CommonName" ) );
        assertTrue( attr.instanceOf( "2.5.4.3" ) );
        assertTrue( attr.instanceOf( "  Cn  " ) );
        assertFalse( attr.instanceOf( "  " ) );
        assertFalse( attr.instanceOf( "sn" ) );
        assertFalse( attr.instanceOf( "name" ) );
    }
View Full Code Here

     * Test method setUpId( String, AttributeType )
     */
    @Test
    public void testSetUpIdStringAttributeType() throws Exception
    {
        EntryAttribute attr = new DefaultServerAttribute( atSN );
       
        attr.setUpId( null, atCN );
        assertEquals( "cn", attr.getId() );
        assertEquals( "cn", attr.getUpId() );
        assertEquals( atCN, attr.getAttributeType() );

        attr.setUpId( "  ", atCN );
        assertEquals( "cn", attr.getId() );
        assertEquals( "cn", attr.getUpId() );
        assertEquals( atCN, attr.getAttributeType() );

        attr.setUpId( "  CN  ", atCN );
        assertEquals( "cn", attr.getId() );
        assertEquals( "  CN  ", attr.getUpId() );
        assertEquals( atCN, attr.getAttributeType() );

        attr.setUpId( "  CommonName  ", atCN );
        assertEquals( "commonname", attr.getId() );
        assertEquals( "  CommonName  ", attr.getUpId() );
        assertEquals( atCN, attr.getAttributeType() );

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

        // Check with wrong IDs
        try
        {
            attr.setUpId( "sn", atCN );
            fail();
        }
        catch ( IllegalArgumentException iae )
        {
            assertTrue( true );
        }

        try
        {
            attr.setUpId( "  2.5.4.4  ", atCN );
            fail();
        }
        catch ( IllegalArgumentException iae )
        {
            assertTrue( true );
View Full Code Here

     * Test method setUpId( String ) inherited from ClientAttribute
     */
    @Test
    public void testSetUpIdString() throws Exception
    {
        EntryAttribute attr = new DefaultServerAttribute( atCN );
       
        attr.setUpId( "cn" );
        assertEquals( "cn", attr.getId() );
        assertEquals( "cn", attr.getUpId() );
        assertEquals( atCN, attr.getAttributeType() );

        attr.setUpId( "  CN  " );
        assertEquals( "cn", attr.getId() );
        assertEquals( "  CN  ", attr.getUpId() );
        assertEquals( atCN, attr.getAttributeType() );

        attr.setUpId( "  CommonName  ");
        assertEquals( "commonname", attr.getId() );
        assertEquals( "  CommonName  ", attr.getUpId() );
        assertEquals( atCN, attr.getAttributeType() );

        attr.setUpId( "  2.5.4.3  " );
        assertEquals( "  2.5.4.3  ", attr.getUpId() );
        assertEquals( "2.5.4.3", attr.getId() );
        assertEquals( atCN, attr.getAttributeType() );
       
        // Now check wrong IDs
        attr = new DefaultServerAttribute( atCN );
        attr.setUpId( "sn" );
        assertEquals( "cn", attr.getId() );
        assertEquals( "cn", attr.getUpId() );
        assertEquals( atCN, attr.getAttributeType() );

        attr.setUpId( "  SN  " );
        assertEquals( "cn", attr.getId() );
        assertEquals( "cn", attr.getUpId() );
        assertEquals( atCN, attr.getAttributeType() );

        attr.setUpId( "  surname  " );
        assertEquals( "cn", attr.getId() );
        assertEquals( "cn", attr.getUpId() );
        assertEquals( atCN, attr.getAttributeType() );

        attr.setUpId( "  2.5.4.4  " );
        assertEquals( "cn", attr.getId() );
        assertEquals( "cn", attr.getUpId() );
        assertEquals( atCN, attr.getAttributeType() );
    }
View Full Code Here

     * Test method setAttributeType( AttributeType )
     */
    @Test
    public void testSetAttributeType() throws Exception
    {
        EntryAttribute attr = new DefaultServerAttribute( atCN );
       
        try
        {
            attr.setAttributeType( null );
            fail();
        }
        catch ( IllegalArgumentException iae )
        {
            assertTrue( true );
        }
       
        attr.setAttributeType( atSN );
       
        assertTrue( attr.instanceOf( "Surname" ) );
        assertEquals( "sn", attr.getId() );
        assertEquals( "sn", attr.getUpId() );
    }
View Full Code Here

     * Test method getAttributeType()
     */
    @Test
    public void testGetAttributeType() throws Exception
    {
        EntryAttribute attr = new DefaultServerAttribute( atSN );
        assertEquals( atSN, attr.getAttributeType() );
    }
View Full Code Here

     * Test constructor DefaultServerAttribute( AttributeType )
     */
    @Test
    public void testDefaultServerAttributeAttributeType()
    {
        EntryAttribute attr = new DefaultServerAttribute( atCN );
       
        assertTrue( attr.isHR() );
        assertEquals( 0, attr.size() );
        assertEquals( "cn", attr.getId() );
        assertEquals( "cn", attr.getUpId() );
        assertEquals( atCN, attr.getAttributeType() );
    }
View Full Code Here

TOP

Related Classes of org.apache.directory.shared.ldap.entry.DefaultServerAttribute

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.