@Test
public void testParseQuery() throws Exception {

    MatcherAssert.assertThat(parseQuery(""), NameValuePairListMatcher.isEmpty());
    MatcherAssert.assertThat(parseQuery("Name0"),
            NameValuePairListMatcher.equalsTo(new BasicNameValuePair("Name0", null)));
    MatcherAssert.assertThat(parseQuery("Name1=Value1"),
            NameValuePairListMatcher.equalsTo(new BasicNameValuePair("Name1", "Value1")));
    MatcherAssert.assertThat(parseQuery("Name2="),
            NameValuePairListMatcher.equalsTo(new BasicNameValuePair("Name2", "")));
    MatcherAssert.assertThat(parseQuery(" Name3  "),
            NameValuePairListMatcher.equalsTo(new BasicNameValuePair("Name3", null)));
    MatcherAssert.assertThat(parseQuery("Name4=Value%204%21"),
            NameValuePairListMatcher.equalsTo(new BasicNameValuePair("Name4", "Value 4!")));
    MatcherAssert.assertThat(parseQuery("Name4=Value%2B4%21"),
            NameValuePairListMatcher.equalsTo(new BasicNameValuePair("Name4", "Value+4!")));
    MatcherAssert.assertThat(parseQuery("Name4=Value%204%21%20%214"),
            NameValuePairListMatcher.equalsTo(new BasicNameValuePair("Name4", "Value 4! !4")));
    MatcherAssert.assertThat(parseQuery("Name5=aaa&Name6=bbb"),
            NameValuePairListMatcher.equalsTo(
                    new BasicNameValuePair("Name5", "aaa"),
                    new BasicNameValuePair("Name6", "bbb")));
    MatcherAssert.assertThat(parseQuery("Name7=aaa&Name7=b%2Cb&Name7=ccc"),
            NameValuePairListMatcher.equalsTo(
                    new BasicNameValuePair("Name7", "aaa"),
                    new BasicNameValuePair("Name7", "b,b"),
                    new BasicNameValuePair("Name7", "ccc")));
    MatcherAssert.assertThat(parseQuery("Name8=xx%2C%20%20yy%20%20%2Czz"),
            NameValuePairListMatcher.equalsTo(new BasicNameValuePair("Name8", "xx,  yy  ,zz")));
    MatcherAssert.assertThat(parseQuery("price=10%20%E2%82%AC"),
            NameValuePairListMatcher.equalsTo(new BasicNameValuePair("price", "10 \u20AC")));
    MatcherAssert.assertThat(parseQuery("a=b\"c&d=e"),
            NameValuePairListMatcher.equalsTo(
                    new BasicNameValuePair("a", "b\"c"),
                    new BasicNameValuePair("d", "e")));
    MatcherAssert.assertThat(parseQuery("russian=" + PercentCodec.encode(RU_HELLO, StandardCharsets.UTF_8) +
                    "&swiss=" + PercentCodec.encode(CH_HELLO, StandardCharsets.UTF_8)),
            NameValuePairListMatcher.equalsTo(
                    new BasicNameValuePair("russian", RU_HELLO),
                    new BasicNameValuePair("swiss", CH_HELLO)));
}