### Question:
SpiffeSslSocketFactory extends SSLSocketFactory { @Override public Socket createSocket(Socket socket, String s, int i, boolean b) throws IOException { return delegate.createSocket(socket, s, i, b); } SpiffeSslSocketFactory(final SslContextOptions contextOptions);   SpiffeSslSocketFactory(final SSLSocketFactory delegate); @Override String[] getDefaultCipherSuites(); @Override String[] getSupportedCipherSuites(); @Override Socket createSocket(Socket socket, String s, int i, boolean b); @Override Socket createSocket(String s, int i); @Override Socket createSocket(String s, int i, InetAddress inetAddress, int i1); @Override Socket createSocket(InetAddress inetAddress, int i); @Override Socket createSocket(InetAddress inetAddress, int i, InetAddress inetAddress1, int i1); @Override Socket createSocket();  }### Answer:
@Test void createSocket() throws IOException { SpiffeSslSocketFactory socketFactory = new SpiffeSslSocketFactory(sslSocketFactoryMock); Socket expected = new Socket(); when(sslSocketFactoryMock.createSocket()).thenReturn(expected); Socket socket = socketFactory.createSocket(); assertEquals(expected, socket); }
@Test void testCreateSocket_HostParameter() throws IOException { SpiffeSslSocketFactory socketFactory = new SpiffeSslSocketFactory(sslSocketFactoryMock); Socket expected = new Socket(); when(sslSocketFactoryMock.createSocket("string", 1)).thenReturn(expected); Socket socket = socketFactory.createSocket("string", 1); assertEquals(expected, socket); }
@Test void testCreateSocket_InetAddressParameter() throws IOException { SpiffeSslSocketFactory socketFactory = new SpiffeSslSocketFactory(sslSocketFactoryMock); Socket expected = new Socket(); when(sslSocketFactoryMock.createSocket(InetAddress.getLocalHost(), 1)).thenReturn(expected); Socket socket = socketFactory.createSocket(InetAddress.getLocalHost(), 1); assertEquals(expected, socket); }
@Test void testCreateSocket_StringInetAddressParameter() throws IOException { SpiffeSslSocketFactory socketFactory = new SpiffeSslSocketFactory(sslSocketFactoryMock); Socket expected = new Socket(); when(sslSocketFactoryMock.createSocket("string", 1, InetAddress.getLocalHost(), 2)).thenReturn(expected); Socket socket = socketFactory.createSocket("string", 1, InetAddress.getLocalHost(), 2); assertEquals(expected, socket); }
@Test void testCreateSocket_InetAddressPortInetAddressPortParameters() throws IOException { SpiffeSslSocketFactory socketFactory = new SpiffeSslSocketFactory(sslSocketFactoryMock); Socket expected = new Socket(); when(sslSocketFactoryMock.createSocket(InetAddress.getLocalHost(), 1, InetAddress.getLocalHost(), 2)).thenReturn(expected); Socket socket = socketFactory.createSocket(InetAddress.getLocalHost(), 1, InetAddress.getLocalHost(), 2); assertEquals(expected, socket); }
@Test void testCreateSocket_parametersSocketStringPortAutoClose() throws IOException { SpiffeSslSocketFactory socketFactory = new SpiffeSslSocketFactory(sslSocketFactoryMock); Socket expected = new Socket(); Socket s = new Socket(); when(sslSocketFactoryMock.createSocket(s, "string", 1, true)).thenReturn(expected); Socket socket = socketFactory.createSocket(s, "string", 1, true); assertEquals(expected, socket); }