本文整理汇总了Java中javax.naming.ldap.LdapName.add方法的典型用法代码示例。如果您正苦于以下问题:Java LdapName.add方法的具体用法?Java LdapName.add怎么用?Java LdapName.add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.naming.ldap.LdapName
的用法示例。
在下文中一共展示了LdapName.add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: modifyDn
import javax.naming.ldap.LdapName; //导入方法依赖的package包/类
/**
* LDAP modify DN operation.
*
* @param dn Distinguished name of the entry.
* @param newRDN new realtive distinguished name of the entry.
* @param deleteOldRDN if old relative distinguished name should be deleted
* @param newSuperior new superior DN
* @throws NamingException if DN can not be resolved
*/
public void modifyDn(final String dn, final String newRDN, final boolean deleteOldRDN, final String newSuperior)
throws NamingException {
WithContext<Object> action = ctx -> {
LdapName source = new LdapName(dn);
LdapName target = new LdapName(newSuperior);
target.add(newRDN);
ctx.addToEnvironment("java.naming.ldap.deleteRDN", Boolean.toString(deleteOldRDN));
ctx.rename(source, target);
return null;
};
performWithContext(action);
}
示例2: testIntegrationConstructorAndAddMethods
import javax.naming.ldap.LdapName; //导入方法依赖的package包/类
/**
* <p>Method to test all the add methods.</p>
*
*/
public void testIntegrationConstructorAndAddMethods(){
try {
//Testing Constructor
LdapName temp=new LdapName("t=test");
LdapName temp2=new LdapName(list);
list.add(aux);
LdapName temp3=new LdapName(list);
assertNotNull(temp);
assertNotNull(temp2);
assertNotNull(temp3);
//Testing Methods
temp.add(0,aux);
temp.add(0,"f=flag");
temp.add(aux);
temp.add("f=flag");
temp.addAll(0,list);
temp.addAll(0,temp2);
temp.addAll(list);
temp.addAll(temp2);
} catch (InvalidNameException e) {
fail("Failed with:"+e);
}
}
示例3: testLdapNameString002
import javax.naming.ldap.LdapName; //导入方法依赖的package包/类
/**
* <p>
* Test method for 'javax.naming.ldap.LdapName(String)'
* </p>
*/
public void testLdapNameString002() throws Exception {
String str = "t=\\20\\ te\\ s\\20t\\20\\20 + t2 = test1\\20\\ ";
LdapName ln = new LdapName(str);
assertEquals(ln.toString(), str);
ln.get(0);
assertEquals(ln.toString(), str);
ln.add("t=test");
assertEquals(ln.toString(), "t=test,t=\\ \\ te s t\\ +t2=test1\\ \\ ");
}
示例4: testIntegrationConstructorAndMethods001
import javax.naming.ldap.LdapName; //导入方法依赖的package包/类
/**
* <p>Method to test all the add methods in addition to the test of get methods.</p>
*
*/
public void testIntegrationConstructorAndMethods001(){
try {
//Testing Constructor
LdapName temp=new LdapName("t=test");
LdapName temp2=new LdapName(list);
list.add(aux);
LdapName temp3=new LdapName(list);
assertNotNull(temp);
assertNotNull(temp2);
assertNotNull(temp3);
//Testing Add Methods
temp.add(0,aux);
temp.add(0,"f=flag");
temp.add(aux);
temp.add("f=flag");
temp.addAll(0,list);
temp.addAll(0,temp2);
temp.addAll(list);
temp.addAll(temp2);
//Testing get methods
LdapName en=(LdapName) temp.clone();
assertEquals("t=test",temp.get(0));
assertNotNull(temp.getAll());
Enumeration<String> enume=temp.getAll();
Enumeration<String> enume2=en.getAll();
while(enume.hasMoreElements()&&enume2.hasMoreElements()){
if(enume.nextElement().compareTo(enume2.nextElement())!=0)fail("Fail.");
}
if(!temp.getClass().equals(temp2.getClass()))fail("Fail.");
assertTrue(temp.startsWith(temp.getPrefix(0)));
assertTrue(temp.endsWith(temp.getSuffix(0)));
assertTrue(temp.endsWith(temp.getRdns()));
assertTrue(temp.getRdn(0).equals(aux));
} catch (InvalidNameException e) {
fail("Failed with:"+e);
}
}
示例5: testIntegrationConstructorAndMethods002
import javax.naming.ldap.LdapName; //导入方法依赖的package包/类
/**
* <p>Method to test all the add methods in addition to the test of the remaining methods.</p>
*
*/
public void testIntegrationConstructorAndMethods002(){
try {
//Testing Constructor
LdapName temp=new LdapName("t=test");
LdapName temp2=new LdapName(list);
list.add(aux);
LdapName temp3=new LdapName(list);
assertNotNull(temp);
assertNotNull(temp2);
assertNotNull(temp3);
//Testing Add Methods
temp.add(0,aux);
temp.add(0,"f=flag");
temp.add(aux);
temp.add("f=flag");
temp.addAll(0,list);
temp.addAll(0,temp2);
temp.addAll(list);
temp.addAll(temp2);
//Testing methods
assertTrue(temp.hashCode()!=0);
assertFalse(temp.isEmpty());
assertNotNull(temp.remove(0));
assertTrue(temp.size()!=0);
while(temp.size()>0){
assertNotNull(temp.remove(temp.size()-1));
}
assertTrue(temp.isEmpty());
//Testing String
String x="t=test,T=TEST";
LdapName temp4=new LdapName(x);
assertEquals(x.getBytes().length,temp4.toString().getBytes().length);
} catch (InvalidNameException e) {
fail("Failed with:"+e);
}
}
示例6: testSerializationCompatibility
import javax.naming.ldap.LdapName; //导入方法依赖的package包/类
public void testSerializationCompatibility() throws Exception{
LdapName object = new LdapName("t=test\\, , t1=\\ test1");
object.add(new Rdn("t2=te\\ st2"));
SerializationTest.verifyGolden(this, object);
}
示例7: testAddIntRdn006
import javax.naming.ldap.LdapName; //导入方法依赖的package包/类
/**
* <p>
* Test method for 'javax.naming.ldap.LdapName.add(int, Rdn)'
* </p>
* <p>
* Here we are testing if this method correctly adds an RDN to an
* LdapName at the given index.
* </p>
* <p>
* The expected result is the Rdn being inserted in the correct position.
* </p>
*/
public void testAddIntRdn006() throws Exception {
LdapName ln = new LdapName("");
Rdn toadd = new Rdn("");
ln.add(0, toadd);
assertEquals("", ln.toString());
}
示例8: testAddIntString004
import javax.naming.ldap.LdapName; //导入方法依赖的package包/类
/**
* <p>
* Test method for 'javax.naming.ldap.LdapName.add(int, String)'
* </p>
* <p>
* Here we are testing if this method correctly adds a name to an
* LdapName at the given index.
* </p>
* <p>
* The expected result is the name being inserted in the correct position.
* </p>
*/
public void testAddIntString004() throws Exception {
String toadd = "cn=common";
LdapName ln = new LdapName("t=test");
ln.add(1, toadd);
assertEquals("cn=common,t=test", ln.toString());
}
示例9: testAddIntString003
import javax.naming.ldap.LdapName; //导入方法依赖的package包/类
/**
* <p>
* Test method for 'javax.naming.ldap.LdapName.add(int, String)'
* </p>
* <p>
* Here we are testing if this method correctly adds a name to an
* LdapName at the given index.
* </p>
* <p>
* The expected result is a NullPointerException.
* </p>
*/
public void testAddIntString003() throws Exception {
try {
String toadd = null;
LdapName ln = new LdapName("t=test");
ln.add(1, toadd);
fail("NPE expected");
} catch (NullPointerException e) {}
}
示例10: testAddIntRdn002
import javax.naming.ldap.LdapName; //导入方法依赖的package包/类
/**
* <p>
* Test method for 'javax.naming.ldap.LdapName.add(int, Rdn)'
* </p>
* <p>
* Here we are testing if this method correctly adds an RDN to an
* LdapName at the given index.
* </p>
* <p>
* The expected result is an IndexOutOfBoundsException.
* </p>
*/
public void testAddIntRdn002() throws Exception {
try {
LdapName ln = new LdapName("t=test");
Rdn toadd = new Rdn("cn=common");
ln.add(3, toadd);
fail("IndexOutOfBoundsException expected");
} catch (IndexOutOfBoundsException e) {}
}
示例11: testAddIntString008
import javax.naming.ldap.LdapName; //导入方法依赖的package包/类
/**
* <p>
* Test method for 'javax.naming.ldap.LdapName.add(int, String)'
* </p>
* <p>
* Here we are testing if this method correctly adds a name to an
* LdapName at the given index.
* </p>
* <p>
* The expected result is the name being inserted in the correct position.
* </p>
*/
public void testAddIntString008() throws Exception {
String toadd = "t=test";
LdapName ln = new LdapName("");
ln.add(0, toadd);
assertEquals("t=test", ln.toString());
}
示例12: testAddIntRdn003
import javax.naming.ldap.LdapName; //导入方法依赖的package包/类
/**
* <p>
* Test method for 'javax.naming.ldap.LdapName.add(int, Rdn)'
* </p>
* <p>
* Here we are testing if this method correctly adds an RDN to an
* LdapName at the given index.
* </p>
* <p>
* The expected result is a NullPointerException.
* </p>
*/
public void testAddIntRdn003() throws Exception {
try {
LdapName ln = new LdapName("t=test");
Rdn toadd = null;
ln.add(1, toadd);
fail("NPE expected");
} catch (NullPointerException e) {}
}
示例13: testAddString005
import javax.naming.ldap.LdapName; //导入方法依赖的package包/类
/**
* <p>
* Test method for 'javax.naming.ldap.LdapName.add(String)'
* </p>
* <p>
* Here we are testing if this method correctly appends a name to the end of
* an LdapName.
* </p>
* <p>
* The expected result is the name added to the end of the LdapName.
* </p>
*/
public void testAddString005() throws Exception {
LdapName ln = new LdapName("");
String x = "";
ln.add(x);
assertEquals("", ln.toString());
}
示例14: testAddString006
import javax.naming.ldap.LdapName; //导入方法依赖的package包/类
/**
* <p>
* Test method for 'javax.naming.ldap.LdapName.add(String)'
* </p>
* <p>
* Here we are testing if this method correctly appends a name to the end of
* an LdapName.
* </p>
* <p>
* The expected result is the name added to the end of the LdapName.
* </p>
*/
public void testAddString006() throws Exception {
LdapName ln = new LdapName("");
String x = "t=test";
ln.add(x);
assertEquals("t=test", ln.toString());
}
示例15: testAddString007
import javax.naming.ldap.LdapName; //导入方法依赖的package包/类
/**
* <p>
* Test method for 'javax.naming.ldap.LdapName.add(String)'
* </p>
* <p>
* Here we are testing if this method correctly appends a name to the end of
* an LdapName.
* </p>
* <p>
* The expected result is the name added to the end of the LdapName.
* </p>
*/
public void testAddString007() throws Exception {
LinkedList ll = new LinkedList();
ll.add(new Rdn("t=test"));
LdapName ln = new LdapName(ll);
ln.add("t1=test1");
ll.remove(0);
assertEquals(2, ln.size());
}