Example usage for org.springframework.http MediaType TEXT_PLAIN

List of usage examples for org.springframework.http MediaType TEXT_PLAIN

Introduction

In this page you can find the example usage for org.springframework.http MediaType TEXT_PLAIN.

Prototype

MediaType TEXT_PLAIN

To view the source code for org.springframework.http MediaType TEXT_PLAIN.

Click Source Link

Document

Public constant media type for text/plain .

Usage

From source file:de.fau.amos4.test.integration.EmployeeTest.java

@Test
@WithUserDetails("datev@example.com")
public void testEmployeeAsLodasFileDownload() throws Exception {
    final MockHttpServletResponse response = mockMvc.perform(get("/employee/download/text").param("id", "2"))
            .andExpect(status().isOk()).andExpect(content().contentType(MediaType.TEXT_PLAIN)).andReturn()
            .getResponse();//from   ww w .  j  a v a 2 s.  co  m

    final String contentDisp = response.getHeader("Content-Disposition");
    Assert.assertNotNull("Content-Disposition is null", contentDisp);
    Assert.assertTrue("Content-Disposition .", contentDisp.contains("attachment;filename"));
}

From source file:org.zalando.riptide.RedirectTest.java

@Test
public void shouldFollowRedirect() {
    final URI originalUrl = URI.create("https://api.example.com/accounts/123");
    final URI redirectUrl = URI.create("https://api.example.org/accounts/123");

    server.expect(requestTo(originalUrl))
            .andRespond(withStatus(HttpStatus.MOVED_PERMANENTLY).location(redirectUrl));

    server.expect(requestTo(redirectUrl))
            .andRespond(withSuccess().contentType(MediaType.TEXT_PLAIN).body("123"));

    assertThat(send(originalUrl), is("123"));
}

From source file:org.awesomeagile.integrations.hackpad.RestTemplateHackpadClient.java

@Override
public PadIdentity createHackpad(String title) {
    HttpHeaders headers = new HttpHeaders();
    headers.setContentType(MediaType.TEXT_PLAIN);
    HttpEntity<String> entity = new HttpEntity<>(title, headers);
    return restTemplate.postForObject(fullUrl(CREATE_URL), entity, PadIdentity.class);
}

From source file:com.wisemapping.test.rest.RestAdminITCase.java

@Test(dataProviderClass = RestHelper.class, dataProvider = "ContentType-Provider-Function")
public void changePassword(final @NotNull MediaType mediaType) { // Configure media types ...
    final HttpHeaders requestHeaders = createHeaders(mediaType);
    final RestTemplate templateRest = createTemplate(authorisation);

    // Fill user data ...
    final RestUser restUser = createDummyUser();

    // User has been created ...
    final URI location = createUser(requestHeaders, templateRest, restUser);

    // Check that the user has been created ...
    ResponseEntity<RestUser> result = findUser(requestHeaders, templateRest, location);

    // Change password ...
    requestHeaders.setContentType(MediaType.TEXT_PLAIN);
    HttpEntity<String> createUserEntity = new HttpEntity<String>("some-new-password", requestHeaders);
    templateRest.put(BASE_REST_URL + "/admin/users/{id}/password", createUserEntity, result.getBody().getId());
}

From source file:org.zalando.logbook.servlet.WritingTest.java

@Test
public void shouldLogRequest() throws Exception {
    mvc.perform(get("/api/sync").accept(MediaType.APPLICATION_JSON).header("Host", "localhost")
            .contentType(MediaType.TEXT_PLAIN).content("Hello, world!"));

    @SuppressWarnings("unchecked")
    final ArgumentCaptor<Precorrelation<String>> captor = ArgumentCaptor.forClass(Precorrelation.class);
    verify(writer).writeRequest(captor.capture());
    final Precorrelation<String> precorrelation = captor.getValue();

    assertThat(precorrelation.getRequest(), startsWith("Request:"));
    assertThat(precorrelation.getRequest(),
            endsWith("GET http://localhost/api/sync HTTP/1.1\n" + "Accept: application/json\n"
                    + "Host: localhost\n" + "Content-Type: text/plain\n" + "\n" + "Hello, world!"));
}

From source file:ru.tsystems.project.HomeControllerTest.java

@Test
public void testEmployeeMain() throws Exception {
    mockMvc.perform(get("/employee_main").accept(MediaType.TEXT_PLAIN)).andExpect(status().isOk());
}

From source file:mars.RobotControllerTests.java

@Test
public void testMoveWithLeftRotation() throws Exception {
    this.mockMvc.perform(post("/rest/mars/MML")).andExpect(status().isOk())
            .andExpect(content().contentTypeCompatibleWith(MediaType.TEXT_PLAIN))
            .andExpect(content().string("(0, 2, W)\n"));
}

From source file:rugal.sample.springmvc.controller.StudentControllerIntegrationTest.java

@Test
public void get_200() throws Exception {
    LOG.debug("get_200");
    studentService.getDAO().save(bean);//from  ww  w  .  ja v  a2  s.co  m
    this.mockMvc.perform(get("/student/" + bean.getId()).header(SystemDefaultProperties.ID, "rugal")
            .header(SystemDefaultProperties.CREDENTIAL, "123").contentType(MediaType.TEXT_PLAIN)
            .accept(MediaType.APPLICATION_JSON)).andDo(print()).andExpect(status().isOk());
    studentService.getDAO().delete(bean);
}

From source file:org.zalando.logbook.servlet.TeeTest.java

@Test
public void shouldSupportReadSingleByte() throws Exception {
    mvc.perform(get("/api/read-byte").contentType(MediaType.TEXT_PLAIN).content(new byte[] { 17 }))
            .andExpect(status().isOk()).andExpect(content().bytes(new byte[] { 17 }));
}