Search in sources :

Example 1 with ByteArrayContainerResponseWriter

use of org.everrest.core.tools.ByteArrayContainerResponseWriter in project che by eclipse.

the class ProjectServiceTest method testGetFileContent.

@Test
public void testGetFileContent() throws Exception {
    String myContent = "to be or not to be";
    pm.getProject("my_project").getBaseFolder().createFile("test.txt", myContent.getBytes(Charset.defaultCharset()));
    ByteArrayContainerResponseWriter writer = new ByteArrayContainerResponseWriter();
    ContainerResponse response = launcher.service(GET, "http://localhost:8080/api/project/file/my_project/test.txt", "http://localhost:8080/api", null, null, writer, null);
    assertEquals(response.getStatus(), 200, "Error: " + response.getEntity());
    assertEquals(response.getContentType().toString(), TEXT_PLAIN);
    assertEquals(new String(writer.getBody()), myContent);
}
Also used : ContainerResponse(org.everrest.core.impl.ContainerResponse) ByteArrayContainerResponseWriter(org.everrest.core.tools.ByteArrayContainerResponseWriter) Test(org.testng.annotations.Test)

Aggregations

ContainerResponse (org.everrest.core.impl.ContainerResponse)1 ByteArrayContainerResponseWriter (org.everrest.core.tools.ByteArrayContainerResponseWriter)1 Test (org.testng.annotations.Test)1