Author: bago Date: Mon May 15 16:59:53 2006 New Revision: 406781 URL: http://svn.apache.org/viewcvs?rev=406781&view=rev Log: Converted SMTPServerTest to use commons-net SMTPClient instead of ristretto SMTPProtocol (part of JAMES-498) Added two tests, fixed a bug in the size check of the mock MailServer.
Modified: james/server/trunk/src/test/org/apache/james/smtpserver/SMTPServerTest.java james/server/trunk/src/test/org/apache/james/test/mock/james/MockMailServer.java Modified: james/server/trunk/src/test/org/apache/james/smtpserver/SMTPServerTest.java URL: http://svn.apache.org/viewcvs/james/server/trunk/src/test/org/apache/james/smtpserver/SMTPServerTest.java?rev=406781&r1=406780&r2=406781&view=diff ============================================================================== --- james/server/trunk/src/test/org/apache/james/smtpserver/SMTPServerTest.java (original) +++ james/server/trunk/src/test/org/apache/james/smtpserver/SMTPServerTest.java Mon May 15 16:59:53 2006 @@ -20,6 +20,8 @@ import org.apache.avalon.cornerstone.services.store.Store; import org.apache.avalon.cornerstone.services.threads.ThreadManager; import org.apache.avalon.framework.container.ContainerUtil; +import org.apache.commons.net.smtp.SMTPClient; +import org.apache.commons.net.smtp.SMTPReply; import org.apache.james.Constants; import org.apache.james.core.MailImpl; import org.apache.james.services.DNSServer; @@ -41,26 +43,15 @@ import org.apache.james.util.Base64; import org.apache.james.util.connection.SimpleConnectionManager; import org.apache.mailet.MailAddress; -import org.columba.ristretto.composer.MimeTreeRenderer; -import org.columba.ristretto.io.CharSequenceSource; -import org.columba.ristretto.message.Address; -import org.columba.ristretto.message.Header; -import org.columba.ristretto.message.LocalMimePart; -import org.columba.ristretto.message.MimeHeader; -import org.columba.ristretto.message.MimeType; -import org.columba.ristretto.smtp.SMTPException; -import org.columba.ristretto.smtp.SMTPProtocol; -import org.columba.ristretto.smtp.SMTPResponse; import javax.mail.MessagingException; import javax.mail.Session; import javax.mail.internet.MimeMessage; -import javax.mail.util.SharedByteArrayInputStream; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; -import java.io.InputStream; +import java.io.Writer; import java.net.InetAddress; import java.net.UnknownHostException; import java.util.ArrayList; @@ -179,63 +170,59 @@ return m_serviceManager; } - private LocalMimePart createMail() { - MimeHeader mimeHeader = new MimeHeader(new Header()); - mimeHeader.set("Mime-Version", "1.0"); - LocalMimePart mail = new LocalMimePart(mimeHeader); - MimeHeader header = mail.getHeader(); - header.setMimeType(new MimeType("text", "plain")); - - mail.setBody(new CharSequenceSource("James Unit Test Body")); - return mail; - } - - public void testSimpleMailSendWithEHLO() throws Exception, SMTPException { + public void testSimpleMailSendWithEHLO() throws Exception { finishSetUp(m_testConfiguration); - - SMTPProtocol smtpProtocol = new SMTPProtocol("127.0.0.1", m_smtpListenerPort); - smtpProtocol.openPort(); + + SMTPClient smtpProtocol = new SMTPClient(); + smtpProtocol.connect("127.0.0.1", m_smtpListenerPort); // no message there, yet assertNull("no mail received by mail server", m_mailServer.getLastMail()); - String[] capabilityStrings = smtpProtocol.ehlo(InetAddress.getLocalHost()); - assertEquals("capabilities", 2, capabilityStrings.length); - List capabilitieslist = Arrays.asList(capabilityStrings); + smtpProtocol.sendCommand("EHLO "+InetAddress.getLocalHost()); + String[] capabilityRes = smtpProtocol.getReplyStrings(); + + List capabilitieslist = new ArrayList(); + for (int i = 1; i < capabilityRes.length; i++) { + capabilitieslist.add(capabilityRes[i].substring(4)); + } + + assertEquals("capabilities", 2, capabilitieslist.size()); assertTrue("capabilities present PIPELINING", capabilitieslist.contains("PIPELINING")); assertTrue("capabilities present ENHANCEDSTATUSCODES", capabilitieslist.contains("ENHANCEDSTATUSCODES")); //assertTrue("capabilities present 8BITMIME", capabilitieslist.contains("8BITMIME")); - smtpProtocol.mail(new Address("[EMAIL PROTECTED]")); - smtpProtocol.rcpt(new Address("[EMAIL PROTECTED]")); - - smtpProtocol.data(MimeTreeRenderer.getInstance().renderMimePart(createMail())); + smtpProtocol.setSender("[EMAIL PROTECTED]"); + smtpProtocol.addRecipient("[EMAIL PROTECTED]"); + smtpProtocol.sendShortMessageData("Subject: test\r\n\r\nBody\r\n\r\n.\r\n"); smtpProtocol.quit(); + smtpProtocol.disconnect(); // mail was propagated by SMTPServer assertNotNull("mail received by mail server", m_mailServer.getLastMail()); } public void testEmptyMessage() throws Exception { - InputStream mSource = new SharedByteArrayInputStream(("").getBytes()); finishSetUp(m_testConfiguration); - SMTPProtocol smtpProtocol = new SMTPProtocol("127.0.0.1", m_smtpListenerPort); - smtpProtocol.openPort(); + SMTPClient smtp = new SMTPClient(); + smtp.connect("127.0.0.1", m_smtpListenerPort); // no message there, yet assertNull("no mail received by mail server", m_mailServer.getLastMail()); - smtpProtocol.helo(InetAddress.getLocalHost()); + smtp.helo(InetAddress.getLocalHost().toString()); - smtpProtocol.mail(new Address("[EMAIL PROTECTED]")); + smtp.setSender("[EMAIL PROTECTED]"); - smtpProtocol.rcpt(new Address("[EMAIL PROTECTED]")); + smtp.addRecipient("[EMAIL PROTECTED]"); - smtpProtocol.data(mSource); + smtp.sendShortMessageData(""); - smtpProtocol.quit(); + smtp.quit(); + + smtp.disconnect(); // mail was propagated by SMTPServer assertNotNull("mail received by mail server", m_mailServer.getLastMail()); @@ -249,436 +236,424 @@ assertEquals(size, 2); } - public void testSimpleMailSendWithHELO() throws Exception, SMTPException { + public void testSimpleMailSendWithHELO() throws Exception { finishSetUp(m_testConfiguration); - SMTPProtocol smtpProtocol = new SMTPProtocol("127.0.0.1", m_smtpListenerPort); - smtpProtocol.openPort(); + SMTPClient smtpProtocol = new SMTPClient(); + smtpProtocol.connect("127.0.0.1", m_smtpListenerPort); // no message there, yet assertNull("no mail received by mail server", m_mailServer.getLastMail()); - smtpProtocol.helo(InetAddress.getLocalHost()); - - smtpProtocol.mail(new Address("[EMAIL PROTECTED]")); - smtpProtocol.rcpt(new Address("[EMAIL PROTECTED]")); + smtpProtocol.helo(InetAddress.getLocalHost().toString()); + + smtpProtocol.setSender("[EMAIL PROTECTED]"); + + smtpProtocol.addRecipient("[EMAIL PROTECTED]"); - smtpProtocol.data(MimeTreeRenderer.getInstance().renderMimePart(createMail())); + smtpProtocol.sendShortMessageData("Subject: test mail\r\n\r\nTest body\r\n.\r\n"); smtpProtocol.quit(); + smtpProtocol.disconnect(); // mail was propagated by SMTPServer assertNotNull("mail received by mail server", m_mailServer.getLastMail()); } - public void testTwoSimultaneousMails() throws Exception, SMTPException { + public void testTwoSimultaneousMails() throws Exception { finishSetUp(m_testConfiguration); - SMTPProtocol smtpProtocol1 = new SMTPProtocol("127.0.0.1", m_smtpListenerPort); - SMTPProtocol smtpProtocol2 = new SMTPProtocol("127.0.0.1", m_smtpListenerPort); - smtpProtocol1.openPort(); - smtpProtocol2.openPort(); + SMTPClient smtpProtocol1 = new SMTPClient(); + smtpProtocol1.connect("127.0.0.1", m_smtpListenerPort); + SMTPClient smtpProtocol2 = new SMTPClient(); + smtpProtocol2.connect("127.0.0.1", m_smtpListenerPort); - assertEquals("first connection taken", 1, smtpProtocol1.getState()); - assertEquals("second connection taken", 1, smtpProtocol2.getState()); + assertTrue("first connection taken",smtpProtocol1.isConnected()); + assertTrue("second connection taken",smtpProtocol2.isConnected()); // no message there, yet assertNull("no mail received by mail server", m_mailServer.getLastMail()); - smtpProtocol1.helo(InetAddress.getLocalHost()); - smtpProtocol2.helo(InetAddress.getLocalHost()); + smtpProtocol1.helo(InetAddress.getLocalHost().toString()); + smtpProtocol2.helo(InetAddress.getLocalHost().toString()); String sender1 = "[EMAIL PROTECTED]"; String recipient1 = "[EMAIL PROTECTED]"; - smtpProtocol1.mail(new Address(sender1)); - smtpProtocol1.rcpt(new Address(recipient1)); + smtpProtocol1.setSender(sender1); + smtpProtocol1.addRecipient(recipient1); String sender2 = "[EMAIL PROTECTED]"; String recipient2 = "[EMAIL PROTECTED]"; - smtpProtocol2.mail(new Address(sender2)); - smtpProtocol2.rcpt(new Address(recipient2)); + smtpProtocol2.setSender(sender2); + smtpProtocol2.addRecipient(recipient2); - smtpProtocol1.data(MimeTreeRenderer.getInstance().renderMimePart(createMail())); + smtpProtocol1.sendShortMessageData("Subject: test\r\n\r\nTest body\r\n.\r\n"); verifyLastMail(sender1, recipient1, null); - smtpProtocol2.data(MimeTreeRenderer.getInstance().renderMimePart(createMail())); + smtpProtocol2.sendShortMessageData("Subject: test\r\n\r\nTest body\r\n.\r\n"); verifyLastMail(sender2, recipient2, null); smtpProtocol1.quit(); smtpProtocol2.quit(); + + smtpProtocol1.disconnect(); + smtpProtocol2.disconnect(); } - public void testTwoMailsInSequence() throws Exception, SMTPException { + public void testTwoMailsInSequence() throws Exception { finishSetUp(m_testConfiguration); - SMTPProtocol smtpProtocol1 = new SMTPProtocol("127.0.0.1", m_smtpListenerPort); - smtpProtocol1.openPort(); + SMTPClient smtpProtocol1 = new SMTPClient(); + smtpProtocol1.connect("127.0.0.1", m_smtpListenerPort); - assertEquals("first connection taken", 1, smtpProtocol1.getState()); + assertTrue("first connection taken", smtpProtocol1.isConnected()); // no message there, yet assertNull("no mail received by mail server", m_mailServer.getLastMail()); - smtpProtocol1.helo(InetAddress.getLocalHost()); + smtpProtocol1.helo(InetAddress.getLocalHost().toString()); String sender1 = "[EMAIL PROTECTED]"; String recipient1 = "[EMAIL PROTECTED]"; - smtpProtocol1.mail(new Address(sender1)); - smtpProtocol1.rcpt(new Address(recipient1)); + smtpProtocol1.setSender(sender1); + smtpProtocol1.addRecipient(recipient1); - smtpProtocol1.data(MimeTreeRenderer.getInstance().renderMimePart(createMail())); + smtpProtocol1.sendShortMessageData("Subject: test\r\n\r\nTest body\r\n"); verifyLastMail(sender1, recipient1, null); String sender2 = "[EMAIL PROTECTED]"; String recipient2 = "[EMAIL PROTECTED]"; - smtpProtocol1.mail(new Address(sender2)); - smtpProtocol1.rcpt(new Address(recipient2)); + smtpProtocol1.setSender(sender2); + smtpProtocol1.addRecipient(recipient2); - smtpProtocol1.data(MimeTreeRenderer.getInstance().renderMimePart(createMail())); + smtpProtocol1.sendShortMessageData("Subject: test2\r\n\r\nTest body2\r\n"); verifyLastMail(sender2, recipient2, null); smtpProtocol1.quit(); + smtpProtocol1.disconnect(); } - public void testHeloResolv() throws Exception, SMTPException { + public void testHeloResolv() throws Exception { m_testConfiguration.setHeloResolv(); m_testConfiguration.setAuthorizedAddresses("192.168.0.1"); finishSetUp(m_testConfiguration); - MySMTPProtocol smtpProtocol1 = new MySMTPProtocol("127.0.0.1", m_smtpListenerPort); - smtpProtocol1.openPort(); + SMTPClient smtpProtocol1 = new SMTPClient(); + smtpProtocol1.connect("127.0.0.1", m_smtpListenerPort); - assertEquals("first connection taken", 1, smtpProtocol1.getState()); + assertTrue("first connection taken", smtpProtocol1.isConnected()); // no message there, yet assertNull("no mail received by mail server", m_mailServer.getLastMail()); - String[] helo1 = new String[] { "abgsfe3rsf.de"}; - String[] helo2 = new String[] { "james.apache.org" }; + String helo1 = "abgsfe3rsf.de"; + String helo2 = "james.apache.org"; smtpProtocol1.sendCommand("helo",helo1); - SMTPResponse response = smtpProtocol1.getResponse(); // this should give a 501 code cause the helo could not resolved - assertEquals("expected error: helo could not resolved", 501, response.getCode()); + assertEquals("expected error: helo could not resolved", 501, smtpProtocol1.getReplyCode()); smtpProtocol1.sendCommand("helo", helo2); - SMTPResponse response2 = smtpProtocol1.getResponse(); // helo is resolvable. so this should give a 250 code - assertEquals("Helo accepted", 250, response2.getCode()); + assertEquals("Helo accepted", 250, smtpProtocol1.getReplyCode()); smtpProtocol1.quit(); } - public void testHeloResolvDefault() throws Exception, SMTPException { + public void testHeloResolvDefault() throws Exception { finishSetUp(m_testConfiguration); - MySMTPProtocol smtpProtocol1 = new MySMTPProtocol("127.0.0.1", m_smtpListenerPort); - smtpProtocol1.openPort(); + SMTPClient smtpProtocol1 = new SMTPClient(); + smtpProtocol1.connect("127.0.0.1", m_smtpListenerPort); - smtpProtocol1.sendCommand("helo",new String[]{"abgsfe3rsf.de"}); - SMTPResponse response = smtpProtocol1.getResponse(); + smtpProtocol1.helo("abgsfe3rsf.de"); // helo should not be checked. so this should give a 250 code - assertEquals("Helo accepted", 250, response.getCode()); + assertEquals("Helo accepted", 250, smtpProtocol1.getReplyCode()); smtpProtocol1.quit(); } - public void testSenderDomainResolv() throws Exception, SMTPException { + public void testSenderDomainResolv() throws Exception { m_testConfiguration.setSenderDomainResolv(); m_testConfiguration.setAuthorizedAddresses("192.168.0.1/32"); finishSetUp(m_testConfiguration); - SMTPProtocol smtpProtocol1 = new SMTPProtocol("127.0.0.1", m_smtpListenerPort); - smtpProtocol1.openPort(); + SMTPClient smtpProtocol1 = new SMTPClient(); + smtpProtocol1.connect("127.0.0.1", m_smtpListenerPort); - assertEquals("first connection taken", 1, smtpProtocol1.getState()); + assertTrue("first connection taken", smtpProtocol1.isConnected()); // no message there, yet assertNull("no mail received by mail server", m_mailServer.getLastMail()); - smtpProtocol1.helo(InetAddress.getLocalHost()); + smtpProtocol1.helo(InetAddress.getLocalHost().toString()); String sender1 = "[EMAIL PROTECTED]"; String sender2 = "[EMAIL PROTECTED]"; - try { - smtpProtocol1.mail(new Address(sender1)); - fail("sender should not accept"); - } catch (SMTPException e) { - assertEquals("expected 501 error", 501, e.getCode()); - } + smtpProtocol1.setSender(sender1); + assertEquals("expected 501 error", 501, smtpProtocol1.getReplyCode()); - smtpProtocol1.mail(new Address(sender2)); + smtpProtocol1.setSender(sender2); smtpProtocol1.quit(); } - public void testSenderDomainResolvDefault() throws Exception, SMTPException { + public void testSenderDomainResolvDefault() throws Exception { finishSetUp(m_testConfiguration); - SMTPProtocol smtpProtocol1 = new SMTPProtocol("127.0.0.1", m_smtpListenerPort); - smtpProtocol1.openPort(); + SMTPClient smtpProtocol1 = new SMTPClient(); + smtpProtocol1.connect("127.0.0.1", m_smtpListenerPort); - smtpProtocol1.helo(InetAddress.getLocalHost()); + smtpProtocol1.helo(InetAddress.getLocalHost().toString()); String sender1 = "[EMAIL PROTECTED]"; - smtpProtocol1.mail(new Address(sender1)); + smtpProtocol1.setSender(sender1); smtpProtocol1.quit(); } - public void testSenderDomainResolvRelayClientDefault() throws Exception, SMTPException { + public void testSenderDomainResolvRelayClientDefault() throws Exception { m_testConfiguration.setSenderDomainResolv(); finishSetUp(m_testConfiguration); - SMTPProtocol smtpProtocol1 = new SMTPProtocol("127.0.0.1", m_smtpListenerPort); - smtpProtocol1.openPort(); + SMTPClient smtpProtocol1 = new SMTPClient(); + smtpProtocol1.connect("127.0.0.1", m_smtpListenerPort); - assertEquals("first connection taken", 1, smtpProtocol1.getState()); + assertTrue("first connection taken", smtpProtocol1.isConnected()); // no message there, yet assertNull("no mail received by mail server", m_mailServer.getLastMail()); - smtpProtocol1.helo(InetAddress.getLocalHost()); + smtpProtocol1.helo(InetAddress.getLocalHost().toString()); String sender1 = "[EMAIL PROTECTED]"; // Both mail shold - smtpProtocol1.mail(new Address(sender1)); + smtpProtocol1.setSender(sender1); smtpProtocol1.quit(); } - public void testSenderDomainResolvRelayClient() throws Exception, SMTPException { + public void testSenderDomainResolvRelayClient() throws Exception { m_testConfiguration.setSenderDomainResolv(); m_testConfiguration.setCheckAuthClients(true); finishSetUp(m_testConfiguration); - SMTPProtocol smtpProtocol1 = new SMTPProtocol("127.0.0.1", m_smtpListenerPort); - smtpProtocol1.openPort(); + SMTPClient smtpProtocol1 = new SMTPClient(); + smtpProtocol1.connect("127.0.0.1", m_smtpListenerPort); - assertEquals("first connection taken", 1, smtpProtocol1.getState()); + assertTrue("first connection taken", smtpProtocol1.isConnected()); // no message there, yet assertNull("no mail received by mail server", m_mailServer.getLastMail()); - smtpProtocol1.helo(InetAddress.getLocalHost()); + smtpProtocol1.helo(InetAddress.getLocalHost().toString()); String sender1 = "[EMAIL PROTECTED]"; String sender2 = "[EMAIL PROTECTED]"; - try { - smtpProtocol1.mail(new Address(sender1)); - fail("sender should not accept"); - } catch (SMTPException e) { - assertEquals("expected 501 error", 501, e.getCode()); - } + smtpProtocol1.setSender(sender1); + assertEquals("expected 501 error", 501, smtpProtocol1.getReplyCode()); - smtpProtocol1.mail(new Address(sender2)); + smtpProtocol1.setSender(sender2); smtpProtocol1.quit(); } - public void testMaxRcpt() throws Exception, SMTPException { + public void testMaxRcpt() throws Exception { m_testConfiguration.setMaxRcpt(1); finishSetUp(m_testConfiguration); - SMTPProtocol smtpProtocol1 = new SMTPProtocol("127.0.0.1", m_smtpListenerPort); - smtpProtocol1.openPort(); + SMTPClient smtpProtocol1 = new SMTPClient(); + smtpProtocol1.connect("127.0.0.1", m_smtpListenerPort); - assertEquals("first connection taken", 1, smtpProtocol1.getState()); + assertTrue("first connection taken", smtpProtocol1.isConnected()); // no message there, yet assertNull("no mail received by mail server", m_mailServer.getLastMail()); - smtpProtocol1.helo(InetAddress.getLocalHost()); + smtpProtocol1.helo(InetAddress.getLocalHost().toString()); String sender1 = "[EMAIL PROTECTED]"; String rcpt1 = "[EMAIL PROTECTED]"; String rcpt2 = "[EMAIL PROTECTED]"; - smtpProtocol1.mail(new Address(sender1)); - smtpProtocol1.rcpt(new Address(rcpt1)); + smtpProtocol1.setSender(sender1); + smtpProtocol1.addRecipient(rcpt1); - try { - smtpProtocol1.rcpt(new Address(rcpt2)); - fail("rcpt should not accepted"); - } catch (SMTPException e) { - assertEquals("expected 452 error", 452, e.getCode()); - } + smtpProtocol1.addRecipient(rcpt2); + assertEquals("expected 452 error", 452, smtpProtocol1.getReplyCode()); - smtpProtocol1.data(MimeTreeRenderer.getInstance().renderMimePart(createMail())); + smtpProtocol1.sendShortMessageData("Subject: test\r\n\r\nTest body\r\n"); // After the data is send the rcpt count is set back to 0.. So a new mail with rcpt should be accepted - smtpProtocol1.mail(new Address(sender1)); + smtpProtocol1.setSender(sender1); - smtpProtocol1.rcpt(new Address(rcpt1)); + smtpProtocol1.addRecipient(rcpt1); - smtpProtocol1.data(MimeTreeRenderer.getInstance().renderMimePart(createMail())); + smtpProtocol1.sendShortMessageData("Subject: test\r\n\r\nTest body\r\n"); smtpProtocol1.quit(); } - public void testMaxRcptDefault() throws Exception, SMTPException { + public void testMaxRcptDefault() throws Exception { finishSetUp(m_testConfiguration); - SMTPProtocol smtpProtocol1 = new SMTPProtocol("127.0.0.1", m_smtpListenerPort); - smtpProtocol1.openPort(); + SMTPClient smtpProtocol1 = new SMTPClient(); + smtpProtocol1.connect("127.0.0.1", m_smtpListenerPort); - smtpProtocol1.helo(InetAddress.getLocalHost()); + smtpProtocol1.helo(InetAddress.getLocalHost().toString()); String sender1 = "[EMAIL PROTECTED]"; String rcpt1 = "[EMAIL PROTECTED]"; - smtpProtocol1.mail(new Address(sender1)); + smtpProtocol1.setSender(sender1); - smtpProtocol1.rcpt(new Address(rcpt1)); + smtpProtocol1.addRecipient(rcpt1); - smtpProtocol1.data(MimeTreeRenderer.getInstance().renderMimePart(createMail())); + smtpProtocol1.sendShortMessageData("Subject: test\r\n\r\nTest body\r\n"); smtpProtocol1.quit(); } - public void testEhloResolv() throws Exception, SMTPException { + public void testEhloResolv() throws Exception { m_testConfiguration.setEhloResolv(); m_testConfiguration.setAuthorizedAddresses("192.168.0.1"); finishSetUp(m_testConfiguration); - MySMTPProtocol smtpProtocol1 = new MySMTPProtocol("127.0.0.1", m_smtpListenerPort); - smtpProtocol1.openPort(); + SMTPClient smtpProtocol1 = new SMTPClient(); + smtpProtocol1.connect("127.0.0.1", m_smtpListenerPort); - assertEquals("first connection taken", 1, smtpProtocol1.getState()); + assertTrue("first connection taken", smtpProtocol1.isConnected()); // no message there, yet assertNull("no mail received by mail server", m_mailServer.getLastMail()); - String[] ehlo1 = new String[] { "abgsfe3rsf.de"}; - String[] ehlo2 = new String[] { "james.apache.org" }; + String ehlo1 = "abgsfe3rsf.de"; + String ehlo2 = "james.apache.org"; smtpProtocol1.sendCommand("ehlo", ehlo1); - SMTPResponse response = smtpProtocol1.getResponse(); // this should give a 501 code cause the ehlo could not resolved - assertEquals("expected error: ehlo could not resolved", 501, response.getCode()); + assertEquals("expected error: ehlo could not resolved", 501, smtpProtocol1.getReplyCode()); smtpProtocol1.sendCommand("ehlo", ehlo2); - SMTPResponse response2 = smtpProtocol1.getResponse(); // ehlo is resolvable. so this should give a 250 code - assertEquals("ehlo accepted", 250, response2.getCode()); + assertEquals("ehlo accepted", 250, smtpProtocol1.getReplyCode()); smtpProtocol1.quit(); } - public void testEhloResolvDefault() throws Exception, SMTPException { + public void testEhloResolvDefault() throws Exception { finishSetUp(m_testConfiguration); - MySMTPProtocol smtpProtocol1 = new MySMTPProtocol("127.0.0.1", m_smtpListenerPort); - smtpProtocol1.openPort(); + SMTPClient smtpProtocol1 = new SMTPClient(); + smtpProtocol1.connect("127.0.0.1", m_smtpListenerPort); - smtpProtocol1.sendCommand("ehlo",new String[]{"abgsfe3rsf.de"}); - SMTPResponse response = smtpProtocol1.getResponse(); + smtpProtocol1.sendCommand("ehlo","abgsfe3rsf.de"); // ehlo should not be checked. so this should give a 250 code - assertEquals("ehlo accepted", 250, response.getCode()); + assertEquals("ehlo accepted", 250, smtpProtocol1.getReplyCode()); smtpProtocol1.quit(); } - public void testEhloResolvIgnoreClientDisabled() throws Exception, SMTPException { + public void testEhloResolvIgnoreClientDisabled() throws Exception { m_testConfiguration.setEhloResolv(); m_testConfiguration.setCheckAuthNetworks(true); finishSetUp(m_testConfiguration); - MySMTPProtocol smtpProtocol1 = new MySMTPProtocol("127.0.0.1", m_smtpListenerPort); - smtpProtocol1.openPort(); + SMTPClient smtpProtocol1 = new SMTPClient(); + smtpProtocol1.connect("127.0.0.1", m_smtpListenerPort); - assertEquals("first connection taken", 1, smtpProtocol1.getState()); + assertTrue("first connection taken", smtpProtocol1.isConnected()); // no message there, yet assertNull("no mail received by mail server", m_mailServer.getLastMail()); - String[] ehlo1 = new String[] { "abgsfe3rsf.de"}; - String[] ehlo2 = new String[] { "james.apache.org" }; + String ehlo1 = "abgsfe3rsf.de"; + String ehlo2 = "james.apache.org"; smtpProtocol1.sendCommand("ehlo", ehlo1); - SMTPResponse response = smtpProtocol1.getResponse(); // this should give a 501 code cause the ehlo could not resolved - assertEquals("expected error: ehlo could not resolved", 501, response.getCode()); + assertEquals("expected error: ehlo could not resolved", 501, smtpProtocol1.getReplyCode()); smtpProtocol1.sendCommand("ehlo", ehlo2); - SMTPResponse response2 = smtpProtocol1.getResponse(); // ehlo is resolvable. so this should give a 250 code - assertEquals("ehlo accepted", 250, response2.getCode()); + assertEquals("ehlo accepted", 250, smtpProtocol1.getReplyCode()); smtpProtocol1.quit(); } - public void testHeloEnforcement() throws Exception, SMTPException { + public void testHeloEnforcement() throws Exception { finishSetUp(m_testConfiguration); - SMTPProtocol smtpProtocol1 = new SMTPProtocol("127.0.0.1", m_smtpListenerPort); - smtpProtocol1.openPort(); + SMTPClient smtpProtocol1 = new SMTPClient(); + smtpProtocol1.connect("127.0.0.1", m_smtpListenerPort); - assertEquals("first connection taken", 1, smtpProtocol1.getState()); + assertTrue("first connection taken", smtpProtocol1.isConnected()); // no message there, yet assertNull("no mail received by mail server", m_mailServer.getLastMail()); String sender1 = "[EMAIL PROTECTED]"; - try { - smtpProtocol1.mail(new Address(sender1)); - fail("helo not enforced"); - } catch (SMTPException e) { - assertEquals("expected 503 error", 503, e.getCode()); - } + smtpProtocol1.setSender(sender1); + assertEquals("expected 503 error", 503, smtpProtocol1.getReplyCode()); - smtpProtocol1.helo(InetAddress.getLocalHost()); + smtpProtocol1.helo(InetAddress.getLocalHost().toString()); - smtpProtocol1.mail(new Address(sender1)); + smtpProtocol1.setSender(sender1); smtpProtocol1.quit(); } - public void testHeloEnforcementDisabled() throws Exception, SMTPException { + public void testHeloEnforcementDisabled() throws Exception { m_testConfiguration.setHeloEhloEnforcement(false); finishSetUp(m_testConfiguration); - SMTPProtocol smtpProtocol1 = new SMTPProtocol("127.0.0.1", m_smtpListenerPort); - smtpProtocol1.openPort(); + SMTPClient smtpProtocol1 = new SMTPClient(); + smtpProtocol1.connect("127.0.0.1", m_smtpListenerPort); - assertEquals("first connection taken", 1, smtpProtocol1.getState()); + assertTrue("first connection taken", smtpProtocol1.isConnected()); // no message there, yet assertNull("no mail received by mail server", m_mailServer.getLastMail()); String sender1 = "[EMAIL PROTECTED]"; - smtpProtocol1.mail(new Address(sender1)); + smtpProtocol1.setSender(sender1); smtpProtocol1.quit(); } - public void testAuth() throws Exception, SMTPException { + public void testAuth() throws Exception { m_testConfiguration.setAuthorizedAddresses("128.0.0.1/8"); m_testConfiguration.setAuthorizingAnnounce(); finishSetUp(m_testConfiguration); - MySMTPProtocol smtpProtocol = new MySMTPProtocol("127.0.0.1", m_smtpListenerPort); - smtpProtocol.openPort(); + SMTPClient smtpProtocol = new SMTPClient(); + smtpProtocol.connect("127.0.0.1", m_smtpListenerPort); - String[] capabilityStrings = smtpProtocol.ehlo(InetAddress.getLocalHost()); - List capabilitieslist = Arrays.asList(capabilityStrings); + smtpProtocol.sendCommand("ehlo", InetAddress.getLocalHost().toString()); + String[] capabilityRes = smtpProtocol.getReplyStrings(); + + List capabilitieslist = new ArrayList(); + for (int i = 1; i < capabilityRes.length; i++) { + capabilitieslist.add(capabilityRes[i].substring(4)); + } + assertTrue("anouncing auth required", capabilitieslist.contains("AUTH LOGIN PLAIN")); // is this required or just for compatibility? assertTrue("anouncing auth required", capabilitieslist.contains("AUTH=LOGIN PLAIN")); @@ -686,47 +661,35 @@ String noexistUserName = "noexist_test_user_smtp"; String sender ="[EMAIL PROTECTED]"; smtpProtocol.sendCommand("AUTH FOO", null); - SMTPResponse response = smtpProtocol.getResponse(); - assertEquals("expected error: unrecognized authentication type", 504, response.getCode()); + assertEquals("expected error: unrecognized authentication type", 504, smtpProtocol.getReplyCode()); - smtpProtocol.mail(new Address(sender)); + smtpProtocol.setSender(sender); - try { - smtpProtocol.rcpt(new Address("[EMAIL PROTECTED]")); - fail("no auth required"); - } catch (SMTPException e) { - assertEquals("expected 530 error", 530, e.getCode()); - } + smtpProtocol.addRecipient("[EMAIL PROTECTED]"); + assertEquals("expected 530 error", 530, smtpProtocol.getReplyCode()); assertFalse("user not existing", m_usersRepository.contains(noexistUserName)); - try { - smtpProtocol.auth("PLAIN", noexistUserName, "pwd".toCharArray()); - fail("auth succeeded for non-existing user"); - } catch (SMTPException e) { - assertEquals("expected error", 535, e.getCode()); - } + + smtpProtocol.sendCommand("AUTH PLAIN"); + smtpProtocol.sendCommand(Base64.encodeAsString("\0"+noexistUserName+"\0pwd\0")); +// smtpProtocol.sendCommand(noexistUserName+"pwd".toCharArray()); + assertEquals("expected error", 535, smtpProtocol.getReplyCode()); m_usersRepository.addUser(userName, "pwd"); - try { - smtpProtocol.auth("PLAIN", userName, "wrongpwd".toCharArray()); - fail("auth succeeded with wrong password"); - } catch (SMTPException e) { - assertEquals("expected error", 535, e.getCode()); - } - try { - smtpProtocol.auth("PLAIN", userName, "pwd".toCharArray()); - } catch (SMTPException e) { - e.printStackTrace(); - fail("authentication failed"); - } + smtpProtocol.sendCommand("AUTH PLAIN"); + smtpProtocol.sendCommand(Base64.encodeAsString("\0"+userName+"\0wrongpwd\0")); + assertEquals("expected error", 535, smtpProtocol.getReplyCode()); + + smtpProtocol.sendCommand("AUTH PLAIN"); + smtpProtocol.sendCommand(Base64.encodeAsString("\0"+userName+"\0pwd\0")); + assertEquals("authenticated", 235, smtpProtocol.getReplyCode()); - smtpProtocol.sendCommand("AUTH PLAIN ", new String[]{Base64.encodeAsString("\0" + userName + "\0pwd")}); - response = smtpProtocol.getResponse(); - assertEquals("expected error: User has previously authenticated.", 503, response.getCode()); + smtpProtocol.sendCommand("AUTH PLAIN"); + assertEquals("expected error: User has previously authenticated.", 503, smtpProtocol.getReplyCode()); - smtpProtocol.rcpt(new Address("[EMAIL PROTECTED]")); - smtpProtocol.data(MimeTreeRenderer.getInstance().renderMimePart(createMail())); + smtpProtocol.addRecipient("[EMAIL PROTECTED]"); + smtpProtocol.sendShortMessageData("Subject: test\r\n\r\nTest body\r\n"); smtpProtocol.quit(); @@ -739,51 +702,40 @@ m_testConfiguration.setAuthorizingAnnounce(); finishSetUp(m_testConfiguration); - MySMTPProtocol smtpProtocol = new MySMTPProtocol("127.0.0.1", m_smtpListenerPort); - smtpProtocol.openPort(); + SMTPClient smtpProtocol = new SMTPClient(); + smtpProtocol.connect("127.0.0.1", m_smtpListenerPort); - smtpProtocol.ehlo(InetAddress.getLocalHost()); + smtpProtocol.sendCommand("ehlo "+InetAddress.getLocalHost()); String userName = "test_user_smtp"; m_usersRepository.addUser(userName, "pwd"); - smtpProtocol.mail(new Address("")); + smtpProtocol.setSender(""); - try { - smtpProtocol.auth("PLAIN", userName, "pwd".toCharArray()); - } catch (SMTPException e) { - e.printStackTrace(); - fail("authentication failed"); - } + smtpProtocol.sendCommand("AUTH PLAIN"); + smtpProtocol.sendCommand(Base64.encodeAsString("\0"+userName+"\0pwd\0")); + assertEquals("authenticated", 235, smtpProtocol.getReplyCode()); - try { - smtpProtocol.rcpt(new Address("[EMAIL PROTECTED]")); - fail("smtpserver allowed an empty sender for an authenticated user"); - } catch (SMTPException e) { - assertEquals("expected error", 503, e.getCode()); - } + smtpProtocol.addRecipient("[EMAIL PROTECTED]"); + assertEquals("expected error", 503, smtpProtocol.getReplyCode()); smtpProtocol.quit(); } - public void testNoRecepientSpecified() throws Exception, SMTPException { + public void testNoRecepientSpecified() throws Exception { finishSetUp(m_testConfiguration); - MySMTPProtocol smtpProtocol = new MySMTPProtocol("127.0.0.1", m_smtpListenerPort); - smtpProtocol.openPort(); + SMTPClient smtpProtocol = new SMTPClient(); + smtpProtocol.connect("127.0.0.1", m_smtpListenerPort); - smtpProtocol.ehlo(InetAddress.getLocalHost()); + smtpProtocol.sendCommand("ehlo "+InetAddress.getLocalHost()); - smtpProtocol.mail(new Address("[EMAIL PROTECTED]")); + smtpProtocol.setSender("[EMAIL PROTECTED]"); // left out for test smtpProtocol.rcpt(new Address("[EMAIL PROTECTED]")); - try { - smtpProtocol.data(MimeTreeRenderer.getInstance().renderMimePart(createMail())); - fail("sending succeeded without recepient"); - } catch (Exception e) { - // test succeeded - } + smtpProtocol.sendShortMessageData("Subject: test\r\n\r\nTest body\r\n"); + assertTrue("sending succeeded without recepient", SMTPReply.isNegativePermanent(smtpProtocol.getReplyCode())); smtpProtocol.quit(); @@ -791,19 +743,19 @@ assertNull("no mail received by mail server", m_mailServer.getLastMail()); } - public void testMultipleMailsAndRset() throws Exception, SMTPException { + public void testMultipleMailsAndRset() throws Exception { finishSetUp(m_testConfiguration); - MySMTPProtocol smtpProtocol = new MySMTPProtocol("127.0.0.1", m_smtpListenerPort); - smtpProtocol.openPort(); + SMTPClient smtpProtocol = new SMTPClient(); + smtpProtocol.connect("127.0.0.1", m_smtpListenerPort); - smtpProtocol.ehlo(InetAddress.getLocalHost()); + smtpProtocol.sendCommand("ehlo "+InetAddress.getLocalHost()); - smtpProtocol.mail(new Address("[EMAIL PROTECTED]")); + smtpProtocol.setSender("[EMAIL PROTECTED]"); smtpProtocol.reset(); - smtpProtocol.mail(new Address("[EMAIL PROTECTED]")); + smtpProtocol.setSender("[EMAIL PROTECTED]"); smtpProtocol.quit(); @@ -811,98 +763,128 @@ assertNull("no mail received by mail server", m_mailServer.getLastMail()); } - public void testRelayingDenied() throws Exception, SMTPException { + public void testRelayingDenied() throws Exception { m_testConfiguration.setAuthorizedAddresses("128.0.0.1/8"); finishSetUp(m_testConfiguration); - SMTPProtocol smtpProtocol = new SMTPProtocol("127.0.0.1", m_smtpListenerPort); - smtpProtocol.openPort(); + SMTPClient smtpProtocol = new SMTPClient(); + smtpProtocol.connect("127.0.0.1", m_smtpListenerPort); - smtpProtocol.ehlo(InetAddress.getLocalHost()); + smtpProtocol.sendCommand("ehlo "+InetAddress.getLocalHost()); - smtpProtocol.mail(new Address("[EMAIL PROTECTED]")); - try { - smtpProtocol.rcpt(new Address("[EMAIL PROTECTED]")); - fail("relaying allowed"); - } catch (SMTPException e) { - assertEquals("expected 550 error", 550, e.getCode()); - } + smtpProtocol.setSender("[EMAIL PROTECTED]"); + + smtpProtocol.addRecipient("[EMAIL PROTECTED]"); + assertEquals("expected 550 error", 550, smtpProtocol.getReplyCode()); } - public void testHandleAnnouncedMessageSizeLimitExceeded() throws Exception, SMTPException { + public void testHandleAnnouncedMessageSizeLimitExceeded() throws Exception { m_testConfiguration.setMaxMessageSize(1); // set message limit to 1kb finishSetUp(m_testConfiguration); - MySMTPProtocol smtpProtocol = new MySMTPProtocol("127.0.0.1", m_smtpListenerPort); - smtpProtocol.openPort(); + SMTPClient smtpProtocol = new SMTPClient(); + smtpProtocol.connect("127.0.0.1", m_smtpListenerPort); - smtpProtocol.ehlo(InetAddress.getLocalHost()); + smtpProtocol.sendCommand("ehlo "+InetAddress.getLocalHost()); smtpProtocol.sendCommand("MAIL FROM:<[EMAIL PROTECTED]> SIZE=1025", null); - SMTPResponse response = smtpProtocol.getResponse(); - assertEquals("expected error: max msg size exceeded", 552, response.getCode()); + assertEquals("expected error: max msg size exceeded", 552, smtpProtocol.getReplyCode()); - try { - smtpProtocol.rcpt(new Address("[EMAIL PROTECTED]")); - } catch (SMTPException e) { - assertEquals("expected error", 552, response.getCode()); - } + smtpProtocol.addRecipient("[EMAIL PROTECTED]"); + assertEquals("expected error", 503, smtpProtocol.getReplyCode()); } - public void testHandleMessageSizeLimitExceeded() throws Exception, SMTPException { + public void testHandleMessageSizeLimitExceeded() throws Exception { m_testConfiguration.setMaxMessageSize(1); // set message limit to 1kb finishSetUp(m_testConfiguration); - MySMTPProtocol smtpProtocol = new MySMTPProtocol("127.0.0.1", m_smtpListenerPort); - smtpProtocol.openPort(); + SMTPClient smtpProtocol = new SMTPClient(); + smtpProtocol.connect("127.0.0.1", m_smtpListenerPort); - smtpProtocol.ehlo(InetAddress.getLocalHost()); + smtpProtocol.sendCommand("ehlo "+InetAddress.getLocalHost()); - smtpProtocol.mail(new Address("[EMAIL PROTECTED]")); - smtpProtocol.rcpt(new Address("[EMAIL PROTECTED]")); + smtpProtocol.setSender("[EMAIL PROTECTED]"); + smtpProtocol.addRecipient("[EMAIL PROTECTED]"); - MimeHeader mimeHeader = new MimeHeader(new Header()); - mimeHeader.set("Mime-Version", "1.0"); - LocalMimePart mail = new LocalMimePart(mimeHeader); - MimeHeader header = mail.getHeader(); - header.setMimeType(new MimeType("text", "plain")); - - // create Body with more than 1kb - StringBuffer body = new StringBuffer(); - body.append("1234567810123456782012345678301234567840123456785012345678601234567870123456788012345678901234567100"); - body.append("1234567810123456782012345678301234567840123456785012345678601234567870123456788012345678901234567100"); - body.append("1234567810123456782012345678301234567840123456785012345678601234567870123456788012345678901234567100"); - body.append("1234567810123456782012345678301234567840123456785012345678601234567870123456788012345678901234567100"); - body.append("1234567810123456782012345678301234567840123456785012345678601234567870123456788012345678901234567100"); - body.append("1234567810123456782012345678301234567840123456785012345678601234567870123456788012345678901234567100"); - body.append("1234567810123456782012345678301234567840123456785012345678601234567870123456788012345678901234567100"); - body.append("1234567810123456782012345678301234567840123456785012345678601234567870123456788012345678901234567100"); - body.append("1234567810123456782012345678301234567840123456785012345678601234567870123456788012345678901234567100"); - body.append("1234567810123456782012345678301234567840123456785012345678601234567870123456788012345678901234567100"); - body.append("1234567810123456782012345"); // 1025 chars + Writer wr = smtpProtocol.sendMessageData(); + // create Body with more than 1kb . 502 + wr.write("1234567810123456782012345678301234567840123456785012345678601234567870123456788012345678901234567100"); + wr.write("1234567810123456782012345678301234567840123456785012345678601234567870123456788012345678901234567100"); + wr.write("1234567810123456782012345678301234567840123456785012345678601234567870123456788012345678901234567100"); + wr.write("1234567810123456782012345678301234567840123456785012345678601234567870123456788012345678901234567100"); + wr.write("1234567810123456782012345678301234567840123456785012345678601234567870123456788012345678901234567100\r\n"); + // second line + wr.write("1234567810123456782012345678301234567840123456785012345678601234567870123456788012345678901234567100"); + wr.write("1234567810123456782012345678301234567840123456785012345678601234567870123456788012345678901234567100"); + wr.write("1234567810123456782012345678301234567840123456785012345678601234567870123456788012345678901234567100"); + wr.write("1234567810123456782012345678301234567840123456785012345678601234567870123456788012345678901234567100"); + wr.write("1234567810123456782012345678301234567840123456785012345678601234567870123456788012345678901234567100"); + wr.write("123456781012345678201\r\n"); // 521 + CRLF = 523 + 502 => 1025 + wr.close(); + + assertFalse(smtpProtocol.completePendingCommand()); - mail.setBody(new CharSequenceSource(body.toString())); + assertEquals("expected 552 error", 552, smtpProtocol.getReplyCode()); - try { - smtpProtocol.data(MimeTreeRenderer.getInstance().renderMimePart(mail)); - fail("message size exceeded not recognized"); - } catch (SMTPException e) { - assertEquals("expected 552 error", 552, e.getCode()); - } + } + + public void testHandleMessageSizeLimitRespected() throws Exception { + m_testConfiguration.setMaxMessageSize(1); // set message limit to 1kb + finishSetUp(m_testConfiguration); + + SMTPClient smtpProtocol = new SMTPClient(); + smtpProtocol.connect("127.0.0.1", m_smtpListenerPort); + + smtpProtocol.sendCommand("ehlo "+InetAddress.getLocalHost()); + + smtpProtocol.setSender("[EMAIL PROTECTED]"); + smtpProtocol.addRecipient("[EMAIL PROTECTED]"); + + Writer wr = smtpProtocol.sendMessageData(); + // create Body with less than 1kb + wr.write("1234567810123456782012345678301234567840123456785012345678601234567870123456788012345678901234567100"); + wr.write("1234567810123456782012345678301234567840123456785012345678601234567870123456788012345678901234567100"); + wr.write("1234567810123456782012345678301234567840123456785012345678601234567870123456788012345678901234567100"); + wr.write("1234567810123456782012345678301234567840123456785012345678601234567870123456788012345678901234567100"); + wr.write("1234567810123456782012345678301234567840123456785012345678601234567870123456788012345678901234567100"); + wr.write("1234567810123456782012345678301234567840123456785012345678601234567870123456788012345678901234567100"); + wr.write("1234567810123456782012345678301234567840123456785012345678601234567870123456788012345678901234567100"); + wr.write("1234567810123456782012345678301234567840123456785012345678601234567870123456788012345678901234567100"); + wr.write("1234567810123456782012345678301234567840123456785012345678601234567870123456788012345678901234567100"); + wr.write("1234567810123456782012345678301234567840123456785012345678601234567870123456788012345678901234567100"); + wr.write("1234567810123456782012\r\n"); // 1022 + CRLF = 1024 + wr.close(); + + assertTrue(smtpProtocol.completePendingCommand()); + + assertEquals("expected 250 ok", 250, smtpProtocol.getReplyCode()); } - public void testConnectionLimitExceeded() throws Exception, SMTPException { + public void testConnectionLimitExceeded() throws Exception { m_testConfiguration.setConnectionLimit(1); // allow no more than one connection at a time finishSetUp(m_testConfiguration); - SMTPProtocol smtpProtocol1 = new SMTPProtocol("127.0.0.1", m_smtpListenerPort); - SMTPProtocol smtpProtocol2 = new SMTPProtocol("127.0.0.1", m_smtpListenerPort); - smtpProtocol1.openPort(); - assertEquals("first connection taken", 1, smtpProtocol1.getState()); + SMTPClient smtpProtocol1 = new SMTPClient(); + SMTPClient smtpProtocol2 = new SMTPClient(); + smtpProtocol1.connect("127.0.0.1", m_smtpListenerPort); + assertTrue("first connection taken", smtpProtocol1.isConnected()); - smtpProtocol2.openPort(); - assertEquals("second connection not taken", SMTPProtocol.NOT_CONNECTED, smtpProtocol2.getState()); + try { + smtpProtocol2.connect("127.0.0.1", m_smtpListenerPort); + fail("second connection not taken1"); + } catch (Exception e) { + } + + // disconnect the first + smtpProtocol1.quit(); + smtpProtocol1.disconnect(); + + Thread.sleep(100); + + // now the second should be able to connect + smtpProtocol2.connect("127.0.0.1", m_smtpListenerPort); + assertTrue(smtpProtocol2.isConnected()); } // RemoteDelivery tests. @@ -1005,24 +987,4 @@ } -} - -class MySMTPProtocol extends SMTPProtocol -{ - - public MySMTPProtocol(String s, int i) { - super(s, i); - } - - public MySMTPProtocol(String s) { - super(s); - } - - public void sendCommand(String string, String[] strings) throws IOException { - super.sendCommand(string, strings); - } - - public SMTPResponse getResponse() throws IOException, SMTPException { - return super.readSingleLineResponse(); - } } Modified: james/server/trunk/src/test/org/apache/james/test/mock/james/MockMailServer.java URL: http://svn.apache.org/viewcvs/james/server/trunk/src/test/org/apache/james/test/mock/james/MockMailServer.java?rev=406781&r1=406780&r2=406781&view=diff ============================================================================== --- james/server/trunk/src/test/org/apache/james/test/mock/james/MockMailServer.java (original) +++ james/server/trunk/src/test/org/apache/james/test/mock/james/MockMailServer.java Mon May 15 16:59:53 2006 @@ -59,7 +59,7 @@ public void sendMail(Mail mail) throws MessagingException { int bodySize = mail.getMessage().getSize(); try { - if (m_maxMessageSizeBytes != 0 && m_maxMessageSizeBytes < bodySize) throw new MessageSizeException(); + if (m_maxMessageSizeBytes != 0 && m_maxMessageSizeBytes*1024 < bodySize) throw new MessageSizeException(); } catch (MessageSizeException e) { throw new MessagingException("message size exception is nested", e); } --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]