Package org.restlet.data

Examples of org.restlet.data.MediaType


     */
    public void test1() throws Exception {
        final Response response = get();
        sysOutEntityIfError(response);
        assertEquals(Status.SUCCESS_OK, response.getStatus());
        assertEqualMediaType(new MediaType("text/crazy-person"), response);
        final String actualEntity = response.getEntity().getText();
        final String expectedEntity = "abc def is crazy.\nHeader value for name h1 is h1v";
        assertEquals(expectedEntity, actualEntity);
    }
View Full Code Here


    /** @see ProviderTestService#mMapPost(javax.ws.rs.core.MultivaluedMap) */
    public void testMultivaluedMapPost() throws Exception {
        final Response response = post("MultivaluedMap", createForm()
                .getWebRepresentation());
        assertEquals(Status.SUCCESS_OK, response.getStatus());
        final MediaType respMediaType = response.getEntity().getMediaType();
        assertEqualMediaType(MediaType.TEXT_PLAIN, respMediaType);
        final String respEntity = response.getEntity().getText();
        assertEquals("[(lastname,Merkel), (firstname,Angela)]", respEntity);
    }
View Full Code Here

    private void getAndCheck(MediaType mt) {
        final Response response = get(mt);
        sysOutEntityIfError(response);
        assertEquals(Status.SUCCESS_OK, response.getStatus());
        final MediaType mediaType = response.getEntity().getMediaType();
        assertEqualMediaType(mt, mediaType);
    }
View Full Code Here

    public void testGet() throws Exception {
        final Response response = get();
        sysOutEntityIfError(response);
        assertEquals(Status.SUCCESS_OK, response.getStatus());
        final MediaType mediaType = response.getEntity().getMediaType();
        try {
            assertEqualMediaType(MediaType.TEXT_XML, mediaType);
        } catch (AssertionFailedError afe) {
            try {
                assertEqualMediaType(MediaType.APPLICATION_XML, mediaType);
View Full Code Here

    final Response response = get("offers");
    final Representation representation = response.getEntity();
    sysOutEntityIfError(response);
    assertEquals(Status.SUCCESS_OK, response.getStatus());
    assertEquals(CarListResource.OFFERS, representation.getText());
    final MediaType actualMediaType = representation.getMediaType();
    assertEqualMediaType(MediaType.TEXT_PLAIN, actualMediaType);
  }
View Full Code Here

    public void test1() throws IOException {
        final Response response = get();
        final Representation entity = response.getEntity();
        sysOutEntityIfError(response);
        assertEquals(Status.SUCCESS_OK, response.getStatus());
        assertEqualMediaType(new MediaType("application/crazy-person"), entity);
        assertEquals(
                "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><person><firstname>Angela</firstname><lastname>Merkel</lastname></person>Angela Merkel is crazy.\nHeader value for name h1 is h1v",
                entity.getText());
    }
View Full Code Here

        result = addObjectClass(result, InputStream.class);
        result = addObjectClass(result, Reader.class);
        result = addObjectClass(result, ReadableByteChannel.class);

        if (source.getMediaType() != null) {
            MediaType mediaType = source.getMediaType();

            if (MediaType.APPLICATION_JAVA_OBJECT.equals(mediaType)
                    || MediaType.APPLICATION_JAVA_OBJECT_XML.equals(mediaType)) {
                result = addObjectClass(result, Object.class);
            } else if (MediaType.APPLICATION_WWW_FORM.equals(mediaType)) {
View Full Code Here

            case TYPE_LANGUAGE:
                result.setMetadata((T) new Language(metadata.toString()));
                break;

            case TYPE_MEDIA_TYPE:
                result.setMetadata((T) new MediaType(metadata.toString(),
                        mediaParams));
                break;
            }
        }
View Full Code Here

            if (metadata instanceof Language) {
                Language language = (Language) metadata;
                defaultMetadata = language.equals(getMetadataService()
                        .getDefaultLanguage());
            } else if (metadata instanceof MediaType) {
                MediaType mediaType = (MediaType) metadata;
                defaultMetadata = mediaType.equals(getMetadataService()
                        .getDefaultMediaType());
            } else if (metadata instanceof CharacterSet) {
                CharacterSet characterSet = (CharacterSet) metadata;
                defaultMetadata = characterSet.equals(getMetadataService()
                        .getDefaultCharacterSet());
View Full Code Here

                    }
                }

                // If no media type is defined, take the default one
                if (variant.getMediaType() == null) {
                    final MediaType defaultMediaType = metadataService
                            .getDefaultMediaType();

                    if ((defaultMediaType != null)
                            && !defaultMediaType.equals(MediaType.ALL)) {
                        variant.setMediaType(defaultMediaType);
                    }
                }

                // If no encoding is defined, take the default one
View Full Code Here

TOP

Related Classes of org.restlet.data.MediaType

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.