Package org.apache.directory.api.ldap.model.subtree

Examples of org.apache.directory.api.ldap.model.subtree.SubtreeSpecification


     * maximum set.
     */
    @Test
    public void testWithBaseAndMinimumAndMaximum() throws Exception
    {
        SubtreeSpecification ss = parser.parse( SPEC_WITH_BASE_AND_MINIMUM_AND_MAXIMUM );

        assertEquals( new Dn( "ou=ORGANIZATION UNIT" ).getName(), ss.getBase().getName() );
        assertEquals( 1, ss.getMinBaseDistance() );
        assertEquals( 2, ss.getMaxBaseDistance() );
    }
View Full Code Here


     * exclusions and minimum and maximum set.
     */
    @Test
    public void testSpecWithBaseAndSpecificExclusionsAndMinimumAndMaximum() throws Exception
    {
        SubtreeSpecification ss = parser.parse( SPEC_WITH_BASE_AND_SPECIFICEXCLUSIONS_AND_MINIMUM_AND_MAXIMUM );
        assertNotNull( ss );

        assertEquals( "ou=people", ss.getBase().toString() );
        assertTrue( ss.getChopBeforeExclusions().contains( new Dn( "cn=y" ).apply( schemaManager ) ) );
        assertTrue( ss.getChopBeforeExclusions().contains( new Dn( "c=z" ).apply( schemaManager ) ) );
        assertTrue( ss.getChopAfterExclusions().contains( new Dn( "sn=l" ).apply( schemaManager ) ) );
        assertTrue( ss.getChopAfterExclusions().contains( new Dn( "l=m" ).apply( schemaManager ) ) );
        assertEquals( 7, ss.getMinBaseDistance() );
        assertEquals( 77, ss.getMaxBaseDistance() );
    }
View Full Code Here

     * Tests the parser with a valid specification with refinement set.
     */
    @Test
    public void testSpecWithRefinement() throws Exception
    {
        SubtreeSpecification ss = parser.parse( SPEC_WITH_REFINEMENT );

        // The items
        Refinement topItem = new ItemRefinement( TOP_OC );
        Refinement aliasItem = new ItemRefinement( ALIAS_OC );
        Refinement personItem = new ItemRefinement( PERSON_OC );
        Refinement countryItem = new ItemRefinement( COUNTRY_OC );

        // The inner OR refinement or:{item:2.5.6.1, item:person}
        List<Refinement> orList = new ArrayList<Refinement>();
        orList.add( aliasItem );
        orList.add( personItem );

        Refinement orRefinement = new OrRefinement( orList );

        // The inner AND refinement and:{ item:2.5.6.0, or:... }
        List<Refinement> innerAndList = new ArrayList<Refinement>();
        innerAndList.add( topItem );
        innerAndList.add( orRefinement );

        Refinement innerAndRefinement = new AndRefinement( innerAndList );

        // The NOT refinement not:item:2.5.6.2
        Refinement notRefinement = new NotRefinement( countryItem );

        // The outer AND refinement and:{and:..., not:...}
        List<Refinement> outerAndList = new ArrayList<Refinement>();
        outerAndList.add( innerAndRefinement );
        outerAndList.add( notRefinement );

        StringBuilder buffer = new StringBuilder();
        ss.getRefinement().printRefinementToBuffer( buffer );

        //assertEquals( outerAndRefinement.toString(), buffer );
        assertEquals( "and: { and: { item: 2.5.6.0, or: { item: 2.5.6.1, item: person } }, not: item: 2.5.6.2 }",
            buffer.toString() );
    }
View Full Code Here

     * refinement set.
     */
    @Test
    public void testSpecWithBaseAndEmptyRefinement() throws Exception
    {
        SubtreeSpecification ss = parser.parse( SPEC_WITH_BASE_AND_EMPTY_REFINEMENT );

        assertEquals( "ou=system", ss.getBase().toString() );
    }
View Full Code Here

     * Tests the parser with a valid specification with all components set.
     */
    @Test
    public void testSpecWithAllInOne() throws Exception
    {
        SubtreeSpecification ss = parser.parse( SPEC_WITH_ALL_IN_ONE );
        assertNotNull( ss );
    }
View Full Code Here

     * order.
     */
    @Test
    public void testSpecOrderOfComponentsDoesNotMatter() throws Exception
    {
        SubtreeSpecification ss = parser.parse( SPEC_ORDER_OF_COMPONENTS_DOES_NOT_MATTER );
        assertNotNull( ss );
    }
View Full Code Here

    @Test
    public void testReusabiltiy() throws Exception
    {
        Dn firstDn = new Dn( schemaManager, "cn=l" );
        String firstExclusion = "{ specificExclusions { chopAfter:\"cn=l\" } }";
        SubtreeSpecification firstSpec = parser.parse( firstExclusion );
        assertEquals( 1, firstSpec.getChopAfterExclusions().size() );
        assertEquals( firstDn, firstSpec.getChopAfterExclusions().iterator().next() );

        Dn secondDn = new Dn( schemaManager, "l=y" );
        String secondExclusion = "{ specificExclusions { chopAfter:\"l=y\" } }";
        SubtreeSpecification secondSpec = parser.parse( secondExclusion );
        assertEquals( 1, secondSpec.getChopAfterExclusions().size() );
        assertEquals( secondDn, secondSpec.getChopAfterExclusions().iterator().next() );

    }
View Full Code Here

TOP

Related Classes of org.apache.directory.api.ldap.model.subtree.SubtreeSpecification

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.