<commit_before>package org.subethamail.smtp;

import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.net.InetAddress;
import java.net.Socket;

import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.subethamail.wiser.Wiser;

/**
 * This class tests connection timeouts.
 *
 * @author <NAME>
 */
public class TimeoutTest extends TestCase
{
	/** */
	@SuppressWarnings("unused")
	private static Logger log = LoggerFactory.getLogger(TimeoutTest.class);

	/** */
	public static final int PORT = 2566;

	/** */
	public TimeoutTest(String name)
	{
		super(name);
	}

	/** */
	@Override
	protected void setUp() throws Exception
	{
		super.setUp();
	}

	/** */
	@Override
	protected void tearDown() throws Exception
	{
		super.tearDown();
	}

	/** */
	public void testTimeout() throws Exception
	{
		Wiser wiser = new Wiser();
		wiser.setPort(PORT);
		wiser.getServer().setConnectionTimeout(1000);

		wiser.start();

		Socket sock = new Socket(InetAddress.getLocalHost(), PORT);
		OutputStream out = sock.getOutputStream();
		PrintWriter writer = new PrintWriter(new OutputStreamWriter(out));

		writer.print("HELO foo\r\n");
		assert(!writer.checkError());

		Thread.sleep(2000);

		writer.print("HELO bar\r\n");
		assert(writer.checkError());

		wiser.stop();
	}

	/** */
	public static Test suite()
	{
		return new TestSuite(TimeoutTest.class);
	}
}<commit_msg>Updated old test, which had no effect, likely since assert became a keyword. Moreover, currently (at least on Windows7/Java7) the disconnect is only noticed on read, and the test only used write.<commit_after>package org.subethamail.smtp;

import static org.junit.Assert.fail;

import java.net.SocketException;

import org.junit.Test;
import org.subethamail.smtp.client.SMTPClient;
import org.subethamail.wiser.Wiser;

/**
 * This class tests connection timeouts.
 * 
 * @author <NAME>
 */
public class TimeoutTest {
	/** */
	public static final int PORT = 2566;

	/** */
	@Test
	public void testTimeout() throws Exception {
		Wiser wiser = new Wiser();
		wiser.setPort(PORT);
		wiser.getServer().setConnectionTimeout(1000);
		wiser.start();

		SMTPClient client = new SMTPClient("localhost", PORT);
		client.sendReceive("HELO foo");
		Thread.sleep(2000);
		try {
			client.sendReceive("HELO bar");
			fail();
		} catch (SocketException e) {
			// expected
		} finally {
			wiser.stop();
		}
	}

}
{'fraction_non_alphanumeric': 0.1346613545816733, 'fraction_numerical': 0.011155378486055778, 'mean_word_length': 4.145491803278689, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1211349', 'n_tokens_mistral': 892, 'n_tokens_neox': 818, 'n_words': 197}