Example usage for org.springframework.http MediaType APPLICATION_JSON

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

Introduction

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

Prototype

MediaType APPLICATION_JSON

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

Click Source Link

Document

Public constant media type for application/json .

Usage

From source file:com.hatta.consumer.App.java

private static HttpHeaders getHeaders() {
    HttpHeaders headers = new HttpHeaders();
    headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON));
    return headers;
}

From source file:io.curly.tagger.TagHelper.java

public static MediaType jsonMediaType() {
    return new MediaType(MediaType.APPLICATION_JSON.getType(), MediaType.APPLICATION_JSON.getSubtype());
}

From source file:com.boundlessgeo.geoserver.api.converters.JSONMessageConverter.java

public JSONMessageConverter() {
    super(MediaType.APPLICATION_JSON);
}

From source file:com.coinblesk.server.utilTest.RESTUtils.java

public static <T> T postRequest(MockMvc mockMvc, String url, String requestJSON, Class<T> responseClass)
        throws Exception {
    final MvcResult res = mockMvc
            .perform(post(url).secure(true).contentType(MediaType.APPLICATION_JSON).content(requestJSON))
            .andExpect(status().isOk()).andReturn();
    final String responseJson = res.getResponse().getContentAsString();
    final T responseTO = SerializeUtils.GSON.fromJson(responseJson, responseClass);
    return responseTO;
}

From source file:StatsControllerTest.java

@Test
public void getQuestsTest() throws Exception {
    String uri = "/stats/id/1";
    MvcResult result = mvc.perform(MockMvcRequestBuilders.get(uri).accept(MediaType.APPLICATION_JSON))
            .andReturn();/*  w ww . jav  a  2  s  . com*/

    String content = result.getResponse().getContentAsString();
    int status = result.getResponse().getStatus();

    Assert.assertEquals("failure - expected HTTP status 200", 200, status);
    Assert.assertTrue("failure - expected HTTP response body to have a value", content.trim().length() > 0);

}

From source file:com.bugbusters.lajarus.controller.ItemControllerTest.java

@Test
public void getItemByIdTest() throws Exception {
    String uri = "/item/all";
    MvcResult result = mvc.perform(MockMvcRequestBuilders.get(uri).accept(MediaType.APPLICATION_JSON))
            .andReturn();// w ww . j  av a  2  s . co  m

    String content = result.getResponse().getContentAsString();
    int status = result.getResponse().getStatus();

    Assert.assertEquals("failure - expected HTTP status 200", 200, status);
    Assert.assertTrue("failure - expected HTTP response body to have a value", content.trim().length() > 0);

}

From source file:com.bugbusters.lajarus.controller.QuestControllerTest.java

@Test
public void getQuestsTest() throws Exception {
    String uri = "/quest/all";
    MvcResult result = mvc.perform(MockMvcRequestBuilders.get(uri).accept(MediaType.APPLICATION_JSON))
            .andReturn();//from   ww  w .ja v a  2  s  . c om

    String content = result.getResponse().getContentAsString();
    int status = result.getResponse().getStatus();

    Assert.assertEquals("failure - expected HTTP status 200", 200, status);
    Assert.assertTrue("failure - expected HTTP response body to have a value", content.trim().length() > 0);

}

From source file:io.github.autsia.crowly.tests.IntegrationTestingUtils.java

public MediaType getContentType() {
    return new MediaType(MediaType.APPLICATION_JSON.getType(), MediaType.APPLICATION_JSON.getSubtype(),
            Charset.forName("utf8"));
}

From source file:rugal.sample.controller.StudentActionClientSideTest.java

@Test
//    @Ignore/*from ww  w  .  j  a  v  a2s  .co m*/
public void test() throws Exception {
    this.mockMvc
            .perform(get("/student/1").contentType(MediaType.APPLICATION_JSON)
                    .accept(MediaType.parseMediaType("application/json;charset=UTF-8")))
            .andExpect(status().isOk());
    System.out.println("Rugal Bernstein");
}

From source file:de.codecentric.boot.admin.services.ApplicationRegistrator.java

private static HttpHeaders createHttpHeaders() {
    HttpHeaders headers = new HttpHeaders();
    headers.setContentType(MediaType.APPLICATION_JSON);
    headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON));
    return HttpHeaders.readOnlyHttpHeaders(headers);
}