public static String constructUrl( VariableSpace space, String hostname, String port, String webAppName,
                                     String serviceAndArguments ) throws UnsupportedEncodingException {
    return constructUrl( space, hostname, port, webAppName, serviceAndArguments, false );
  }
@Test
  public void testConstructUrl() throws Exception {
    Variables variables = new Variables();
    String expected = "hostname:1234/webAppName?param=value";

    Assert.assertEquals( "http://" + expected,
      HttpUtil.constructUrl( variables, "hostname", String.valueOf( 1234 ), "webAppName", "?param=value" ) );

    Assert.assertEquals( "http://" + expected,
      HttpUtil.constructUrl( variables, "hostname", String.valueOf( 1234 ), "webAppName", "?param=value", false ) );

    Assert.assertEquals( "https://" + expected,
      HttpUtil.constructUrl( variables, "hostname", String.valueOf( 1234 ), "webAppName", "?param=value", true ) );
  }