org.subethamail.smtp.test.ReceivedHeaderStreamTest Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of subethasmtp Show documentation
Show all versions of subethasmtp Show documentation
SubEtha SMTP is an easy-to-use server-side SMTP library for Java.
package org.subethamail.smtp.test;
import java.io.ByteArrayInputStream;
import java.net.InetAddress;
import junit.framework.TestCase;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.subethamail.smtp.io.ReceivedHeaderStream;
/**
* This class tests a bug in ReceivedHeaderStream which
* has since been fixed.
*
* @see http://www.subethamail.org/se/archive_msg.jsp?msgId=59719
*/
public class ReceivedHeaderStreamTest extends TestCase
{
@SuppressWarnings("unused")
private final static Logger log = LoggerFactory.getLogger(ReceivedHeaderStreamTest.class);
/** */
public ReceivedHeaderStreamTest(String name)
{
super(name);
}
/** */
@Override
protected void setUp() throws Exception
{
super.setUp();
}
/** */
public void testReceivedHeader() throws Exception
{
int BUF_SIZE = 10000;
int offset = 10;
ByteArrayInputStream in = new ByteArrayInputStream("hello world".getBytes());
ReceivedHeaderStream hdrIS = new ReceivedHeaderStream(in, "ehlo", InetAddress.getLocalHost(), "foo");
byte[] buf = new byte[BUF_SIZE];
int len = hdrIS.read(buf, offset, BUF_SIZE-offset);
String result = new String(buf, offset, len);
assertTrue(result.endsWith("\nhello world"));
}
}