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

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


     */
    @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

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

        value = "( 1 FORM 1.1 )";
        ditStructureRule = parser.parseDITStructureRuleDescription( value );
        assertNotNull( ditStructureRule.getForm() );

        value = "( 1 )";
        try
        {
            parser.parseDITStructureRuleDescription( value );
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.