@Test
public void testBind() throws Exception {

  Configuration conf = new Configuration();
  ServerSocket socket = new ServerSocket();
  InetSocketAddress address = new InetSocketAddress("0.0.0.0",0);
  socket.bind(address);
  try {
    int min = socket.getLocalPort();
    int max = min + 100;
    conf.set("TestRange", min+"-"+max);
    
    ServerSocket socket2 = new ServerSocket();
    InetSocketAddress address2 = new InetSocketAddress("0.0.0.0", 0);
    Server.bind(socket2, address2, 10, conf, "TestRange");
    try {
      assertTrue(socket2.isBound());
      assertTrue(socket2.getLocalPort() > min);
      assertTrue(socket2.getLocalPort() <= max);
    } finally {
      socket2.close();
    }
  } finally {
    socket.close();
  }
}