Package org.restlet

Examples of org.restlet.Response


        assertEquals(Status.SUCCESS_OK, response.getStatus());
        assertEquals("abc/def", response.getEntity().getText());
    }

    public void testX() throws Exception {
        Response response = get("abc123");
        assertEquals(Status.SUCCESS_OK, response.getStatus());
        assertEquals("123", response.getEntity().getText());

        response = get("abcdef");
        assertEquals(Status.SUCCESS_OK, response.getStatus());
        assertEquals("def", response.getEntity().getText());
    }
View Full Code Here


        assertEquals(Status.SUCCESS_OK, response.getStatus());
        assertEquals("def", response.getEntity().getText());
    }

    public void testX2() throws Exception {
        Response response = get("abcdef/1234");
        assertEquals(Status.SUCCESS_OK, response.getStatus());
        assertEquals("bcd\n12", response.getEntity().getText());

        response = get("aXYZef/AB34");
        assertEquals(Status.SUCCESS_OK, response.getStatus());
        assertEquals("XYZ\nAB", response.getEntity().getText());
    }
View Full Code Here

            }
        };
    }

    public void testEncodedWithDefault() throws Exception {
        Response response = get("encodedWithDefault;m=1;m=2;x=3");
        assertEquals(Status.SUCCESS_OK, response.getStatus());
        assertEquals("[1, 2]", response.getEntity().getText());

        response = get("encodedWithDefault;m=1;i=2;x=3");
        assertEquals(Status.SUCCESS_OK, response.getStatus());
        assertEquals("[1]", response.getEntity().getText());

        response = get("encodedWithDefault;a=1;i=2;x=3");
        assertEquals(Status.SUCCESS_OK, response.getStatus());
        assertEquals("[default]", response.getEntity().getText());
    }
View Full Code Here

        assertEquals(Status.SUCCESS_OK, response.getStatus());
        assertEquals("[default]", response.getEntity().getText());
    }

    public void testWithoutPath() throws Exception {
        Response response = get(";firstname=Angela;lastname=Merkel");
        assertEquals(Status.SUCCESS_OK, response.getStatus());
        assertEquals("Angela Merkel", response.getEntity().getText());

        response = get(";lastname=Merkel;firstname=Angela");
        assertEquals(Status.SUCCESS_OK, response.getStatus());
        assertEquals("Angela Merkel", response.getEntity().getText());

        response = get(";firstname=Goofy");
        assertEquals(Status.SUCCESS_OK, response.getStatus());
        assertEquals("Goofy null", response.getEntity().getText());

        response = get(";lastname=Goofy");
        assertEquals(Status.SUCCESS_OK, response.getStatus());
        assertEquals("null Goofy", response.getEntity().getText());
    }
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

    }

    /** @throws IOException
     *  @see RepresentationTestService#postJaxb(org.restlet.ext.jaxb.JaxbRepresentation) */
    public void testJaxbPost() throws IOException {
        final Response response = post("jaxb", (Representation) null);
        sysOutEntityIfError(response);
        assertEquals(Status.SUCCESS_NO_CONTENT, response.getStatus());
        assertEquals(null, response.getEntity().getText());
    }
View Full Code Here

        assertEquals(null, response.getEntity().getText());
    }

    /** @see RepresentationTestService#get() */
    public void testReprGet() {
        final Response response = get("repr");
        sysOutEntityIfError(response);
        assertEquals(Status.SUCCESS_OK, response.getStatus());
    }
View Full Code Here

    }

    /** @throws IOException
     *  @see RepresentationTestService#postJaxb(org.restlet.ext.jaxb.JaxbRepresentation) */
    public void testReprPost() throws IOException {
        Response response = post("jaxb", new StringRepresentation("abcdef"));
        assertEquals(Status.CLIENT_ERROR_UNSUPPORTED_MEDIA_TYPE, response
                .getStatus());

        response = post("jaxb", new StringRepresentation(
                "<person firstname=\"Angela\" lastname=\"Merkel\"/>",
                MediaType.APPLICATION_XML));
        sysOutEntityIfError(response);
        assertEquals(Status.SUCCESS_OK, response.getStatus());
        String packageName = Person.class.getPackage().getName();
        assertEquals(packageName, response.getEntity().getText());
    }
View Full Code Here

        assertEquals(packageName, response.getEntity().getText());
    }

    /** @see RepresentationTestService#getString() */
    public void testStringGet() {
        final Response response = get("reprString");
        sysOutEntityIfError(response);
        assertEquals(Status.SUCCESS_OK, response.getStatus());
    }
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

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.