public void testToString() { log.setMethod("testToString()"); String str; AttributeModificationException ex = new AttributeModificationException( "sample message"); str = ex.toString(); assertTrue(str.indexOf("sample message") >= 0); assertFalse(str.indexOf("sample id") >= 0); assertFalse(str.indexOf("sample value") >= 0); ModificationItem items[] = new ModificationItem[] { new ModificationItem( DirContext.ADD_ATTRIBUTE, new BasicAttribute("sample id", "sample value")), }; ex.setUnexecutedModifications(items); str = ex.toString(); assertTrue(str.indexOf("sample message") >= 0); assertTrue(str.indexOf("sample id") >= 0); assertTrue(str.indexOf("sample value") >= 0); }
public void testSetUnexecutedModifications() throws InvalidNameException { AttributeModificationException ex1 = new AttributeModificationException( "Test 1"); AttributeModificationException ex2 = new AttributeModificationException( "Test 2"); Name name = new CompositeName("TestSetUnexecutedModifications"); ex1.setRemainingName(name); ex1.setRootCause(ex2); ModificationItem[] items = { new ModificationItem(DirContext.ADD_ATTRIBUTE, new BasicAttribute("test1")), new ModificationItem(DirContext.ADD_ATTRIBUTE, new BasicAttribute("test2")), }; ex1.setUnexecutedModifications(items); assertTrue(ex1.toString(false).equals(ex1.toString())); assertTrue(ex1.toString(true).equals(ex1.toString())); }
public void modify() throws AttributeModificationException, NamingException{ //Get a reference to a directory context int modType; // decode the modification type to one which the context will understand switch (modifyType){ case ldapConnection.MODIFY_REPLACE: // attributes require name=value pairs modType = DirContext.REPLACE_ATTRIBUTE; break; case ldapConnection.MODIFY_ADD: modType = DirContext.ADD_ATTRIBUTE; // attributes require name=value pairs break; case ldapConnection.MODIFY_DELETE: modType = DirContext.REMOVE_ATTRIBUTE; // attributes require names only break; default: modType = DirContext.REPLACE_ATTRIBUTE; }// switch DirContext ctx = new InitialDirContext(env); Attributes attributes = processAttributes(); ctx.modifyAttributes(dn, modType, attributes); ctx.close(); }
public void testGetterAndSetter() { log.setMethod("testGetterAndSetter()"); AttributeModificationException ex = new AttributeModificationException( "sample message"); ModificationItem items[] = new ModificationItem[] { new ModificationItem( DirContext.ADD_ATTRIBUTE, new BasicAttribute("sample id", "sample value")), }; ex.setUnexecutedModifications(items); assertSame(items, ex.getUnexecutedModifications()); }
public void testSetRemainingName() throws InvalidNameException { AttributeModificationException ex1 = new AttributeModificationException( "Test 1"); AttributeModificationException ex2 = new AttributeModificationException( "Test 2"); Name name = new CompositeName("TestSetRemainingName"); ex1.setRootCause(ex2); ex1.setRemainingName(name); boolean check = ex1.toString().indexOf( ex1.getRemainingName().toString() + "'") > 0; assertTrue(check); }
public void testSetRemainingName2() throws InvalidNameException { AttributeModificationException ex1 = new AttributeModificationException( "Test 1"); AttributeModificationException ex2 = new AttributeModificationException( "Test 2"); Name name = new CompositeName("TestSetRemainingName2"); ex1.setRemainingName(name); ex1.setRootCause(ex2); boolean check = ex1.toString().indexOf( "[Root exception is " + ex2.toString()) > 0; assertTrue(check); }
public void testGetUnexecutedModifications() { AttributeModificationException exception = new AttributeModificationException( "Test"); assertNull(exception.getUnexecutedModifications()); }
public void testGetUnexecutedModifications2() { AttributeModificationException exception = new AttributeModificationException( null); assertNull(exception.getUnexecutedModifications()); }
public void testGetUnexecutedModifications3() { AttributeModificationException exception = new AttributeModificationException(); assertNull(exception.getUnexecutedModifications()); }