Fix / unsuppress some URLConnectTests tests

URLConnectionTest.testConnectTimeouts():

The code was creating a URL like:

http://:::<port number>/

because the stuck server returns "::" as the host
address for the wildcard binding done. This URL
is invalid (as it is missing [] around the IPv6
address string).

The test was supposed to check multiple IPs are tried
and the overall timeout is the sum of all the sockets
tried.

Switching StuckServer over to binding to localhost
did not work.

Since the format of the URL does not appear to be the
purpose of this test it is reasonable to change it
before the OkHttp update.

Instead, the test now replaces the the SocketFactory
with one that returns sockets that immediately time
out, avoid the need to nerf the server-side entirely.
The test does not test multiple IPs because (AFAIK) the
tests cannot depend on being able to resolve real
server names. This part of the change involved creating
a hidden method in SocketFactory.

This change adds a new dependency on Mockito so that a
partial mock for Socket can be created.

URLConnectionTest.testServerShutdownInput():

Unsuppress. It should work now.

Bug: 5534202
Bug: 23888521
Change-Id: Iaa57987c59cd6ec1c117f9c90f6ff8ea42d58210
6 files changed