package org.eclipse.jgit.lib;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
import java.util.Date;
import java.util.TimeZone;
public void nullForEmailShouldThrowIllegalArgumentException() {
new PersonIdent("A U Thor", null);
}
+
+ @Test
+ public void testToExternalStringTrimsNameAndEmail() throws Exception {
+ PersonIdent personIdent = new PersonIdent(" A U Thor ",
+ " author@example.com ");
+
+ String externalString = personIdent.toExternalString();
+
+ assertTrue(externalString.startsWith("A U Thor <author@example.com>"));
+ }
+
}
*/
public String toExternalString() {
final StringBuilder r = new StringBuilder();
- r.append(getName());
+ r.append(getName().trim());
r.append(" <"); //$NON-NLS-1$
- r.append(getEmailAddress());
+ r.append(getEmailAddress().trim());
r.append("> "); //$NON-NLS-1$
r.append(when / 1000);
r.append(' ');