@@ -0,0 +1,3358 @@
+package net.kencochrane.raven.connection;%0A%0Aimport net.kencochrane.raven.Dsn;%0Aimport net.kencochrane.raven.event.Event;%0Aimport net.kencochrane.raven.event.EventBuilder;%0Aimport net.kencochrane.raven.marshaller.Marshaller;%0Aimport org.junit.Before;%0Aimport org.junit.Test;%0Aimport org.junit.runner.RunWith;%0Aimport org.mockito.Answers;%0Aimport org.mockito.Mock;%0Aimport org.mockito.runners.MockitoJUnitRunner;%0A%0Aimport javax.net.ssl.HostnameVerifier;%0Aimport javax.net.ssl.HttpsURLConnection;%0Aimport java.io.IOException;%0Aimport java.io.OutputStream;%0Aimport java.net.URI;%0Aimport java.net.URL;%0Aimport java.net.URLConnection;%0Aimport java.net.URLStreamHandler;%0Aimport java.util.UUID;%0A%0Aimport static org.hamcrest.MatcherAssert.assertThat;%0Aimport static org.hamcrest.core.Is.is;%0Aimport static org.mockito.Matchers.any;%0Aimport static org.mockito.Mockito.*;%0A%0A@RunWith(MockitoJUnitRunner.class)%0Apublic class HttpConnectionTest %7B%0A    private HttpConnection httpConnection;%0A    private String publicKey = UUID.randomUUID().toString();%0A    private String secretKey = UUID.randomUUID().toString();%0A    @Mock(answer = Answers.RETURNS_MOCKS)%0A    private HttpsURLConnection mockUrlConnection;%0A    @Mock%0A    private Marshaller mockMarshaller;%0A%0A    @Before%0A    public void setUp() throws Exception %7B%0A        URLStreamHandler stubUrlHandler = new URLStreamHandler() %7B%0A            @Override%0A            protected URLConnection openConnection(URL u) throws IOException %7B%0A                return mockUrlConnection;%0A            %7D%0A        %7D;%0A%0A        URL mockUrl = new URL(null, %22http://%22, stubUrlHandler);%0A        httpConnection = new HttpConnection(mockUrl, publicKey, secretKey);%0A        httpConnection.setMarshaller(mockMarshaller);%0A    %7D%0A%0A    @Test%0A    public void testTimeout() throws Exception %7B%0A        int timeout = 12;%0A        httpConnection.setTimeout(timeout);%0A        httpConnection.send(new EventBuilder().build());%0A%0A        verify(mockUrlConnection).setConnectTimeout(timeout);%0A    %7D%0A%0A    @Test%0A    public void testByPassSecurity() throws Exception %7B%0A        httpConnection.send(new EventBuilder().build());%0A        verify(mockUrlConnection, never()).setHostnameVerifier(any(HostnameVerifier.class));%0A%0A        reset(mockUrlConnection);%0A        httpConnection.setBypassSecurity(true);%0A        httpConnection.send(new EventBuilder().build());%0A        verify(mockUrlConnection).setHostnameVerifier(any(HostnameVerifier.class));%0A%0A        reset(mockUrlConnection);%0A        httpConnection.setBypassSecurity(false);%0A        httpConnection.send(new EventBuilder().build());%0A        verify(mockUrlConnection, never()).setHostnameVerifier(any(HostnameVerifier.class));%0A    %7D%0A%0A    @Test%0A    public void testContentMarshalled() throws Exception %7B%0A        Event event = new EventBuilder().build();%0A%0A        httpConnection.send(event);%0A%0A        verify(mockMarshaller).marshall(eq(event), any(OutputStream.class));%0A    %7D%0A%0A    @Test%0A    public void testApiUrlCreation() throws Exception %7B%0A        Dsn dsn = mock(Dsn.class);%0A        String projectId = UUID.randomUUID().toString();%0A        String uri = %22http://host/sentry/%22;%0A        when(dsn.getUri()).thenReturn(new URI(uri));%0A        when(dsn.getProjectId()).thenReturn(projectId);%0A%0A        URL sentryApiUrl = HttpConnection.getSentryApiUrl(dsn);%0A%0A        assertThat(sentryApiUrl.toString(), is(uri + %22api/%22 + projectId + %22/store/%22));%0A    %7D%0A%7D%0A

Add unit tests for HttpConnection