Package org.restlet

Examples of org.restlet.Response


        }
    }

    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


    public void testGetTextAll() throws Exception {
        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

        assertEqualMediaType(MediaType.TEXT_PLAIN, representation);
    }

    public void testGetTextMultiple1() throws Exception {
        if (!ONLY_M2 && !ONLY_TEXT_ALL) {
            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

    public void testGetTextMultiple2() throws Exception {
        if (ONLY_TEXT_ALL) {
            return;
        }
        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

        assertEquals(SimpleTrain.RERP_HTML_TEXT, representation.getText());
    }

    public void testHead() throws Exception {
        if (!ONLY_M2 && !ONLY_TEXT_ALL) {
            final Response responseHead = accessServer(Method.HEAD,
                    SimpleTrain.class, TestUtils.createList(new Object[] {
                            PREF_TEXTPLAIN_QUAL05, MediaType.TEXT_HTML }));
            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

            assertEquals(SimpleTrain.RERP_HTML_TEXT, entityGett.getText());
        }
    }

    public void testOptions() throws Exception {
        final Response response = options();
        sysOutEntityIfError(response);
        assertAllowedMethod(response, Method.GET);
    }
View Full Code Here

        assertAllowedMethod(response, Method.GET);
    }

    public void testTemplParamsDecoded() throws Exception {
        final String deEncoded = "decode";
        Response response = get(deEncoded + "/66");
        sysOutEntityIfError(response);
        assertEquals(Status.SUCCESS_OK, response.getStatus());
        assertEquals("66", response.getEntity().getText());

        response = get(deEncoded + "/a+bc");
        sysOutEntityIfError(response);
        assertEquals(Status.SUCCESS_OK, response.getStatus());
        assertEquals("a bc", response.getEntity().getText());

        response = get(deEncoded + "/a%20bc");
        sysOutEntityIfError(response);
        assertEquals(Status.SUCCESS_OK, response.getStatus());
        assertEquals("a bc", response.getEntity().getText());
    }
View Full Code Here

        assertEquals("a bc", response.getEntity().getText());
    }

    public void testTemplParamsEncoded() throws Exception {
        final String deEncoded = "encode";
        Response response = get(deEncoded + "/66");
        sysOutEntityIfError(response);
        assertEquals(Status.SUCCESS_OK, response.getStatus());
        assertEquals("66", response.getEntity().getText());

        response = get(deEncoded + "/a+bc");
        sysOutEntityIfError(response);
        assertEquals(Status.SUCCESS_OK, response.getStatus());
        assertEquals("a+bc", response.getEntity().getText());

        response = get(deEncoded + "/a%20bc");
        sysOutEntityIfError(response);
        assertEquals(Status.SUCCESS_OK, response.getStatus());
        assertEquals("a%20bc", response.getEntity().getText());
    }
View Full Code Here

    /**
     * @param accMediaType
     * @param expMediaType
     */
    private void check(MediaType accMediaType, MediaType expMediaType) {
        final Response response = get(accMediaType);
        sysOutEntityIfError(response);
        assertEquals(IllegalArgExcMapper.STATUS, response.getStatus().getCode());
        assertEqualMediaType(expMediaType, response);
    }
View Full Code Here

        };
        return appConfig;
    }

    public void test0() throws Exception {
        final Response response = get();
        sysOutEntityIfError(response);
        assertEquals(Status.SUCCESS_OK, response.getStatus());
        assertEquals("0", response.getEntity().getText());
    }
View Full Code Here

TOP

Related Classes of org.restlet.Response

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.