All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.subethamail.smtp.test.ReceivedHeaderStreamTest Maven / Gradle / Ivy

There is a newer version: 3.1.7
Show newest version
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"));
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy