本文整理汇总了Java中javax.naming.ldap.Rdn.toString方法的典型用法代码示例。如果您正苦于以下问题:Java Rdn.toString方法的具体用法?Java Rdn.toString怎么用?Java Rdn.toString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.naming.ldap.Rdn
的用法示例。
在下文中一共展示了Rdn.toString方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testToString002
import javax.naming.ldap.Rdn; //导入方法依赖的package包/类
/**
* <p>
* Test method for 'javax.naming.ldap.LdapName.toString()'
* </p>
* <p>
* Here we are testing if the method returns the correct string for an
* LdapName according to RFC 2253.
* </p>
* <p>
* The expected results is a representation of this LDAP as we created it,
* in this case the in the String are three names, the ldapname should
* return the strings in the LIFO way.
* </p>
*/
public void testToString002() throws Exception {
LinkedList<Rdn> test = new LinkedList<Rdn>();
test.add(new Rdn("c1=common"));
test.add(new Rdn("c2=common"));
test.add(new Rdn("c3=common"));
LdapName ln = new LdapName(test);
String comp = "";
for (Rdn rdn : test) {
if (test.getFirst() == rdn) {
comp = rdn.toString();
} else {
comp = rdn.toString() + "," + comp;
}
}
assertEquals(comp, ln.toString());
}
示例2: rename
import javax.naming.ldap.Rdn; //导入方法依赖的package包/类
public void rename(Name nOld, Name nNew) throws NamingException {
checkName(nOld);
checkName(nNew);
if (!isInSameNamespace(nOld, nNew)) {
throw new InvalidNameException(Messages.getString("ldap.2A")); //$NON-NLS-1$
}
if (hasMultiNamingSpace(nOld) && hasMultiNamingSpace(nNew)) {
Context context = findNnsContext(nOld);
context.rename(nOld.getSuffix(1), nNew.getSuffix(1));
return;
}
// get absolute dn name
String oldTargetDN = getTargetDN(nOld, contextDn);
String newTargetDN = getTargetDN(nNew, contextDn);
LdapName name = new LdapName(newTargetDN);
Rdn rdn = name.getRdn(name.size() - 1);
String value = (String) env.get(LDAP_DELETE_RDN);
// true is default value
boolean isDeleteRdn = true;
if (value != null) {
isDeleteRdn = Boolean.getBoolean(value);
}
ModifyDNOp op = new ModifyDNOp(oldTargetDN, rdn.toString(),
isDeleteRdn, name.getPrefix(name.size() - 1).toString());
try {
doBasicOperation(op);
} catch (ReferralException e) {
if (isFollowReferral(e)) {
DirContext referralContext = getReferralContext(e);
referralContext.rename(nOld, nNew);
return;
}
throw e;
}
}
示例3: testToString008
import javax.naming.ldap.Rdn; //导入方法依赖的package包/类
/**
* <p>
* Test method for 'javax.naming.ldap.Rdn.toString()'
* </p>
* <p>
* Here we are testing if this method give us the correct string of a Rdn
* that we create, notice here that Rdn created by us is non-empty so the
* string returned must be also non-empty. Here the rdn is created with an
* object that contains an array of primitives.
* </p>
* <p>
* The expected result is an exception.
* </p>
*/
public void testToString008() throws Exception {
int[] t = new int[] { 1, 2, 3, 4, 5 };
Rdn rdn = new Rdn("t", t);
try {
rdn.toString();
fail("Should throw an exception.");
} catch (ClassCastException e) {}
}
示例4: testRDNEqualsCompare
import javax.naming.ldap.Rdn; //导入方法依赖的package包/类
/**
* <p>
* Test method for 'javax.naming.ldap.Rdn.equals(Rdn)'
* </p>
* <p>
* Here we are testing if the method can receive a Rdn.
* </p>
* <p>
* The expected result is that two rdns must be the same.
* </p>
*/
public void testRDNEqualsCompare() throws Exception {
Rdn rdn = new Rdn("t=test+v=\\4C\\4C+t=test+a=a=a+v=fsdasd+a=<a");
Rdn rdn1 = new Rdn(rdn.toString());
assertTrue(rdn.equals(rdn1));
}