Package org.restlet.representation

Examples of org.restlet.representation.Representation


     */
    static void assertUriAndMediaType(MediaType expectedMT, Response response,
            boolean checkEntityText, String reference) throws IOException {
        sysOutEntityIfError(response);
        assertEquals(Status.SUCCESS_OK, response.getStatus());
        final Representation entity = response.getEntity();
        assertEqualMediaType(expectedMT, entity.getMediaType());
        if (checkEntityText) {
            assertEquals(reference.toString(), entity.getText());
        }
    }
View Full Code Here


    public void test2() throws IOException {
        final Response response = get();
        sysOutEntityIfError(response);
        assertEquals(Status.SUCCESS_NO_CONTENT, response.getStatus());
        final Representation entity = response.getEntity();
        String text;
        if (entity != null) {
            text = entity.getText();
        } else {
            text = null;
        }
        assertEquals(null, text);
    }
View Full Code Here

    }

    /** @throws IOException
     *  @see RepresentationTestService#post(Representation) */
    public void testDecodePost() throws IOException {
        final Representation repr = new StringRepresentation("abcde");
        final Response response = post("reprDecode", repr);
        sysOutEntityIfError(response);
        assertEquals(Status.SUCCESS_OK, response.getStatus());
        assertEquals("abcde", response.getEntity().getText());
    }
View Full Code Here

    public void testGetHtmlText() throws Exception {
        if (!ONLY_M2 && !ONLY_TEXT_ALL) {
            final Response response = get(MediaType.TEXT_HTML);
            sysOutEntityIfError(response);
            assertTrue(response.getStatus().isSuccess());
            final Representation entity = response.getEntity();
            assertEquals(SimpleTrain.RERP_HTML_TEXT, entity.getText());
            assertEqualMediaType(MediaType.TEXT_HTML, entity.getMediaType());
        }
    }
View Full Code Here

    public void testGetPlainText() throws Exception {
        if (!ONLY_M2 && !ONLY_TEXT_ALL) {
            final Response response = get(MediaType.TEXT_PLAIN);
            sysOutEntityIfError(response);
            assertEquals(Status.SUCCESS_OK, response.getStatus());
            final Representation entity = response.getEntity();
            assertEquals(SimpleTrain.RERP_PLAIN_TEXT, entity.getText());
            assertEqualMediaType(MediaType.TEXT_PLAIN, entity.getMediaType());
        }
    }
View Full Code Here

        if (ONLY_M2) {
            return;
        }
        Response response = get(MediaType.TEXT_ALL);
        sysOutEntityIfError(response);
        Representation representation = response.getEntity();
        final MediaType mediaType = representation.getMediaType();
        assertEquals(Status.SUCCESS_OK, response.getStatus());
        assertTrue(mediaType.equals(MediaType.TEXT_PLAIN, true)
                || mediaType.equals(MediaType.TEXT_HTML, true));

        response = get(MediaType.TEXT_PLAIN);
        sysOutEntityIfError(response);
        assertTrue(response.getStatus().isSuccess());
        representation = response.getEntity();
        assertEquals(SimpleTrain.RERP_PLAIN_TEXT, representation.getText());
        assertEqualMediaType(MediaType.TEXT_PLAIN, representation);
    }
View Full Code Here

            final Response response = accessServer(Method.GET,
                    SimpleTrain.class, TestUtils.createList(new Object[] {
                            PREF_TEXTPLAIN_QUAL05, MediaType.TEXT_CALENDAR }));
            sysOutEntityIfError(response);
            assertEquals(Status.SUCCESS_OK, response.getStatus());
            final Representation entity = response.getEntity();
            assertEqualMediaType(MediaType.TEXT_PLAIN, entity.getMediaType());
            assertEquals(SimpleTrain.RERP_PLAIN_TEXT, entity.getText());
        }
    }
View Full Code Here

        final Response response = accessServer(Method.GET, SimpleTrain.class,
                TestUtils.createList(new Object[] { PREF_TEXTPLAIN_QUAL05,
                        MediaType.TEXT_HTML }));
        sysOutEntityIfError(response);
        assertEquals(Status.SUCCESS_OK, response.getStatus());
        final Representation representation = response.getEntity();
        assertEqualMediaType(MediaType.TEXT_HTML, representation.getMediaType());
        assertEquals(SimpleTrain.RERP_HTML_TEXT, representation.getText());
    }
View Full Code Here

            final Response responseGett = accessServer(Method.GET,
                    SimpleTrain.class, TestUtils.createList(new Object[] {
                            PREF_TEXTPLAIN_QUAL05, MediaType.TEXT_HTML }));
            assertEquals(Status.SUCCESS_OK, responseHead.getStatus());
            assertEquals(Status.SUCCESS_OK, responseGett.getStatus());
            final Representation entityHead = responseHead.getEntity();
            final Representation entityGett = responseGett.getEntity();
            assertNotNull(entityHead);
            assertNotNull(entityGett);
            assertEqualMediaType(MediaType.TEXT_HTML, entityGett.getMediaType());
            assertEquals(SimpleTrain.RERP_HTML_TEXT, entityGett.getText());
        }
    }
View Full Code Here

     * @throws IOException
     */
    private Representation check1(String subPath) throws IOException {
        Form form = new Form();
        form.add("a", "b");
        Representation webRepresentation = form.getWebRepresentation();
        Response response = post(subPath, webRepresentation);
        sysOutEntityIfError(response);
        assertEquals(Status.SUCCESS_OK, response.getStatus());
        assertEquals("a -> b\n", response.getEntity().getText());
        return webRepresentation;
View Full Code Here

TOP

Related Classes of org.restlet.representation.Representation

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.