本文整理匯總了Java中javax.naming.ldap.LdapName.clone方法的典型用法代碼示例。如果您正苦於以下問題:Java LdapName.clone方法的具體用法?Java LdapName.clone怎麽用?Java LdapName.clone使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.naming.ldap.LdapName
的用法示例。
在下文中一共展示了LdapName.clone方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: 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);
}
}
示例2: testCompleteIntegration
import javax.naming.ldap.LdapName; //導入方法依賴的package包/類
/**
* <p>Test method to test the complete integration of the class.</p>
*
*/
public void testCompleteIntegration(){
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 String
String x="t=test,T=TEST";
LdapName temp4=new LdapName(x);
assertEquals(x.getBytes().length,temp4.toString().getBytes().length);
//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));
//Testing Clone, Equlas and CompareTo
if(!temp.clone().getClass().equals(temp.getClass()))fail("Fail.");
assertEquals(0,temp.compareTo(temp));
assertTrue(temp.compareTo(temp2)>0);
assertTrue(temp.compareTo(temp3)>0);
assertFalse(temp.equals(null));
assertTrue(temp.equals(temp));
assertFalse(temp.equals(temp2));
//Testing SartWith and EndWith methods
assertTrue(temp.endsWith(list));
assertTrue(temp.endsWith(temp2));
assertTrue(temp.startsWith(list));
assertTrue(temp.startsWith(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());
} catch (InvalidNameException e) {
fail("Failed with:"+e);
}
}
示例3: testClone002
import javax.naming.ldap.LdapName; //導入方法依賴的package包/類
/**
* <p>
* Test method for 'javax.naming.ldap.LdapName.clone()'
* </p>
* <p>
* Here we are testing if this method correctly clones this LdapName.
* </p>
* <p>
* The expected result in this case is if a change in primary object no
* affect the clone.
* </p>
*/
public void testClone002() throws Exception {
LdapName ln = new LdapName("t=test");
LdapName copy = (LdapName) ln.clone();
ln.add("ch=change");
assertNotSame(ln.toString(), copy.toString());
}
示例4: testClone003
import javax.naming.ldap.LdapName; //導入方法依賴的package包/類
/**
* <p>
* Test method for 'javax.naming.ldap.LdapName.clone()'
* </p>
* <p>
* Here we are testing if this method correctly clones this LdapName.
* </p>
* <p>
* The expected result in this case is if a change in the clone object no
* affect the primary.
* </p>
*/
public void testClone003() throws Exception {
LdapName ln = new LdapName("t=test");
LdapName copy = (LdapName) ln.clone();
copy.add("ch=change");
assertNotSame(ln.toString(), copy.toString());
}
示例5: testClone001
import javax.naming.ldap.LdapName; //導入方法依賴的package包/類
/**
* <p>
* Test method for 'javax.naming.ldap.LdapName.clone()'
* </p>
* <p>
* Here we are testing if a clone of an object of LdapName is equal to the
* original.
* </p>
* <p>
* The expected result in this case is true.
* </p>
*/
public void testClone001() throws Exception {
LdapName ln = new LdapName("t=test");
LdapName copy = (LdapName) ln.clone();
assertEquals(ln, copy);
}
示例6: testClone004
import javax.naming.ldap.LdapName; //導入方法依賴的package包/類
/**
* <p>
* Test method for 'javax.naming.ldap.LdapName.clone()'
* </p>
* <p>
* Here we are testing if this method correctly clones this LdapName.
* </p>
* <p>
* The expected result in this case is if clone of an empty object is equal
* to its primary.
* </p>
*/
public void testClone004() throws Exception {
LdapName ln = new LdapName("");
LdapName copy = (LdapName) ln.clone();
assertEquals(ln, copy);
}