protected static Client createJerseyClient(Configuration conf) {
    Client client = Client.create();

    long checkConnectTimeOut = conf.getLong(YarnConfiguration.ROUTER_WEBAPP_CONNECT_TIMEOUT, 0);
    int connectTimeOut = (int) conf.getTimeDuration(YarnConfiguration.ROUTER_WEBAPP_CONNECT_TIMEOUT,
        YarnConfiguration.DEFAULT_ROUTER_WEBAPP_CONNECT_TIMEOUT, TimeUnit.MILLISECONDS);
    if (checkConnectTimeOut <= 0 || checkConnectTimeOut > Integer.MAX_VALUE) {
      LOG.warn("Configuration {} = {} ms error. We will use the default value({} ms).",
          YarnConfiguration.ROUTER_WEBAPP_CONNECT_TIMEOUT, connectTimeOut,
          YarnConfiguration.DEFAULT_ROUTER_WEBAPP_CONNECT_TIMEOUT);
      connectTimeOut = (int) TimeUnit.MILLISECONDS.convert(
          YarnConfiguration.DEFAULT_ROUTER_WEBAPP_CONNECT_TIMEOUT, TimeUnit.MILLISECONDS);
    }
    client.setConnectTimeout(connectTimeOut);

    long checkReadTimeout = conf.getLong(YarnConfiguration.ROUTER_WEBAPP_READ_TIMEOUT, 0);
    int readTimeout = (int) conf.getTimeDuration(YarnConfiguration.ROUTER_WEBAPP_READ_TIMEOUT,
        YarnConfiguration.DEFAULT_ROUTER_WEBAPP_READ_TIMEOUT, TimeUnit.MILLISECONDS);

    if (checkReadTimeout < 0) {
      LOG.warn("Configuration {} = {} ms error. We will use the default value({} ms).",
          YarnConfiguration.ROUTER_WEBAPP_CONNECT_TIMEOUT, connectTimeOut,
          YarnConfiguration.DEFAULT_ROUTER_WEBAPP_CONNECT_TIMEOUT);
      readTimeout = (int) TimeUnit.MILLISECONDS.convert(
          YarnConfiguration.DEFAULT_ROUTER_WEBAPP_CONNECT_TIMEOUT, TimeUnit.MILLISECONDS);
    }
    client.setReadTimeout(readTimeout);

    return client;
  }
@Test
  public void testCreateJerseyClient() {
    // Case1,  default timeout, The default timeout is 30s.
    YarnConfiguration configuration = new YarnConfiguration();
    Client client01 = RouterWebServiceUtil.createJerseyClient(configuration);
    Map<String, Object> properties = client01.getProperties();
    int readTimeOut = (int) properties.get(ClientConfig.PROPERTY_READ_TIMEOUT);
    int connectTimeOut = (int) properties.get(ClientConfig.PROPERTY_CONNECT_TIMEOUT);
    Assert.assertEquals(30000, readTimeOut);
    Assert.assertEquals(30000, connectTimeOut);
    client01.destroy();

    // Case2, set a negative timeout, We'll get the default timeout(30s)
    YarnConfiguration configuration2 = new YarnConfiguration();
    configuration2.setLong(YarnConfiguration.ROUTER_WEBAPP_CONNECT_TIMEOUT, -1L);
    configuration2.setLong(YarnConfiguration.ROUTER_WEBAPP_READ_TIMEOUT, -1L);
    Client client02 = RouterWebServiceUtil.createJerseyClient(configuration2);
    Map<String, Object> properties02 = client02.getProperties();
    int readTimeOut02 = (int) properties02.get(ClientConfig.PROPERTY_READ_TIMEOUT);
    int connectTimeOut02 =  (int) properties02.get(ClientConfig.PROPERTY_CONNECT_TIMEOUT);
    Assert.assertEquals(30000, readTimeOut02);
    Assert.assertEquals(30000, connectTimeOut02);
    client02.destroy();

    // Case3, Set the maximum value that exceeds the integer
    // We'll get the default timeout(30s)
    YarnConfiguration configuration3 = new YarnConfiguration();
    long connectTimeOutLong = (long) Integer.MAX_VALUE + 1;
    long readTimeOutLong = (long) Integer.MAX_VALUE + 1;

    configuration3.setLong(YarnConfiguration.ROUTER_WEBAPP_CONNECT_TIMEOUT, connectTimeOutLong);
    configuration3.setLong(YarnConfiguration.ROUTER_WEBAPP_READ_TIMEOUT, readTimeOutLong);
    Client client03 = RouterWebServiceUtil.createJerseyClient(configuration3);
    Map<String, Object> properties03 = client03.getProperties();
    int readTimeOut03 = (int) properties03.get(ClientConfig.PROPERTY_READ_TIMEOUT);
    int connectTimeOut03 = (int) properties03.get(ClientConfig.PROPERTY_CONNECT_TIMEOUT);
    Assert.assertEquals(30000, readTimeOut03);
    Assert.assertEquals(30000, connectTimeOut03);
    client03.destroy();
  }