/*
* test name '/usr/bin/cn=test'
*/
server.setResponseSeq(new LdapMessage[] { new LdapMessage(
LdapASN1Constant.OP_SEARCH_RESULT_DONE,
new EncodableLdapResult(), null) });
try {
context.lookup("/usr/bin/cn=test");
fail("Should throw CannotProceedException");
} catch (CannotProceedException e) {
assertEquals("/", e.getAltName().toString());
assertEquals("usr/bin/cn=test", e.getRemainingName().toString());
assertNull(e.getRemainingNewName());
assertTrue(e.getResolvedName() instanceof CompositeName);
assertEquals(1, e.getResolvedName().size());
assertEquals("/", e.getResolvedName().toString());
assertTrue(e.getAltNameCtx() instanceof LdapContext);
assertEquals(context.getNameInNamespace(), e
.getAltNameCtx().getNameInNamespace());
assertTrue(e.getResolvedObj() instanceof Reference);
Reference ref = (Reference) e.getResolvedObj();
assertEquals(Object.class.getName(), ref.getClassName());
assertNull(ref.getFactoryClassLocation());
assertNull(ref.getFactoryClassName());
assertEquals(1, ref.size());
RefAddr addr = ref.get(0);
assertTrue(addr.getContent() instanceof LdapContext);
assertEquals(context.getNameInNamespace(),
((LdapContext) addr.getContent()).getNameInNamespace());
assertEquals("nns", addr.getType());
}
/*
* test name 'usr/bin/cn=test'
*/
try {
context.getAttributes("usr/bin/cn=test");
fail("Should throw InvalidNameException");
} catch (InvalidNameException e) {
// expected
}
/*
* test name '/'
*/
server.setResponseSeq(new LdapMessage[] { new LdapMessage(
LdapASN1Constant.OP_SEARCH_RESULT_DONE,
new EncodableLdapResult(), null) });
try {
Name name = new CompositeName();
name.add("");
context.getAttributes(name);
fail("Should throw CannotProceedException");