Package org.apache.wink.common.internal.providers.entity

Examples of org.apache.wink.common.internal.providers.entity.FormMultivaluedMapProvider


        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,
View Full Code Here

TOP

Related Classes of org.apache.wink.common.internal.providers.entity.FormMultivaluedMapProvider

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.