WWWFormCodec { public static List<NameValuePair> parse(final CharSequence s, final Charset charset) { return URIBuilder.parseQuery(s, charset, true); }  static List<NameValuePair> parse(final CharSequence s, final Charset charset); static void format(
            final StringBuilder buf, final Iterable<? extends NameValuePair> params, final Charset charset); static String format(final Iterable<? extends NameValuePair> params, final Charset charset);  }
@Test public void testParse() throws Exception { MatcherAssert.assertThat(parse(""), NameValuePairListMatcher.isEmpty()); MatcherAssert.assertThat(parse("Name0"), NameValuePairListMatcher.equalsTo(new BasicNameValuePair("Name0", null))); MatcherAssert.assertThat(parse("Name1=Value1"), NameValuePairListMatcher.equalsTo(new BasicNameValuePair("Name1", "Value1"))); MatcherAssert.assertThat(parse("Name2="), NameValuePairListMatcher.equalsTo(new BasicNameValuePair("Name2", ""))); MatcherAssert.assertThat(parse(" Name3 "), NameValuePairListMatcher.equalsTo(new BasicNameValuePair("Name3", null))); MatcherAssert.assertThat(parse("Name4=Value%204%21"), NameValuePairListMatcher.equalsTo(new BasicNameValuePair("Name4", "Value 4!"))); MatcherAssert.assertThat(parse("Name4=Value%2B4%21"), NameValuePairListMatcher.equalsTo(new BasicNameValuePair("Name4", "Value+4!"))); MatcherAssert.assertThat(parse("Name4=Value%204%21%20%214"), NameValuePairListMatcher.equalsTo(new BasicNameValuePair("Name4", "Value 4! !4"))); MatcherAssert.assertThat(parse("Name5=aaa&Name6=bbb"), NameValuePairListMatcher.equalsTo( new BasicNameValuePair("Name5", "aaa"), new BasicNameValuePair("Name6", "bbb"))); MatcherAssert.assertThat(parse("Name7=aaa&Name7=b%2Cb&Name7=ccc"), NameValuePairListMatcher.equalsTo( new BasicNameValuePair("Name7", "aaa"), new BasicNameValuePair("Name7", "b,b"), new BasicNameValuePair("Name7", "ccc"))); MatcherAssert.assertThat(parse("Name8=xx%2C%20%20yy%20%20%2Czz"), NameValuePairListMatcher.equalsTo(new BasicNameValuePair("Name8", "xx, yy ,zz"))); MatcherAssert.assertThat(parse("price=10%20%E2%82%AC"), NameValuePairListMatcher.equalsTo(new BasicNameValuePair("price", "10 \u20AC"))); MatcherAssert.assertThat(parse("a=b\"c&d=e"), NameValuePairListMatcher.equalsTo( new BasicNameValuePair("a", "b\"c"), new BasicNameValuePair("d", "e"))); MatcherAssert.assertThat(parse("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))); }