1 36 package org.columba.ristretto.smtp.parser; 37 38 import junit.framework.TestCase; 39 40 import org.columba.ristretto.parser.ParserException; 41 import org.columba.ristretto.smtp.SMTPResponse; 42 43 public class SMTPResponseParserTest extends TestCase { 44 45 public void testSingleMessage() throws ParserException { 46 String responseString = "250 OK\r\n"; 47 SMTPResponse response = SMTPResponseParser.parse(responseString); 48 49 assertTrue( response.getCode() == 250); 50 assertTrue( response.getMessage().equals("OK")); 51 assertFalse( response.isHasSuccessor() ); 52 } 53 54 public void testSingleNoMessage() throws ParserException { 55 String responseString = "250\r\n"; 56 SMTPResponse response = SMTPResponseParser.parse(responseString); 57 58 assertTrue( response.getCode() == 250); 59 assertTrue( response.getMessage() == null); 60 assertFalse( response.isHasSuccessor() ); 61 } 62 63 public void testSingleGreeting() throws ParserException { 64 String responseString = "220 smtp.domain greeting\r\n"; 65 SMTPResponse response = SMTPResponseParser.parse(responseString); 66 67 assertTrue( response.getCode() == 220); 68 assertTrue( response.getDomain().equals("smtp.domain")); 69 assertTrue( response.getMessage().equals("greeting")); 70 assertFalse( response.isHasSuccessor() ); 71 } 72 73 public void testSingleMessageSuccessor() throws ParserException { 74 String responseString = "250-OK\r\n"; 75 SMTPResponse response = SMTPResponseParser.parse(responseString); 76 77 assertTrue( response.getCode() == 250); 78 assertTrue( response.getMessage().equals("OK")); 79 assertTrue( response.isHasSuccessor() ); 80 } 81 } 82 | Popular Tags |