package net.kencochrane.raven.connection;

import mockit.Injectable;
import mockit.Tested;
import mockit.Verifications;
import net.kencochrane.raven.event.Event;
import net.kencochrane.raven.marshaller.Marshaller;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;

import java.io.OutputStream;
import java.net.InetAddress;

public class UdpConnectionTest {
    @Injectable
    private final String hostname = "127.0.0.1";
    @Injectable
    private final String publicKey = "44850120-9d2a-451b-8e00-998bddaa2800";
    @Injectable
    private final String secretKey = "1de38091-6e8c-42df-8298-cf7f8098617a";
    @Tested
    private UdpConnection udpConnection;
    @Injectable
    private Marshaller mockMarshaller;

    @BeforeMethod
    public void setUp() throws Exception {
        udpConnection = null;
    }

    @Test
    public void testContentMarshalled(@Injectable final Event event) throws Exception {
        udpConnection.send(event);

        new Verifications() {{
            mockMarshaller.marshall(event, (OutputStream) any);
        }};
    }
}

@@ -54,69 +54,9 @@
 kit.
-Injectable;%0Aimport mockit.Tested;%0Aimport mockit.Verifications
+*
 ;%0Aim
@@ -257,16 +257,48 @@
 Stream;%0A
+import java.net.DatagramSocket;%0A
 import j
@@ -309,16 +309,22 @@
 net.Inet
+Socket
 Address;
@@ -325,16 +325,17 @@
 dress;%0A%0A
+%0A
 public c
@@ -717,16 +717,75 @@
 shaller;
+%0A    @Mocked%0A    private DatagramSocket mockDatagramSocket;
 %0A%0A    @B
@@ -831,32 +831,32 @@
 ows Exception %7B%0A
-
         udpConne
@@ -876,16 +876,632 @@
 %0A    %7D%0A%0A
+    @Test%0A    public void testConnectionWorkingWithProperHost(@Injectable(%22customHostname%22) final String mockHostname,%0A                                                    @Injectable(%221234%22) final int mockPort) throws Exception %7B%0A        new UdpConnection(mockHostname, mockPort, publicKey, secretKey);%0A%0A        new Verifications() %7B%7B%0A            InetSocketAddress generatedAddress;%0A            mockDatagramSocket.connect(generatedAddress = withCapture());%0A            assertThat(generatedAddress.getHostName(), is(mockHostname));%0A            assertThat(generatedAddress.getPort(), is(mockPort));%0A        %7D%7D;%0A    %7D%0A%0A
     @Tes

Add tests to check connection through UDP