@Test
public void testQuery04_url_encoding_for_queryString() {

    Map<String, Object> map = new LinkedHashMap<String, Object>();
    // Specify a characters(#[]) that cannot use in the query on RFC3986.
    // See http://tools.ietf.org/html/rfc3986#section-3.4.
    map.put("key#1", "value#1");
    map.put("key[2", "value[2");
    map.put("key]3", "value]3");
    // Specify a characters(&=+) that must be escaped in the query on general web server.
    map.put("key&4", "value&4");
    map.put("key=5", "value=5");
    map.put("key+6", "value+6");
    String actualQuery = Functions.query(map);
    StringBuilder expectedQuery = new StringBuilder();
    expectedQuery.append("key%231=value%231"); // #
    expectedQuery.append("&").append("key%5B2=value%5B2"); // [
    expectedQuery.append("&").append("key%5D3=value%5D3"); // ]
    expectedQuery.append("&").append("key%264=value%264"); // &
    expectedQuery.append("&").append("key%3D5=value%3D5"); // =
    expectedQuery.append("&").append("key%2B6=value%2B6"); // +
    assertThat(actualQuery, is(expectedQuery.toString()));
}