<commit_before>package io.sniffy.socket;

import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;

import java.io.*;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.SocketAddress;
import java.net.SocketImpl;
import java.sql.SQLException;

import static org.junit.Assert.*;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.anyObject;
import static org.powermock.api.mockito.PowerMockito.*;

@RunWith(PowerMockRunner.class)
@PrepareForTest(SocketImpl.class)
public class SnifferSocketImplTest {

    @Mock
    private SocketImpl delegate;

    private SnifferSocketImpl sniffySocket;

    @Before
    public void createSniffySocket() {
        sniffySocket = new SnifferSocketImpl(delegate);
    }

    @Test
    public void testSendUrgentData() throws Exception {

        sniffySocket.sendUrgentData(1);

        verifyPrivate(delegate).invoke("sendUrgentData",1);
        verifyNoMoreInteractions(delegate);

    }

    @Test
    public void testSendUrgentDataThrowsIOException() throws Exception {

        IOException expected = new IOException();
        when(delegate, "sendUrgentData", anyInt()).thenThrow(expected);

        try {
            sniffySocket.sendUrgentData(1);
        } catch (IOException actual) {
            assertEquals(expected, actual);
        }

        verifyPrivate(delegate).invoke("sendUrgentData",1);
        verifyNoMoreInteractions(delegate);

    }

    @Test
    public void testSendUrgentDataThrowIOException() throws Exception {

        IOException expected = new IOException();
        when(delegate, "sendUrgentData", anyInt()).thenThrow(expected);

        try {
            sniffySocket.sendUrgentData(1);
            fail();
        } catch (IOException actual) {
            assertEquals(expected, actual);
        }

        verifyPrivate(delegate).invoke("sendUrgentData",1);
        verifyNoMoreInteractions(delegate);

    }

    @Test
    public void testSendUrgentDataThrowRuntimeException() throws Exception {

        RuntimeException expected = new RuntimeException();
        when(delegate, "sendUrgentData", anyInt()).thenThrow(expected);

        try {
            sniffySocket.sendUrgentData(1);
            fail();
        } catch (Exception actual) {
            assertEquals(expected, actual);
        }

        verifyPrivate(delegate).invoke("sendUrgentData",1);
        verifyNoMoreInteractions(delegate);

    }

    @Test
    public void testShutdownInput() throws Exception {

        sniffySocket.shutdownInput();

        verifyPrivate(delegate).invoke("shutdownInput");
        verifyNoMoreInteractions(delegate);

    }

    @Test
    public void testShutdownOutput() throws Exception {

        sniffySocket.shutdownOutput();
<commit_msg>More unit tests for Socketimpl.shutdownInput() method<commit_after>package io.sniffy.socket;

import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;

import java.io.*;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.SocketAddress;
import java.net.SocketImpl;

import static org.junit.Assert.*;
import static org.mockito.Matchers.anyInt;
import static org.powermock.api.mockito.PowerMockito.*;

@RunWith(PowerMockRunner.class)
@PrepareForTest(SocketImpl.class)
public class SnifferSocketImplTest {

    @Mock
    private SocketImpl delegate;

    private SnifferSocketImpl sniffySocket;

    @Before
    public void createSniffySocket() {
        sniffySocket = new SnifferSocketImpl(delegate);
    }

    @Test
    public void testSendUrgentData() throws Exception {

        sniffySocket.sendUrgentData(1);

        verifyPrivate(delegate).invoke("sendUrgentData",1);
        verifyNoMoreInteractions(delegate);

    }

    @Test
    public void testSendUrgentDataThrowsIOException() throws Exception {

        IOException expected = new IOException();
        when(delegate, "sendUrgentData", anyInt()).thenThrow(expected);

        try {
            sniffySocket.sendUrgentData(1);
            fail();
        } catch (IOException actual) {
            assertEquals(expected, actual);
        }

        verifyPrivate(delegate).invoke("sendUrgentData",1);
        verifyNoMoreInteractions(delegate);

    }

    @Test
    public void testSendUrgentDataThrowsRuntimeException() throws Exception {

        RuntimeException expected = new RuntimeException();
        when(delegate, "sendUrgentData", anyInt()).thenThrow(expected);

        try {
            sniffySocket.sendUrgentData(1);
            fail();
        } catch (Exception actual) {
            assertEquals(expected, actual);
        }

        verifyPrivate(delegate).invoke("sendUrgentData",1);
        verifyNoMoreInteractions(delegate);

    }

    @Test
    public void testShutdownInput() throws Exception {

        sniffySocket.shutdownInput();

        verifyPrivate(delegate).invoke("shutdownInput");
        verifyNoMoreInteractions(delegate);

    }

    @Test
    public void testShutdownInputThrowsIOException() throws Exception {

        IOException expected = new IOException();
        when(delegate, "shutdownInput").thenThrow(expected);

        try {
            sniffySocket.shutdownInput();
            fail();
        } catch (IOException actual) {
            assertEquals(expected, actual);
        }

        verifyPrivate(delegate).invoke("shutdownInput");
        verifyNoMoreInteractions(delegate);

    }

    @Test
    public void testShutdownInputThrowsRuntimeException() throws Exception {

        RuntimeException expected = new RuntimeException();
        when(delegate, "shutdownInput").thenThrow(expected);

        try {
            sniffySocket.shutdownInput();
            fail();
        } catch (Exception actual) {
            assertEquals(expected, actual);
        }

        verifyPrivate(delegate).invoke("shutdownInput");
        verifyNoMoreInteractions(delegate);

    }

    @Test
    public void testShutdownOutput() throws Exception {

        sniffySocket.shutdownOutput();

{'fraction_non_alphanumeric': 0.0966572059287291, 'fraction_numerical': 0.002522863450015768, 'mean_word_length': 3.124187256176853, 'pattern_counts': {'":': 0, '<': 3, '<?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': '3316868', 'n_tokens_mistral': 1740, 'n_tokens_neox': 1667, 'n_words': 322}