Package org.glassfish.jersey.message.internal

Examples of org.glassfish.jersey.message.internal.MediaTypeProvider.fromString()


    @Test
    public void testFromString() throws Exception {
        final MediaTypeProvider instance = new MediaTypeProvider();

        final String header = "application/xml";
        final MediaType result = instance.fromString(header);
        assertEquals(result.getType(), "application");
        assertEquals(result.getSubtype(), "xml");
        assertEquals(result.getParameters().size(), 0);
    }
View Full Code Here


    @Test
    public void testFromStringWithParams() throws Exception {
        final String header = "application/xml;charset=utf8";
        final MediaTypeProvider instance = new MediaTypeProvider();

        final MediaType result = instance.fromString(header);
        assertEquals(result.getType(), "application");
        assertEquals(result.getSubtype(), "xml");
        assertEquals(result.getParameters().size(), 1);
        assertTrue(result.getParameters().containsKey("charset"));
        assertEquals(result.getParameters().get("charset"), "utf8");
View Full Code Here

        final String result = instance.toString(header);
        final String expResult = "application/xml; foo=\"\\\"bar\\\"\"";
        assertEquals(expResult, result);

        final MediaType m = instance.fromString(result);
        assertEquals("\"bar\"", m.getParameters().get("foo"));
    }
}
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.