Author: norman
Date: Mon Oct 16 06:34:21 2006
New Revision: 464486
URL: http://svn.apache.org/viewvc?view=rev&rev=464486
Log:
Add 2 more junit tests for pipeling
Modified:
james/server/trunk/src/test/org/apache/james/smtpserver/SMTPServerTest.java
Modified:
james/server/trunk/src/test/org/apache/james/smtpserver/SMTPServerTest.java
URL:
http://svn.apache.org/viewvc/james/server/trunk/src/test/org/apache/james/smtpserver/SMTPServerTest.java?view=diff&rev=464486&r1=464485&r2=464486
==============================================================================
--- james/server/trunk/src/test/org/apache/james/smtpserver/SMTPServerTest.java
(original)
+++ james/server/trunk/src/test/org/apache/james/smtpserver/SMTPServerTest.java
Mon Oct 16 06:34:21 2006
@@ -52,7 +52,6 @@
import javax.mail.Session;
import javax.mail.internet.MimeMessage;
-import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -1455,6 +1454,7 @@
smtpProtocol.quit();
}
+ // See http://www.ietf.org/rfc/rfc2920.txt 4: Examples
public void testPipelining() throws Exception {
StringBuffer buf = new StringBuffer();
finishSetUp(m_testConfiguration);
@@ -1490,6 +1490,96 @@
assertEquals("MAIL FROM accepted" , 250,
Integer.parseInt(in.readLine().split(" ")[0]));
assertEquals("RCPT TO accepted" , 250,
Integer.parseInt(in.readLine().split(" ")[0]));
assertEquals("DATA accepted" , 354,
Integer.parseInt(in.readLine().split(" ")[0]));
+ assertEquals("Message accepted" , 250,
Integer.parseInt(in.readLine().split(" ")[0]));
+ in.close();
+ out.close();
+ client.close();
+ }
+
+ // See http://www.ietf.org/rfc/rfc2920.txt 4: Examples
+ public void testRejectAllRCPTPipelining() throws Exception {
+ StringBuffer buf = new StringBuffer();
+ m_testConfiguration.setAuthorizedAddresses("");
+ finishSetUp(m_testConfiguration);
+ Socket client = new Socket("127.0.0.1",m_smtpListenerPort);
+
+ buf.append("HELO TEST");
+ buf.append("\r\n");
+ buf.append("MAIL FROM: <[EMAIL PROTECTED]>");
+ buf.append("\r\n");
+ buf.append("RCPT TO: <[EMAIL PROTECTED]>");
+ buf.append("\r\n");
+ buf.append("RCPT TO: <[EMAIL PROTECTED]>");
+ buf.append("\r\n");
+ buf.append("DATA");
+ buf.append("\r\n");
+ buf.append("Subject: test");
+ buf.append("\r\n");;
+ buf.append("\r\n");
+ buf.append("content");
+ buf.append("\r\n");
+ buf.append(".");
+ buf.append("\r\n");
+ buf.append("quit");
+ buf.append("\r\n");
+
+ OutputStream out = client.getOutputStream();
+
+ out.write(buf.toString().getBytes());
+ out.flush();
+
+ BufferedReader in = new BufferedReader(new
InputStreamReader(client.getInputStream()));
+
+ assertEquals("Connection made" , 220,
Integer.parseInt(in.readLine().split(" ")[0]));
+ assertEquals("HELO accepted" , 250,
Integer.parseInt(in.readLine().split(" ")[0]));
+ assertEquals("MAIL FROM accepted" , 250,
Integer.parseInt(in.readLine().split(" ")[0]));
+ assertEquals("RCPT TO rejected" , 550,
Integer.parseInt(in.readLine().split(" ")[0]));
+ assertEquals("RCPT TO rejected" , 550,
Integer.parseInt(in.readLine().split(" ")[0]));
+ assertEquals("DATA not accepted" , 503,
Integer.parseInt(in.readLine().split(" ")[0]));
+ in.close();
+ out.close();
+ client.close();
+ }
+
+ public void testRejectOneRCPTPipelining() throws Exception {
+ StringBuffer buf = new StringBuffer();
+ m_testConfiguration.setAuthorizedAddresses("");
+ finishSetUp(m_testConfiguration);
+ Socket client = new Socket("127.0.0.1",m_smtpListenerPort);
+
+ buf.append("HELO TEST");
+ buf.append("\r\n");
+ buf.append("MAIL FROM: <[EMAIL PROTECTED]>");
+ buf.append("\r\n");
+ buf.append("RCPT TO: <[EMAIL PROTECTED]>");
+ buf.append("\r\n");
+ buf.append("RCPT TO: <[EMAIL PROTECTED]>");
+ buf.append("\r\n");
+ buf.append("DATA");
+ buf.append("\r\n");
+ buf.append("Subject: test");
+ buf.append("\r\n");;
+ buf.append("\r\n");
+ buf.append("content");
+ buf.append("\r\n");
+ buf.append(".");
+ buf.append("\r\n");
+ buf.append("quit");
+ buf.append("\r\n");
+
+ OutputStream out = client.getOutputStream();
+
+ out.write(buf.toString().getBytes());
+ out.flush();
+
+ BufferedReader in = new BufferedReader(new
InputStreamReader(client.getInputStream()));
+
+ assertEquals("Connection made" , 220,
Integer.parseInt(in.readLine().split(" ")[0]));
+ assertEquals("HELO accepted" , 250,
Integer.parseInt(in.readLine().split(" ")[0]));
+ assertEquals("MAIL FROM accepted" , 250,
Integer.parseInt(in.readLine().split(" ")[0]));
+ assertEquals("RCPT TO rejected" , 550,
Integer.parseInt(in.readLine().split(" ")[0]));
+ assertEquals("RCPT accepted" , 250,
Integer.parseInt(in.readLine().split(" ")[0]));
+ assertEquals("DATA accepted" , 354,
Integer.parseInt(in.readLine().split(" ")[0]));
assertEquals("Message accepted" , 250,
Integer.parseInt(in.readLine().split(" ")[0]));
in.close();
out.close();
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]