use of org.apache.directory.api.ldap.model.name.Dn in project directory-ldap-api by apache.
the class SubtreeSpecificationParserTest method testSpecWithSpecificExclusions.
/**
* Tests the parser with a valid specification with some specific exclusions
* set.
*/
@Test
public void testSpecWithSpecificExclusions() throws Exception {
SubtreeSpecification ss = parser.parse(SPEC_WITH_SPECIFICEXCLUSIONS);
assertFalse(ss.getChopBeforeExclusions().isEmpty());
assertFalse(ss.getChopAfterExclusions().isEmpty());
assertTrue(ss.getChopBeforeExclusions().contains(new Dn(schemaManager, "cn=cd")));
assertTrue(ss.getChopAfterExclusions().contains(new Dn(schemaManager, "cn=gh")));
// try a second time
ss = parser.parse(SPEC_WITH_SPECIFICEXCLUSIONS);
assertFalse(ss.getChopBeforeExclusions().isEmpty());
assertFalse(ss.getChopAfterExclusions().isEmpty());
assertTrue(ss.getChopBeforeExclusions().contains(new Dn(schemaManager, "cn=cd")));
assertTrue(ss.getChopAfterExclusions().contains(new Dn(schemaManager, "cn=gh")));
// try a third time
ss = parser.parse(SPEC_WITH_SPECIFICEXCLUSIONS);
assertFalse(ss.getChopBeforeExclusions().isEmpty());
assertFalse(ss.getChopAfterExclusions().isEmpty());
assertTrue(ss.getChopBeforeExclusions().contains(new Dn(schemaManager, "cn=cd")));
assertTrue(ss.getChopAfterExclusions().contains(new Dn(schemaManager, "cn=gh")));
}
use of org.apache.directory.api.ldap.model.name.Dn 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());
}
use of org.apache.directory.api.ldap.model.name.Dn 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());
}
use of org.apache.directory.api.ldap.model.name.Dn in project directory-ldap-api by apache.
the class ApiLdapExtrasCodecApiOsgiTest method useBundleClasses.
@Override
protected void useBundleClasses() throws Exception {
SynchronizationModeEnum.REFRESH_AND_PERSIST.getValue();
new AdDirSyncImpl().getOid();
new AdShowDeletedImpl().getOid();
new AdPolicyHintsImpl().getOid();
new ChangeNotificationsImpl().getOid();
new PermissiveModifyImpl().getOid();
new PasswordPolicyImpl().getOid();
new PasswordPolicyResponseImpl().getGraceAuthNRemaining();
new SyncDoneValueImpl().getOid();
new SyncRequestValueImpl().getOid();
new SyncStateValueImpl(true).getCookie();
new VirtualListViewRequestImpl().getOid();
new VirtualListViewResponseImpl().getOid();
new PasswordModifyRequestImpl().getUserIdentity();
new PasswordModifyResponseImpl(5).setResponseName("foo");
new WhoAmIRequestImpl();
new WhoAmIResponseImpl().setDn(new Dn("uid=admin,ou=system"));
new StartTlsRequestImpl();
new StartTlsResponseImpl();
new StartTransactionRequestImpl();
new StartTransactionResponseImpl();
}
use of org.apache.directory.api.ldap.model.name.Dn in project directory-ldap-api by apache.
the class LdifRevertorTest method test102ReverseRenameCompositeCompositeNotOverlappingKeepOldRdnExistInEntry.
/**
* Test a reversed rename ModifyDN, where the initial Rdn is composite,
* the new Rdn is composite, they don't overlap, with deleteOldRdn = false, and
* some of the new values exists in the entry.
*
* Covers case 10.2 of http://cwiki.apache.org/confluence/display/DIRxSRVx11/Reverse+LDIF
*
* Initial entry
* dn: sn=small+cn=test,ou=system
* objectclass: top
* objectclass: person
* cn: test
* cn: big
* sn: small
* sn: This is a test
*
* new Rdn : sn=joe+cn=big
*
* @throws LdapException on error
*/
@Test
public void test102ReverseRenameCompositeCompositeNotOverlappingKeepOldRdnExistInEntry() throws LdapException {
Dn dn = new Dn("sn=small+cn=test,ou=system");
Rdn oldRdn = new Rdn("sn=small+cn=test");
Rdn newRdn = new Rdn("sn=joe+cn=big");
Entry entry = new DefaultEntry(dn, "objectClass: top", "objectClass: person", "cn: test", "cn: big", "sn: small", "sn: this is a test");
List<LdifEntry> reverseds = LdifRevertor.reverseRename(entry, newRdn, LdifRevertor.KEEP_OLD_RDN);
assertNotNull(reverseds);
assertEquals(2, reverseds.size());
LdifEntry reversed = reverseds.get(0);
assertEquals("sn=joe+cn=big,ou=system", reversed.getDn().getName());
assertEquals(ChangeType.ModRdn, reversed.getChangeType());
assertFalse(reversed.isDeleteOldRdn());
assertEquals(oldRdn.getName(), reversed.getNewRdn());
assertNull(reversed.getNewSuperior());
reversed = reverseds.get(1);
assertEquals("sn=small+cn=test,ou=system", reversed.getDn().getName());
assertEquals(ChangeType.Modify, reversed.getChangeType());
Modification[] mods = reversed.getModificationArray();
assertNotNull(mods);
assertEquals(1, mods.length);
assertEquals(ModificationOperation.REMOVE_ATTRIBUTE, mods[0].getOperation());
assertNotNull(mods[0].getAttribute());
assertEquals("sn", mods[0].getAttribute().getId());
assertEquals("joe", mods[0].getAttribute().getString());
}
Aggregations