<commit_before>package de.teiesti.postie;

import org.junit.*;

import java.io.IOException;
import java.net.InetAddress;
import java.net.ServerSocket;
import java.net.Socket;

import static org.junit.Assert.*;
import static org.hamcrest.CoreMatchers.*;

public class PostmanTest {

    private Postman alice;
    private Postman bob;

    @Before
    public void setup() {
        Thread createAlice = new Thread() {
            public void run() {
                try {
                    Socket aliceSocket = new ServerSocket(2804).accept();
                    alice = new Postman(aliceSocket, Integer.class);
                } catch (IOException e) {
                    e.printStackTrace();
                    fail("could not create alice");
                }
            }
        };

        createAlice.start();

        try {
            Socket bobSocket = new Socket(InetAddress.getLocalHost(), 2804);
            bob = new Postman(bobSocket, Integer.class);
        } catch (IOException e) {
            e.printStackTrace();
            fail("could not create bob");
        }

        try {
            createAlice.join();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

    @Test(timeout=5000)
    public void simplexSendTest() {
        bob.send(42);
        assertThat((Integer) alice.receive(), is(42));
    }

    @Test(timeout=5000)
    public void halfDuplexSendTest() {
        bob.send(1234);
        assertThat((Integer) alice.receive(), is(1234));
        alice.send(4321);
        assertThat((Integer) bob.receive(), is(4321));
    }

    @Test(timeout=5000)
    public void fullDuplexSendTest() {
        bob.send(1);
        alice.send(2);
        assertThat((Integer) bob.receive(), is(2));
        assertThat((Integer) alice.receive(), is(2));
    }

    @After
    public void cleanup() throws Exception {
        alice.close();
        bob.close();
    }

}<commit_msg>PostmanTest improved.<commit_after>package de.teiesti.postie;

import org.junit.*;

import java.io.IOException;
import java.net.InetAddress;
import java.net.ServerSocket;
import java.net.Socket;

import static org.junit.Assert.*;
import static org.hamcrest.CoreMatchers.*;

public class PostmanTest {

    private static Postman alice;
    private static Postman bob;

    @BeforeClass
    public static void setup() {
        Thread createAlice = new Thread() {
           	@Override
            public void run() {
                try {
                    Socket aliceSocket = new ServerSocket(2804).accept();
                    alice = new Postman(aliceSocket, Integer.class);
                } catch (IOException e) {
                    e.printStackTrace();
                    fail("could not create alice");
                }
            }
        };

        createAlice.start();

        try {
            Socket bobSocket = new Socket(InetAddress.getLocalHost(), 2804);
            bob = new Postman(bobSocket, Integer.class);
        } catch (IOException e) {
            e.printStackTrace();
            fail("could not create bob");
        }

        try {
            createAlice.join();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

    @Test(timeout = 500)
    public void simplexSendTest() {
        bob.send(42);
        assertThat((Integer) alice.receive(), is(42));
    }

    @Test(timeout=500)
    public void halfDuplexSendTest() {
        bob.send(1234);
        assertThat((Integer) alice.receive(), is(1234));
        alice.send(4321);
        assertThat((Integer) bob.receive(), is(4321));
    }

    @Test(timeout = 500)
    public void fullDuplexSendTest() {
        bob.send(1);
        alice.send(2);
        assertThat((Integer) bob.receive(), is(2));
        assertThat((Integer) alice.receive(), is(1));
    }

	@Test(timeout = 500)
	public void multiSendTest() {
		for (int i = 0 ; i < 1024; i++)
			bob.send(i);

		for (int i = 0; i < 1024; i++)
			assertThat((Integer) alice.receive(), is(i));
	}

    @AfterClass
    public static void cleanup() throws Exception {
        alice.close();
        bob.close();
    }

}
{'fraction_non_alphanumeric': 0.1245483016140689, 'fraction_numerical': 0.023608768971332208, 'mean_word_length': 1.9614835948644793, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '364509', 'n_tokens_mistral': 1284, 'n_tokens_neox': 1170, 'n_words': 271}