Tidy up MulticastSocketTest and fix execution on hammerhead

Similar to the fixes for DatagramChannelMulticastTest
in 6d7b081971d12b25426c46e4989e7df3a5995eae but
for java.net.MulticastSocket.

Because MulticastSocketTest was the genesis of
DatagramChannelMulticastTest it had similar issues to that one,
but also contained other unnecessary or badly formatted code.

The main changes here are:
1) Fix the tests that were implicitly assuming that the
IPv6NetworkInterface1 was the same interface as the IPv4
version (networkInterface1).

2) Renamed variables / moved setUp to the top of the class /
closed sockets after use / fixed try/catch blocks to only wrap
expected throwing code / pulled out common code into new methods
and generally tidied up.

3) Removed the use of the "MulticastServer" class entirely.
This "server" would listen to socket on a separate thread and
was the source of multiple Thread.sleep(1000) calls in the test.
The tests rely exclusively on multicast loopback mode anyway
(MulticastSocket.setLoopbackMode()) and
MulticastSocket.receive() is blocking, which means it either
gets an immediate result or the test can rely on the
setSoTimeout() method to limit the time spent waiting. The use
of multiple threads was therefore unnecessary.

Bug: 15509450
Change-Id: Ie448cc3b2d7432012957db34c72949a7b4da359f
1 file changed