@@ -0,0 +1,2875 @@
+/*-%0A * -%5C-%5C-%0A * docker-client%0A * --%0A * Copyright (C) 2016 - 2017 Spotify AB%0A * --%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A * %0A *      http://www.apache.org/licenses/LICENSE-2.0%0A * %0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A * -/-/-%0A */%0A%0Apackage com.spotify.docker.client;%0A%0Aimport static org.hamcrest.MatcherAssert.assertThat;%0Aimport static org.hamcrest.Matchers.equalTo;%0Aimport static org.mockito.Mockito.mock;%0Aimport static org.mockito.Mockito.verify;%0Aimport static org.mockito.Mockito.when;%0A%0Aimport java.net.InetSocketAddress;%0Aimport java.net.Socket;%0Aimport java.net.URI;%0Aimport java.nio.channels.SocketChannel;%0Aimport javax.net.ssl.SSLSocket;%0Aimport jnr.unixsocket.UnixSocket;%0Aimport org.apache.http.HttpHost;%0Aimport org.apache.http.protocol.HttpContext;%0Aimport org.hamcrest.core.IsInstanceOf;%0Aimport org.junit.Before;%0Aimport org.junit.Rule;%0Aimport org.junit.Test;%0Aimport org.junit.rules.ExpectedException;%0A%0Apublic class UnixConnectionSocketFactoryTest %7B%0A%0A  @Rule%0A  public ExpectedException exception = ExpectedException.none();%0A%0A  private UnixConnectionSocketFactory sut;%0A%0A  @Before%0A  public void setup() throws Exception %7B%0A    sut = new UnixConnectionSocketFactory(new URI(%22unix://localhost%22));%0A  %7D%0A%0A  @Test%0A  public void testSanitizeUri() throws Exception %7B%0A    final URI unixUri = UnixConnectionSocketFactory.sanitizeUri(URI.create(%22unix://localhost%22));%0A    assertThat(unixUri, equalTo(URI.create(%22unix://localhost:80%22)));%0A%0A    final URI nonUnixUri = URI.create(%22http://127.0.0.1%22);%0A    final URI uri = UnixConnectionSocketFactory.sanitizeUri(nonUnixUri);%0A    assertThat(uri, equalTo(nonUnixUri));%0A  %7D%0A%0A  @Test%0A  public void testConnectSocket() throws Exception %7B%0A    final UnixSocket unixSocket = mock(UnixSocket.class);%0A    when(unixSocket.getChannel()).thenReturn(mock(SocketChannel.class));%0A    final Socket socket = sut.connectSocket(10, unixSocket, HttpHost.create(%22http://foo.com%22),%0A        mock(InetSocketAddress.class), mock(InetSocketAddress.class), mock(HttpContext.class));%0A    verify(unixSocket).setSoTimeout(10);%0A    assertThat(socket, IsInstanceOf.instanceOf(UnixSocket.class));%0A    assertThat((UnixSocket) socket, equalTo(unixSocket));%0A  %7D%0A%0A  @Test(expected = AssertionError.class)%0A  public void testConnectSocketNotUnixSocket() throws Exception %7B%0A    sut.connectSocket(10, mock(SSLSocket.class), HttpHost.create(%22http://foo.com%22),%0A        mock(InetSocketAddress.class), mock(InetSocketAddress.class), mock(HttpContext.class));%0A  %7D%0A%0A%7D%0A

Add tests for UnixConnectionSocketFactory