Permalink
Browse files

proved that a MailMessageImpl can keep Subject lines up to 500 chars

  • Loading branch information...
1 parent e5dca03 commit c08fe77fce0a21bf74179733660f99ff62700ba0 @rjo1970 rjo1970 committed Feb 15, 2011
@@ -29,6 +29,16 @@ public void testAddHeader() {
}
@Test
+ public void testLongSubjectHeader() {
+ StringBuffer b = new StringBuffer();
+ for (int i =0; i<500; i++) {
+ b.append("X");
+ }
+ message.addHeader("Subject", b.toString());
+ assertEquals("Subject: "+b+"\n\n\n", message.toString());
+ }
+
+ @Test
public void testEmptyHeaderValue() {
String[] values = message.getHeaderValues("NOT PRESENT");
assertEquals(0, values.length);
@@ -58,7 +58,6 @@ public void testNoMessageSentButWaitingDoesNotHang() {
@Test
public void testSend() {
- System.out.println("testSend");
try {
sendMessage(SMTP_PORT, From, Subject, Body, To);
} catch (Exception e) {
@@ -73,6 +72,26 @@ public void testSend() {
}
@Test
+ public void testSendWithLongSubject() {
+ StringBuffer b = new StringBuffer();
+ for(int i=0; i<500; i++)
+ b.append("X");
+ String longSubject = b.toString();
+ try {
+ sendMessage(SMTP_PORT, From, b.toString(), Body, To);
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail("Unexpected exception: " + e);
+ }
+ server.anticipateMessageCountFor(1, 500);
+ assertTrue(server.getEmailCount() == 1);
+ MailMessage email = server.getMessage(0);
+ assertEquals(longSubject, email.getFirstHeaderValue("Subject"));
+ assertEquals(500, longSubject.length());
+ assertEquals("Test Body", email.getBody());
+ }
+
+ @Test
public void testThreadedSend() {
server.setThreaded(true);
try {
@@ -131,7 +150,6 @@ public void testSendTwoMessagesSameConnection() {
@Test
public void testSendingFileAttachment() throws MessagingException {
- System.out.println("testSendingFileAttachment");
Properties props = getMailProperties(SMTP_PORT);
props.put("mail.smtp.host", "localhost");
Session session = Session.getDefaultInstance(props, null);

0 comments on commit c08fe77

Please sign in to comment.