Package org.apache.directory.shared.ldap.model.schema

Examples of org.apache.directory.shared.ldap.model.schema.DitStructureRule


        }

        // DITStructureRule
        try
        {
            DITStructureRule ditStructureRule = ditStructureRuleRegistry.lookup( name );

            if ( ditStructureRule != null )
            {
                return ditStructureRule.getOid();
            }
        }
        catch ( LdapException ne )
        {
            // No more registries to look at...
View Full Code Here


        reset( ditStructureRuleDescription ); // reset and initialize the parser / lexer pair

        try
        {
            DITStructureRule ditStructureRule = parser.ditStructureRuleDescription();

            // Update the schemaName
            updateSchemaName( ditStructureRule );

            return ditStructureRule;
View Full Code Here

    /**
     * {@inheritDoc}
     */
    public String getSchemaName( int ruleId ) throws LdapException
    {
        DITStructureRule ditStructureRule = byRuleId.get( ruleId );

        if ( ditStructureRule != null )
        {
            return ditStructureRule.getSchemaName();
        }

        String msg = I18n.err( I18n.ERR_04263, ruleId );
        LOG.warn( msg );
        throw new LdapException( msg );
View Full Code Here

    /**
     * {@inheritDoc}
     */
    public DITStructureRule lookup( int ruleId ) throws LdapException
    {
        DITStructureRule ditStructureRule = byRuleId.get( ruleId );

        if ( ditStructureRule == null )
        {
            String msg = I18n.err( I18n.ERR_04265, ruleId );
            LOG.debug( msg );
View Full Code Here

    /**
     * {@inheritDoc}
     */
    public void unregister( int ruleId ) throws LdapException
    {
        DITStructureRule ditStructureRule = byRuleId.remove( ruleId );

        if ( DEBUG )
        {
            LOG.debug( "Removed {} with ruleId {} from the registry", ditStructureRule, ruleId );
        }
View Full Code Here

        }

        // DITStructureRule
        try
        {
            DITStructureRule ditStructureRule = ditStructureRuleRegistry.lookup( name );

            if ( ditStructureRule != null )
            {
                return ditStructureRule.getOid();
            }
        }
        catch ( LdapException ne )
        {
            // No more registries to look at...
View Full Code Here

     */
    @Test
    public void testNumericRuleId() throws ParseException
    {
        String value = null;
        DITStructureRule ditStructureRule = null;

        // null test
        value = null;
        try
        {
            parser.parseDITStructureRuleDescription( value );
            fail( "Exception expected, null" );
        }
        catch ( ParseException pe )
        {
            // expected
        }

        // no ruleid
        value = "( )";
        try
        {
            parser.parseDITStructureRuleDescription( value );
            fail( "Exception expected, no ruleid" );
        }
        catch ( ParseException pe )
        {
            // expected
        }

        // simple
        value = "( 1 FORM 1.1 )";
        ditStructureRule = parser.parseDITStructureRuleDescription( value );
        assertEquals( 1, ditStructureRule.getRuleId() );

        // simple
        value = "( 1234567890 FORM 1.1 )";
        ditStructureRule = parser.parseDITStructureRuleDescription( value );
        assertEquals( 1234567890, ditStructureRule.getRuleId() );

        // simple with spaces
        value = "(      1234567890   FORM   1.1     )";
        ditStructureRule = parser.parseDITStructureRuleDescription( value );
        assertEquals( 1234567890, ditStructureRule.getRuleId() );

        // non-numeric not allowed
        value = "( test FORM 1.1 )";
        try
        {
View Full Code Here

     */
    @Test
    public void testForm() throws ParseException
    {
        String value = null;
        DITStructureRule ditStructureRule = null;

        // numeric oid
        value = "( 1 FORM 1.2.3.4.5.6.7.8.9.0 )";
        ditStructureRule = parser.parseDITStructureRuleDescription( value );
        assertEquals( "1.2.3.4.5.6.7.8.9.0", ditStructureRule.getForm() );

        // numeric oid
        value = "(   1    FORM    123.4567.890    )";
        ditStructureRule = parser.parseDITStructureRuleDescription( value );
        assertEquals( "123.4567.890", ditStructureRule.getForm() );

        // descr
        value = "( 1 FORM abcdefghijklmnopqrstuvwxyz-ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789 )";
        ditStructureRule = parser.parseDITStructureRuleDescription( value );
        assertEquals( "abcdefghijklmnopqrstuvwxyz-ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789", ditStructureRule.getForm() );

        // descr, no space
        value = "(1 FORMabc)";
        ditStructureRule = parser.parseDITStructureRuleDescription( value );
        assertEquals( "abc", ditStructureRule.getForm() );

        // descr, tab
        value = "\t(\t1\tFORM\tabc\t)\t";
        ditStructureRule = parser.parseDITStructureRuleDescription( value );
        assertEquals( "abc", ditStructureRule.getForm() );

        // quoted value
        value = "( 1 FORM '1.2.3.4.5.6.7.8.9.0' )";
        ditStructureRule = parser.parseDITStructureRuleDescription( value );
        assertEquals( "1.2.3.4.5.6.7.8.9.0", ditStructureRule.getForm() );

        // no quote allowed
        value = "( 1 FORM ('test') )";
        ditStructureRule = parser.parseDITStructureRuleDescription( value );
        assertEquals( "test", ditStructureRule.getForm() );

        // invalid character
        value = "( 1 FORM 1.2.3.4.A )";
        try
        {
View Full Code Here

     */
    @Test
    public void testSup() throws ParseException
    {
        String value = null;
        DITStructureRule ditStructureRule = null;

        // no SUP
        value = "( 1 FORM 1.1 )";
        ditStructureRule = parser.parseDITStructureRuleDescription( value );
        assertEquals( 0, ditStructureRule.getSuperRules().size() );

        // SUP simple number
        value = "( 1 FORM 1.1 SUP 1 )";
        ditStructureRule = parser.parseDITStructureRuleDescription( value );
        assertEquals( 1, ditStructureRule.getSuperRules().size() );
        assertEquals( Integer.valueOf( 1 ), ditStructureRule.getSuperRules().get( 0 ) );

        // SUP single number
        value = "( 1 FORM 1.1 SUP ( 1 ) )";
        ditStructureRule = parser.parseDITStructureRuleDescription( value );
        assertEquals( 1, ditStructureRule.getSuperRules().size() );
        assertEquals( Integer.valueOf( 1 ), ditStructureRule.getSuperRules().get( 0 ) );

        // SUP multi number
        value = "( 1 FORM 1.1 SUP(12345 67890))";
        ditStructureRule = parser.parseDITStructureRuleDescription( value );
        assertEquals( 2, ditStructureRule.getSuperRules().size() );
        assertEquals( Integer.valueOf( 12345 ), ditStructureRule.getSuperRules().get( 0 ) );
        assertEquals( Integer.valueOf( 67890 ), ditStructureRule.getSuperRules().get( 1 ) );

        // non-numeric not allowed
        value = "( 1 FORM 1.1 SUP test )";
        try
        {
View Full Code Here

     */
    @Test
    public void testFull() throws ParseException
    {
        String value = null;
        DITStructureRule ditStructureRule = null;

        value = "( 1234567890 NAME ( 'abcdefghijklmnopqrstuvwxyz-ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789' 'test' ) DESC 'Descripton \u00E4\u00F6\u00FC\u00DF \u90E8\u9577' OBSOLETE FORM 2.3.4.5.6.7.8.9.0.1 SUP ( 1 1234567890 5 ) X-TEST-a ('test1-1' 'test1-2') X-TEST-b ('test2-1' 'test2-2') )";
        ditStructureRule = parser.parseDITStructureRuleDescription( value );

        assertEquals( 1234567890, ditStructureRule.getRuleId() );
        assertEquals( 2, ditStructureRule.getNames().size() );
        assertEquals( "abcdefghijklmnopqrstuvwxyz-ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789", ditStructureRule.getNames().get( 0 ) );
        assertEquals( "test", ditStructureRule.getNames().get( 1 ) );
        assertEquals( "Descripton \u00E4\u00F6\u00FC\u00DF \u90E8\u9577", ditStructureRule.getDescription() );
        assertTrue( ditStructureRule.isObsolete() );
        assertEquals( "2.3.4.5.6.7.8.9.0.1", ditStructureRule.getForm() );
        assertEquals( 3, ditStructureRule.getSuperRules().size() );
        assertEquals( Integer.valueOf( 1 ), ditStructureRule.getSuperRules().get( 0 ) );
        assertEquals( Integer.valueOf( 1234567890 ), ditStructureRule.getSuperRules().get( 1 ) );
        assertEquals( Integer.valueOf( 5 ), ditStructureRule.getSuperRules().get( 2 ) );
        assertEquals( 2, ditStructureRule.getExtensions().size() );
        assertNotNull( ditStructureRule.getExtensions().get( "X-TEST-a" ) );
        assertEquals( 2, ditStructureRule.getExtensions().get( "X-TEST-a" ).size() );
        assertEquals( "test1-1", ditStructureRule.getExtensions().get( "X-TEST-a" ).get( 0 ) );
        assertEquals( "test1-2", ditStructureRule.getExtensions().get( "X-TEST-a" ).get( 1 ) );
        assertNotNull( ditStructureRule.getExtensions().get( "X-TEST-b" ) );
        assertEquals( 2, ditStructureRule.getExtensions().get( "X-TEST-b" ).size() );
        assertEquals( "test2-1", ditStructureRule.getExtensions().get( "X-TEST-b" ).get( 0 ) );
        assertEquals( "test2-2", ditStructureRule.getExtensions().get( "X-TEST-b" ).get( 1 ) );
    }
View Full Code Here

TOP

Related Classes of org.apache.directory.shared.ldap.model.schema.DitStructureRule

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.