Package org.restlet.representation

Examples of org.restlet.representation.Representation


  public void testGetCar() throws Exception {
    final String carNumber = "57";

    final Response response = get(carNumber);
    final Representation entity = response.getEntity();
    sysOutEntityIfError(response);
    assertEquals(Status.SUCCESS_OK, response.getStatus());
    assertEquals(CarResource.createTextRepr(carNumber), entity.getText());
    assertEqualMediaType(MediaType.TEXT_PLAIN, entity.getMediaType());
  }
View Full Code Here


    assertEquals(Status.CLIENT_ERROR_NOT_ACCEPTABLE, response.getStatus());
  }

  public void testGetOffers() throws Exception {
    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 testGetPlainText() throws Exception {
    final Response response = get(MediaType.TEXT_PLAIN);
    final Status status = response.getStatus();
    assertTrue("Status should be 2xx, but is " + status, status.isSuccess());
    final Representation representation = response.getEntity();
    assertEquals(CarListResource.DUMMY_CAR_LIST, representation.getText());
    assertEqualMediaType(MediaType.TEXT_PLAIN,
        representation.getMediaType());
  }
View Full Code Here

    /**
     * @see Issue971Resource#getIssue971()
     */
    public void testGet() throws Exception {
        final Response response = get("971");
        final Representation entity = response.getEntity();
        sysOutEntityIfError(response);
        assertEquals(Status.SUCCESS_OK, response.getStatus());
        assertEqualMediaType(MediaType.TEXT_PLAIN, entity.getMediaType());
        assertEquals("issue 971 description", entity.getText());
    }
View Full Code Here

    }

    @Override
    public Representation toRepresentation(Object source, Variant target,
            UniformResource resource) {
        Representation result = null;

        if (source instanceof JacksonRepresentation) {
            result = (JacksonRepresentation<?>) source;
        } else {
            if (target.getMediaType() == null) {
View Full Code Here

     * @param source
     *            The source XML representation.
     * @return The generated result representation.
     */
    public Representation transform(Representation source) {
        final Representation result = new TransformRepresentation(getContext(),
                source, getTransformSheet());

        if (this.resultLanguages != null) {
            result.getLanguages().addAll(getResultLanguages());
        }

        result.setCharacterSet(getResultCharacterSet());
        if (this.resultEncodings != null) {
            result.getEncodings().addAll(getResultEncodings());
        }

        result.setMediaType(getResultMediaType());
        return result;
    }
View Full Code Here

        assertEquals(Status.SUCCESS_OK, responseGett.getStatus());
        if (responseHead.getStatus().isError()) {
            System.out.println(responseHead.getEntity().getText());
        }
        assertEquals(Status.SUCCESS_OK, responseHead.getStatus());
        final Representation entityGett = responseGett.getEntity();
        final Representation entityHead = responseHead.getEntity();
        assertNotNull(entityGett);
        assertNotNull("Must not be null to read the entity headers", entityHead);
        assertEqualMediaType(MediaType.TEXT_HTML, entityGett.getMediaType());
        assertEqualMediaType(MediaType.TEXT_HTML, entityHead.getMediaType());
        assertEquals("4711", entityGett.getText());
        assertEquals("The entity text of the head request must be null", null,
                entityHead.getText());
    }
View Full Code Here

        assertEquals(Status.SUCCESS_OK, responseGett.getStatus());
        if (responseHead.getStatus().isError()) {
            System.out.println(responseHead.getEntity().getText());
        }
        assertEquals(Status.SUCCESS_OK, responseHead.getStatus());
        final Representation entityGett = responseGett.getEntity();
        final Representation entityHead = responseHead.getEntity();
        assertNotNull(entityGett);
        assertNotNull("Must not be null to read the entity headers", entityHead);
        assertEqualMediaType(MediaType.TEXT_HTML, entityGett.getMediaType());
        assertEqualMediaType(MediaType.TEXT_HTML, entityHead.getMediaType());
        assertEquals("4711", entityGett.getText());
        assertEquals("The entity text of the head request must be null", null,
                entityHead.getText());
    }
View Full Code Here

        assertEquals(Status.SUCCESS_OK, responseGett.getStatus());
        if (responseHead.getStatus().isError()) {
            System.out.println(responseHead.getEntity().getText());
        }
        assertEquals(Status.SUCCESS_OK, responseHead.getStatus());
        final Representation entityGett = responseGett.getEntity();
        final Representation entityHead = responseHead.getEntity();
        assertNotNull(entityGett);
        assertNotNull("Must not be null to read the entity headers", entityHead);
        assertEqualMediaType(MediaType.TEXT_PLAIN, entityGett.getMediaType());
        assertEqualMediaType(MediaType.TEXT_PLAIN, entityHead.getMediaType());
        assertEquals("4711", entityGett.getText());
        assertEquals("The entity text of the head request must be null", null,
                entityHead.getText());
    }
View Full Code Here

    }

    public void testGetNull() throws Exception {
        final Response response = get("null");
        assertEquals(Status.SUCCESS_NO_CONTENT, response.getStatus());
        final Representation entity = response.getEntity();
        if (entity != null) {
            assertEquals(null, entity.getText());
        }
    }
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.