use of org.apache.directory.api.ldap.model.name.Dn in project directory-ldap-api by apache.
the class ModifyDnRequestImplTest method getRequest.
/**
* Constructs a ModifyDnrequest to test.
*
* @return the request
*/
private ModifyDnRequestImpl getRequest() {
// Construct the ModifyDn request to test
ModifyDnRequestImpl request = new ModifyDnRequestImpl();
request.setMessageId(45);
request.setDeleteOldRdn(true);
try {
request.setName(new Dn("dc=admins,dc=apache,dc=org"));
request.setNewRdn(new Rdn("dc=administrators"));
request.setNewSuperior(new Dn("dc=groups,dc=apache,dc=org"));
} catch (LdapException ine) {
// do nothing
}
return request;
}
use of org.apache.directory.api.ldap.model.name.Dn in project directory-ldap-api by apache.
the class ModifyDnRequestImplTest method testNotEqualDiffNewSuperior.
/**
* Test for inequality when only the newSuperior DNs are different.
*/
@Test
public void testNotEqualDiffNewSuperior() throws LdapException {
ModifyDnRequestImpl req0 = getRequest();
req0.setNewSuperior(new Dn("cn=admin,dc=example,dc=com"));
ModifyDnRequestImpl req1 = getRequest();
req1.setNewSuperior(new Dn("cn=admin,dc=apache,dc=org"));
assertFalse(req0.equals(req1));
}
use of org.apache.directory.api.ldap.model.name.Dn in project directory-ldap-api by apache.
the class SearchResultEntryImplTest method testNotEqualDiffObjectName.
/**
* Tests for inequality when the objectName dn is not the same.
*/
@Test
public void testNotEqualDiffObjectName() throws LdapException {
SearchResultEntryImpl resp0 = new SearchResultEntryImpl(5);
resp0.setEntry(getEntry());
resp0.setObjectName(new Dn("dc=apache,dc=org"));
SearchResultEntryImpl resp1 = new SearchResultEntryImpl(5);
resp1.setEntry(getEntry());
resp1.setObjectName(new Dn("dc=example,dc=com"));
assertFalse("different object names should not be equal", resp1.equals(resp0));
assertFalse("different object names should not be equal", resp0.equals(resp1));
}
use of org.apache.directory.api.ldap.model.name.Dn in project directory-ldap-api by apache.
the class BaseSubtreeSpecification method toString.
/**
* @see Object#toString()
*/
@Override
public String toString() {
StringBuilder buffer = new StringBuilder();
boolean isFirst = true;
buffer.append('{');
// The base
if (!base.isEmpty()) {
buffer.append(" base \"");
buffer.append(base.getName());
buffer.append('"');
isFirst = false;
}
// The minimum
if (minBaseDistance > 0) {
if (isFirst) {
isFirst = false;
buffer.append(" ");
} else {
buffer.append(", ");
}
buffer.append("minimum ");
buffer.append(minBaseDistance);
}
// The maximum
if (maxBaseDistance > UNBOUNDED_MAX) {
if (isFirst) {
isFirst = false;
buffer.append(" ");
} else {
buffer.append(", ");
}
buffer.append("maximum ");
buffer.append(maxBaseDistance);
}
// The chopBefore exclusions
if (((chopBefore != null) && !chopBefore.isEmpty()) || ((chopAfter != null) && !chopAfter.isEmpty())) {
if (isFirst) {
isFirst = false;
buffer.append(" ");
} else {
buffer.append(", ");
}
buffer.append("specificExclusions { ");
boolean isFirstExclusion = true;
if (chopBefore != null) {
for (Dn exclusion : chopBefore) {
if (isFirstExclusion) {
isFirstExclusion = false;
} else {
buffer.append(", ");
}
buffer.append("chopBefore: \"");
buffer.append(exclusion.getName());
buffer.append('"');
}
}
if (chopAfter != null) {
for (Dn exclusion : chopAfter) {
if (isFirstExclusion) {
isFirstExclusion = false;
} else {
buffer.append(", ");
}
buffer.append("chopAfter: \"");
buffer.append(exclusion.getName());
buffer.append('"');
}
}
buffer.append(" }");
}
if (refinement != null) {
if (isFirst) {
buffer.append(" ");
} else {
buffer.append(", ");
}
buffer.append("specificationFilter ");
buffer.append(refinement.toString());
}
buffer.append(" }");
return buffer.toString();
}
use of org.apache.directory.api.ldap.model.name.Dn in project directory-ldap-api by apache.
the class QuirkySchemaTest method createFakeConnection.
private LdapConnection createFakeConnection(final String schemaFileName) {
return new LdapConnection() {
@Override
public void unBind() throws LdapException {
}
@Override
public void setTimeOut(long timeOut) {
}
@Override
public void setSchemaManager(SchemaManager schemaManager) {
}
@Override
public void setBinaryAttributeDetector(BinaryAttributeDetector binaryAttributeDetecter) {
}
@Override
public SearchCursor search(SearchRequest searchRequest) throws LdapException {
return null;
}
@Override
public EntryCursor search(String baseDn, String filter, SearchScope scope, String... attributes) throws LdapException {
return null;
}
@Override
public EntryCursor search(Dn baseDn, String filter, SearchScope scope, String... attributes) throws LdapException {
return null;
}
@Override
public void rename(Dn entryDn, Rdn newRdn, boolean deleteOldRdn) throws LdapException {
}
@Override
public void rename(String entryDn, String newRdn, boolean deleteOldRdn) throws LdapException {
}
@Override
public void rename(Dn entryDn, Rdn newRdn) throws LdapException {
}
@Override
public void rename(String entryDn, String newRdn) throws LdapException {
}
@Override
public void moveAndRename(String entryDn, String newDn, boolean deleteOldRdn) throws LdapException {
}
@Override
public void moveAndRename(Dn entryDn, Dn newDn, boolean deleteOldRdn) throws LdapException {
}
@Override
public void moveAndRename(String entryDn, String newDn) throws LdapException {
}
@Override
public void moveAndRename(Dn entryDn, Dn newDn) throws LdapException {
}
@Override
public void move(Dn entryDn, Dn newSuperiorDn) throws LdapException {
}
@Override
public void move(String entryDn, String newSuperiorDn) throws LdapException {
}
@Override
public ModifyDnResponse modifyDn(ModifyDnRequest modDnRequest) throws LdapException {
return null;
}
@Override
public ModifyResponse modify(ModifyRequest modRequest) throws LdapException {
return null;
}
@Override
public void modify(Entry entry, ModificationOperation modOp) throws LdapException {
}
@Override
public void modify(String dn, Modification... modifications) throws LdapException {
}
@Override
public void modify(Dn dn, Modification... modifications) throws LdapException {
}
@Override
public Entry lookup(String dn, Control[] controls, String... attributes) throws LdapException {
return lookup(new Dn(dn));
}
@Override
public Entry lookup(String dn, String... attributes) throws LdapException {
return lookup(new Dn(dn));
}
@Override
public Entry lookup(Dn dn, Control[] controls, String... attributes) throws LdapException {
return lookup(dn);
}
@Override
public Entry lookup(Dn dn, String... attributes) throws LdapException {
return lookup(dn);
}
@Override
public Entry lookup(String dn) throws LdapException {
return lookup(new Dn(dn));
}
@Override
public Entry lookup(Dn dn) throws LdapException {
if (dn.isRootDse()) {
Entry entry = new DefaultEntry(dn);
entry.add(SchemaConstants.SUBSCHEMA_SUBENTRY_AT, SCHEMA_DN);
return entry;
} else if (dn.toString().equals(SCHEMA_DN)) {
Entry entry = loadSchemaEntry(schemaFileName);
return entry;
} else {
throw new UnsupportedOperationException("Unexpected DN " + dn);
}
}
@Override
public void loadSchemaRelaxed() throws LdapException {
}
@Override
public void loadSchema() throws LdapException {
}
@Override
public boolean isRequestCompleted(int messageId) {
return true;
}
@Override
public boolean isControlSupported(String controlOID) throws LdapException {
return true;
}
@Override
public boolean isConnected() {
return true;
}
@Override
public boolean isAuthenticated() {
return false;
}
@Override
public List<String> getSupportedControls() throws LdapException {
return null;
}
@Override
public SchemaManager getSchemaManager() {
return null;
}
@Override
public Entry getRootDse(String... attributes) throws LdapException {
return lookup(Dn.ROOT_DSE);
}
@Override
public Entry getRootDse() throws LdapException {
return lookup(Dn.ROOT_DSE);
}
@Override
public LdapApiService getCodecService() {
return null;
}
@Override
public BinaryAttributeDetector getBinaryAttributeDetector() {
return null;
}
@Override
public ExtendedResponse extended(ExtendedRequest extendedRequest) throws LdapException {
return null;
}
@Override
public ExtendedResponse extended(Oid oid, byte[] value) throws LdapException {
return null;
}
@Override
public ExtendedResponse extended(Oid oid) throws LdapException {
return null;
}
@Override
public ExtendedResponse extended(String oid, byte[] value) throws LdapException {
return null;
}
@Override
public ExtendedResponse extended(String oid) throws LdapException {
return null;
}
@Override
public boolean exists(Dn dn) throws LdapException {
return false;
}
@Override
public boolean exists(String dn) throws LdapException {
return false;
}
@Override
public boolean doesFutureExistFor(int messageId) {
return false;
}
@Override
public DeleteResponse delete(DeleteRequest deleteRequest) throws LdapException {
return null;
}
@Override
public void delete(Dn dn) throws LdapException {
}
@Override
public void delete(String dn) throws LdapException {
}
@Override
public boolean connect() throws LdapException {
return true;
}
@Override
public CompareResponse compare(CompareRequest compareRequest) throws LdapException {
return null;
}
@Override
public boolean compare(Dn dn, String attributeName, byte[] value) throws LdapException {
return false;
}
@Override
public boolean compare(Dn dn, String attributeName, String value) throws LdapException {
return false;
}
@Override
public boolean compare(String dn, String attributeName, byte[] value) throws LdapException {
return false;
}
@Override
public boolean compare(String dn, String attributeName, String value) throws LdapException {
return false;
}
@Override
public void close() throws IOException {
}
@Override
public BindResponse bind(BindRequest bindRequest) throws LdapException {
return null;
}
@Override
public void bind(Dn name, String credentials) throws LdapException {
}
@Override
public void bind(Dn name) throws LdapException {
}
@Override
public void bind(String name, String credentials) throws LdapException {
}
@Override
public void bind(String name) throws LdapException {
}
@Override
public void bind() throws LdapException {
}
@Override
public void anonymousBind() throws LdapException {
}
@Override
public AddResponse add(AddRequest addRequest) throws LdapException {
return null;
}
@Override
public void add(Entry entry) throws LdapException {
}
@Override
public void abandon(AbandonRequest abandonRequest) {
}
@Override
public void abandon(int messageId) {
}
@Override
public boolean compare(String dn, String attributeName, Value value) throws LdapException {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean compare(Dn dn, String attributeName, Value value) throws LdapException {
// TODO Auto-generated method stub
return false;
}
@Override
public BindResponse bind(SaslRequest saslRequest) throws LdapException {
// TODO Auto-generated method stub
return null;
}
};
}
Aggregations