Example usage for org.springframework.http MediaType TEXT_HTML

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

Introduction

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

Prototype

MediaType TEXT_HTML

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

Click Source Link

Document

Public constant media type for text/html .

Usage

From source file:edu.infsci2560.LoginHelper.java

public static ResponseEntity<String> login(TestRestTemplate template, String route, String userName,
        String password) {/*  w w  w .j  a v  a2s  .  c o  m*/
    HttpHeaders headers = getHeaders(template, route);
    headers.setAccept(Arrays.asList(MediaType.TEXT_HTML));
    headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
    MultiValueMap<String, String> form = new LinkedMultiValueMap<String, String>();
    form.set("username", userName);
    form.set("password", password);
    ResponseEntity<String> entity = template.exchange(route, HttpMethod.POST,
            new HttpEntity<MultiValueMap<String, String>>(form, headers), String.class);
    return entity;

}

From source file:nl.flotsam.greader.http.GsonHttpMessageConverter.java

@Override
public List<MediaType> getSupportedMediaTypes() {
    return Arrays.asList(MediaType.APPLICATION_JSON, MediaType.TEXT_HTML);
}

From source file:io.bosh.client.errands.ErrandsTest.java

@Test
public void list() {
    // Given/*from  ww  w.j av  a  2s.c om*/
    mockServer.expect(requestTo(url("/deployments/test/errands")))//
            .andRespond(withSuccess(payload("errands/errands.json"), MediaType.TEXT_HTML));
    // When
    errands.list("test").subscribe(summaries -> {
        // Then
        assertThat(summaries.size(), is(3));

        assertThat(summaries.get(0).getName(), is("broker-registrar"));
        assertThat(summaries.get(1).getName(), is("broker-deregistrar"));
        assertThat(summaries.get(2).getName(), is("smoke-tests"));
    });
}

From source file:cn.edu.zjnu.acm.judge.config.JudgeWebMvcConfiguration.java

@Override
public void configureContentNegotiation(ContentNegotiationConfigurer configurer) {
    configurer.defaultContentType(MediaType.TEXT_HTML);
}

From source file:com.fabionoth.rest.RobotRest.java

/**
 *
 * @param command/*from   w w  w . j  a  va 2s  .c  om*/
 * @return
 */
@RequestMapping(value = { "rest/mars/", "/rest/mars/{command}" }, method = { RequestMethod.GET,
        RequestMethod.POST })
public ResponseEntity<String> sendCommand(@PathVariable Optional<String> command) {
    Robot robot;
    robot = new Robot(new Long(1), 0, 0, CardinalPoints.N);

    HttpHeaders responseHeaders = new HttpHeaders();
    responseHeaders.setContentType(MediaType.TEXT_HTML);

    if (command.isPresent()) {
        try {
            robot = new RobotController(robot, command.get()).getRobot();
        } catch (Exception ex) {
            Logger.getLogger(RobotRest.class.getName()).log(Level.SEVERE, null, ex);
            return new ResponseEntity<>("Erro", responseHeaders, HttpStatus.BAD_REQUEST);
        }
    }

    String response = "(" + robot.getX() + ", " + robot.getY() + ", " + robot.getC().toString() + ")";
    return new ResponseEntity<>(response, responseHeaders, HttpStatus.OK);

}

From source file:us.putney.controllers.SampleServiceControllerTest.java

/**
 * Test of home method, of class SampleServiceController.
 *///from   w w  w.  j a v  a 2  s. com
@Test
public void testHome() throws Exception {
    mockMvc.perform(get("/").accept(MediaType.TEXT_HTML)).andDo(MockMvcResultHandlers.print())
            .andExpect(MockMvcResultMatchers.view().name("index.html"));
}

From source file:fi.helsinki.opintoni.integration.pagemetadata.SpringPageMetaDataHttpClient.java

@Override
public Optional<String> getPageBody(String pageUrl) {
    Optional<String> pageBody = Optional.empty();
    try {//from  w ww  .  j av a 2s  . c om
        HttpHeaders headers = new HttpHeaders();
        headers.setAccept(Lists.newArrayList(MediaType.TEXT_HTML));
        headers.add(USER_AGENT_KEY, USER_AGENT);
        HttpEntity<String> entity = new HttpEntity<>(PARAMETERS_KEY, headers);

        ResponseEntity<String> response = metaDataRestTemplate.exchange(pageUrl, HttpMethod.GET, entity,
                String.class);
        if (response.getStatusCode().equals(HttpStatus.OK)) {
            pageBody = Optional.ofNullable(response.getBody());
        }
    } catch (Exception e) {
    }

    return pageBody;

}

From source file:com.alcatel.hello.actuator.ui.SampleActuatorUIApplicationTests.java

@Test
public void testHome() throws Exception {
    HttpHeaders headers = new HttpHeaders();
    headers.setAccept(Arrays.asList(MediaType.TEXT_HTML));
    ResponseEntity<String> entity = new TestRestTemplate().exchange("http://localhost:" + this.port,
            HttpMethod.GET, new HttpEntity<Void>(headers), String.class);

    assertEquals(HttpStatus.OK, entity.getStatusCode());
    assertTrue("Wrong body (title doesn't match):\n" + entity.getBody(),
            entity.getBody().contains("<title>Hello"));
}

From source file:us.putney.controllers.SampleServiceControllerTest.java

/**
 * Test of home method, of class SampleServiceController.
 *///from   w  w w.  j a  v  a2s  . c o m
@Test
public void testIndexHtml() throws Exception {
    mockMvc.perform(get("/index.html").accept(MediaType.TEXT_HTML)).andDo(print())
            .andExpect(content().string(containsString("ng-app=\"sampleModule\"")));
}