Search in sources :

Example 6 with SubtreeSpecification

use of org.apache.directory.api.ldap.model.subtree.SubtreeSpecification in project directory-ldap-api by apache.

the class SubtreeSpecificationParserTest method testEmptySpec.

/**
 * Tests the parser with a valid empty specification.
 */
@Test
public void testEmptySpec() throws Exception {
    SubtreeSpecification ss = parser.parse(EMPTY_SPEC);
    assertNotNull(ss);
    // try a second time
    ss = parser.parse(EMPTY_SPEC);
    assertNotNull(ss);
    // try a third time
    ss = parser.parse(EMPTY_SPEC);
    assertNotNull(ss);
}
Also used : SubtreeSpecification(org.apache.directory.api.ldap.model.subtree.SubtreeSpecification) Test(org.junit.Test)

Example 7 with SubtreeSpecification

use of org.apache.directory.api.ldap.model.subtree.SubtreeSpecification in project directory-ldap-api by apache.

the class SubtreeSpecificationParserTest method testSpecWithBaseAndEmptyRefinement.

/**
 * Tests the parser with a valid specification with base and empty
 * refinement set.
 */
@Test
public void testSpecWithBaseAndEmptyRefinement() throws Exception {
    SubtreeSpecification ss = parser.parse(SPEC_WITH_BASE_AND_EMPTY_REFINEMENT);
    assertEquals("ou=system", ss.getBase().toString());
}
Also used : SubtreeSpecification(org.apache.directory.api.ldap.model.subtree.SubtreeSpecification) Test(org.junit.Test)

Example 8 with SubtreeSpecification

use of org.apache.directory.api.ldap.model.subtree.SubtreeSpecification in project directory-ldap-api by apache.

the class SubtreeSpecificationParserTest method testReusabiltiy.

/**
 * Test reusability, especially if the state is resetted.
 */
@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());
}
Also used : Dn(org.apache.directory.api.ldap.model.name.Dn) SubtreeSpecification(org.apache.directory.api.ldap.model.subtree.SubtreeSpecification) Test(org.junit.Test)

Example 9 with SubtreeSpecification

use of org.apache.directory.api.ldap.model.subtree.SubtreeSpecification in project directory-ldap-api by apache.

the class SubtreeSpecificationParserTest method testSpecWithBaseAndSpecificExclusionsAndMinimumAndMaximum.

/**
 * Tests the parser with a valid specification with base and specific
 * 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(schemaManager, "cn=y")));
    assertTrue(ss.getChopBeforeExclusions().contains(new Dn(schemaManager, "c=z")));
    assertTrue(ss.getChopAfterExclusions().contains(new Dn(schemaManager, "sn=l")));
    assertTrue(ss.getChopAfterExclusions().contains(new Dn(schemaManager, "l=m")));
    assertEquals(7, ss.getMinBaseDistance());
    assertEquals(77, ss.getMaxBaseDistance());
}
Also used : Dn(org.apache.directory.api.ldap.model.name.Dn) SubtreeSpecification(org.apache.directory.api.ldap.model.subtree.SubtreeSpecification) Test(org.junit.Test)

Example 10 with SubtreeSpecification

use of org.apache.directory.api.ldap.model.subtree.SubtreeSpecification in project directory-ldap-api by apache.

the class SubtreeSpecificationParserTest method testSpecWithBase.

/**
 * Tests the parser with a valid specification with base set.
 */
@Test
public void testSpecWithBase() throws Exception {
    SubtreeSpecification ss = parser.parse(SPEC_WITH_BASE);
    assertNotNull(ss);
    assertEquals("ou=system", ss.getBase().toString());
}
Also used : SubtreeSpecification(org.apache.directory.api.ldap.model.subtree.SubtreeSpecification) Test(org.junit.Test)

Aggregations

SubtreeSpecification (org.apache.directory.api.ldap.model.subtree.SubtreeSpecification)13 Test (org.junit.Test)12 Dn (org.apache.directory.api.ldap.model.name.Dn)5 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 Subtree (org.apache.directory.api.ldap.aci.UserClass.Subtree)1 AndRefinement (org.apache.directory.api.ldap.model.subtree.AndRefinement)1 BaseSubtreeSpecification (org.apache.directory.api.ldap.model.subtree.BaseSubtreeSpecification)1 ItemRefinement (org.apache.directory.api.ldap.model.subtree.ItemRefinement)1 NotRefinement (org.apache.directory.api.ldap.model.subtree.NotRefinement)1 OrRefinement (org.apache.directory.api.ldap.model.subtree.OrRefinement)1 Refinement (org.apache.directory.api.ldap.model.subtree.Refinement)1 Before (org.junit.Before)1