Package org.apache.wink.itest.client.jaxb

Examples of org.apache.wink.itest.client.jaxb.Echo


        assertEquals("echo: " + MediaType.APPLICATION_JSON, j.get("value"));

        s =
            client.resource(getBaseURI() + "/echoaccept").accept(MediaType.TEXT_XML)
                .get(String.class);
        Echo e =
            (Echo)JAXBContext.newInstance(Echo.class).createUnmarshaller()
                .unmarshal(new StringReader(s));
        assertEquals(e.getValue(), "echo: " + MediaType.TEXT_XML);

        /*
         * this is actually a trick to make sure that plain text is returned.
         * the server side piece does not produce APPLICATION_XML but will
         * produce TEXT_PLAIN for any non-produced type. it really should return
View Full Code Here


     * For JAXB objects, there will be an error as the resource will return a
     * text/plain representation.
     */
    public void testAcceptHeaderForJAXB() {
        try {
            Echo e  = client.resource(getBaseURI() + "/echoaccept").get(Echo.class);
            fail();
//            String value = e.getValue();
//            assertTrue(value, value.contains(MediaType.APPLICATION_JSON));
//            assertTrue(value, value.contains(MediaType.APPLICATION_XML));
//            assertTrue(value, value.contains(MediaType.TEXT_XML));
//            assertTrue(value, value.contains("application/javascript"));
        } catch (RuntimeException e) {
            assertEquals(e.getMessage(), String
                .format("No reader for type class %s and media type %s",
                        Echo.class.getName(),
                        MediaType.TEXT_PLAIN));
        }
    }
View Full Code Here

        assertEquals("echo: " + MediaType.APPLICATION_JSON, j.get("value"));

        s =
            client.resource(getBaseURI() + "/echoaccept").accept(MediaType.TEXT_XML)
                .get(String.class);
        Echo e =
            (Echo)JAXBContext.newInstance(Echo.class).createUnmarshaller()
                .unmarshal(new StringReader(s));
        assertEquals(e.getValue(), "echo: " + MediaType.TEXT_XML);

        /*
         * this is actually a trick to make sure that plain text is returned.
         * the server side piece does not produce APPLICATION_XML but will
         * produce TEXT_PLAIN for any non-produced type. it really should return
View Full Code Here

     * For JAXB objects, there will be an error as the resource will return a
     * text/plain representation.
     */
    public void testAcceptHeaderForJAXB() {
        try {
            Echo e = client.resource(getBaseURI() + "/echoaccept").get(Echo.class);
            fail();
            // String value = e.getValue();
            // assertTrue(value, value.contains(MediaType.APPLICATION_JSON));
            // assertTrue(value, value.contains(MediaType.APPLICATION_XML));
            // assertTrue(value, value.contains(MediaType.TEXT_XML));
            // assertTrue(value, value.contains("application/javascript"));
        } catch (RuntimeException e) {
            assertEquals(e.getMessage(),
                         String
                             .format("A javax.ws.rs.ext.MessageBodyReader implementation was not found for class %s type and %s media type.  Verify that all entity providers are correctly registered.  Add a custom javax.ws.rs.ext.MessageBodyReader provider to handle the type and media type if a JAX-RS entity provider does not currently exist.",
                                     Echo.class.getName(),
                                     MediaType.TEXT_PLAIN));
        }
View Full Code Here

        assertEquals("echo: " + MediaType.APPLICATION_JSON, j.get("value"));

        s =
            client.resource(getBaseURI() + "/echoaccept").accept(MediaType.TEXT_XML)
                .get(String.class);
        Echo e =
            (Echo)JAXBContext.newInstance(Echo.class).createUnmarshaller()
                .unmarshal(new StringReader(s));
        assertEquals(e.getValue(), "echo: " + MediaType.TEXT_XML);

        /*
         * this is actually a trick to make sure that plain text is returned.
         * the server side piece does not produce APPLICATION_XML but will
         * produce TEXT_PLAIN for any non-produced type. it really should return
View Full Code Here

    /**
     * For JAXB objects, the {@link AcceptHeaderHandler} should automatically
     * take care of the Accept header.
     */
    public void testAcceptHeaderForJAXB() {
        Echo p = client.resource(getBaseURI() + "/echoaccept").get(Echo.class);
        assertTrue(p.getValue().contains(MediaType.TEXT_XML) && p.getValue()
            .contains(MediaType.APPLICATION_XML));
    }
View Full Code Here

            if (MediaType.APPLICATION_JSON_TYPE.isCompatible(variant.getMediaType())) {
                JSONObject jsonObject = new JSONObject();
                jsonObject.put("value", sb.toString());
                return Response.ok(jsonObject).type(MediaType.APPLICATION_JSON).build();
            } else if (MediaType.TEXT_XML_TYPE.isCompatible(variant.getMediaType())) {
                Echo e = new Echo();
                e.setValue(sb.toString());
                return Response.ok(e).type(MediaType.TEXT_XML).build();
            }
        }

        return Response.ok(sb.toString()).type(MediaType.TEXT_PLAIN_TYPE).build();
View Full Code Here

        assertEquals("echo: " + MediaType.APPLICATION_JSON, j.get("value"));

        s =
            client.resource(getBaseURI() + "/echoaccept").accept(MediaType.TEXT_XML)
                .get(String.class);
        Echo e =
            (Echo)JAXBContext.newInstance(Echo.class).createUnmarshaller()
                .unmarshal(new StringReader(s));
        assertEquals(e.getValue(), "echo: " + MediaType.TEXT_XML);

        /*
         * this is actually a trick to make sure that plain text is returned.
         * the server side piece does not produce APPLICATION_XML but will
         * produce TEXT_PLAIN for any non-produced type. it really should return
View Full Code Here

     * For JAXB objects, there will be an error as the resource will return a
     * text/plain representation.
     */
    public void testAcceptHeaderForJAXB() {
        try {
            Echo e = client.resource(getBaseURI() + "/echoaccept").get(Echo.class);
            fail();
            // String value = e.getValue();
            // assertTrue(value, value.contains(MediaType.APPLICATION_JSON));
            // assertTrue(value, value.contains(MediaType.APPLICATION_XML));
            // assertTrue(value, value.contains(MediaType.TEXT_XML));
            // assertTrue(value, value.contains("application/javascript"));
        } catch (RuntimeException e) {
            assertEquals(e.getMessage(),
                         String
                             .format("No javax.ws.rs.ext.MessageBodyReader found for type class %s and media type %s.  Verify that all entity providers are correctly registered.",
                                     Echo.class.getName(),
                                     MediaType.TEXT_PLAIN));
        }
View Full Code Here

TOP

Related Classes of org.apache.wink.itest.client.jaxb.Echo

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.