MultivaluedMap<String, String> {
}
@SuppressWarnings("unchecked")
public void testFormMultivaluedMapProvider() throws Exception {
FormMultivaluedMapProvider provider = new FormMultivaluedMapProvider();
Type type = MyMap.class.getGenericInterfaces()[0];
Class<MultivaluedMap<String, String>> rawType =
(Class<MultivaluedMap<String, String>>)((ParameterizedType)type).getRawType();
assertTrue(provider.isReadable(rawType,
type,
null,
MediaType.APPLICATION_FORM_URLENCODED_TYPE));
MultivaluedMap<String, String> map =
provider.readFrom(rawType,
type,
null,
MediaType.APPLICATION_FORM_URLENCODED_TYPE,
null,
new ByteArrayInputStream(FORM_BYTES));
assertNotNull(map);
assertEquals(4, map.size());
assertEquals("A1", map.get("a").get(0));
assertEquals("A2", map.get("a").get(1));
assertEquals("B+B", map.getFirst("b"));
assertEquals("C%24C", map.getFirst("c"));
assertEquals(null, map.getFirst("d"));
assertTrue(provider.isWriteable(rawType,
type,
null,
MediaType.APPLICATION_FORM_URLENCODED_TYPE));
ByteArrayOutputStream os = new ByteArrayOutputStream();
provider.writeTo(map,
rawType,
type,
null,
MediaType.APPLICATION_FORM_URLENCODED_TYPE,
null,