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.dynatrace.cf.servicebroker.provisioning.ProvisioningControllerTest.java

@Test
public void create() throws Exception {
    this.mockMvc/*  w  w w.j a v  a2  s .c o m*/
            .perform(put("/v2/service_instances/0").content(payload()).contentType(MediaType.APPLICATION_JSON))
            .andExpect(status().isOk()).andExpect(jsonPath("$").exists());
}

From source file:net.gbmb.collector.rest.HttpRecordMessageConverter.java

@Override
public boolean canRead(Class<?> aClass, MediaType mediaType) {
    if (aClass.equals(CollectionRecord.class)) {
        return MediaType.APPLICATION_JSON.includes(mediaType);
    } else {/*ww  w.j a  va 2 s.  co m*/
        return false;
    }
}

From source file:org.cloudfoundry.identity.uaa.integration.PasswordCheckEndpointIntegrationTests.java

@Test
public void passwordPostSucceeds() throws Exception {
    MultiValueMap<String, String> formData = new LinkedMultiValueMap<String, String>();
    formData.add("password", "password1");
    HttpHeaders headers = new HttpHeaders();
    headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON));
    @SuppressWarnings("rawtypes")
    ResponseEntity<Map> response = serverRunning.postForMap("/password/score", formData, headers);
    assertEquals(HttpStatus.OK, response.getStatusCode());

    assertTrue(response.getBody().containsKey("score"));
    assertTrue(response.getBody().containsKey("requiredScore"));
    assertEquals(0, response.getBody().get("score"));
}

From source file:io.pivotal.cla.webdriver.ActuatorSecurityTests.java

@Test
@WithSigningUser//w w w  .j  a  va 2  s.  com
public void actuatorDeniesSigningUser() throws Exception {
    mockMvc.perform(get("/manage/beans").accept(MediaType.APPLICATION_JSON))
            .andExpect(status().is4xxClientError());
}

From source file:com.hillert.botanic.controller.AuthenticationControllerTests.java

@Test
public void testAuthenticateSuccessfully() throws Exception {
    mockMvc.perform(//from   w w  w  .j a  va2  s.com
            post("/authenticate").content("{ \"username\": \"admin\", \"password\": \"admin\" }".getBytes())
                    .contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON))
            .andExpect(status().isOk()).andExpect(jsonPath("$.username", Matchers.is("admin")))
            .andExpect(jsonPath("$.roles['ROLE_USER']", Matchers.is(true)))
            .andExpect(jsonPath("$.roles['ROLE_ADMIN']", Matchers.is(true)))
            .andExpect(jsonPath("$.token", Matchers.not(Matchers.isEmptyOrNullString())));
}

From source file:net.orpiske.tcs.service.rest.functional.DomainCreateTest.java

private HttpHeaders getHeaders(String auth) {
    HttpHeaders headers = new HttpHeaders();
    headers.setContentType(MediaType.APPLICATION_JSON);
    headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON));

    byte[] encodedAuthorisation = Base64.encodeBase64(auth.getBytes());
    headers.add("Authorization", "Basic " + new String(encodedAuthorisation));

    return headers;
}

From source file:web.rufer.swisscom.sms.api.factory.HeaderFactoryTest.java

@Test
public void createHeadersReturnsHeadersWithContentTypeApplicationJson() {
    HttpHeaders headers = HeaderFactory.createHeaders(API_KEY);
    assertEquals(MediaType.APPLICATION_JSON, headers.getContentType());
}

From source file:com.example.hello.HelloEndpoint.java

Mono<ServerResponse> hello(final ServerRequest serverRequest) {
    return ServerResponse.ok().contentType(MediaType.APPLICATION_JSON)
            .body(Mono.just(new HelloMessage("hello", OffsetDateTime.now(ZoneId.of("Z")))), HelloMessage.class);
}

From source file:com.dynatrace.cf.servicebroker.binding.BindingControllerTest.java

@Test
public void create() throws Exception {
    this.mockMvc//from w ww .j ava 2  s. co m
            .perform(put("/v2/service_instances/0/service_bindings/1").content(payload())
                    .contentType(MediaType.APPLICATION_JSON))
            .andExpect(status().isOk()).andExpect(jsonPath("$.credentials.environmentid").exists());
}

From source file:com.dbsvg.controllers.JsonView.java

public ModelAndView Render(Object model, HttpServletResponse response) {

    MediaType jsonMimeType = MediaType.APPLICATION_JSON;

    try {/*from  w  w  w. j  a  v a  2  s  .  co m*/
        jsonConverter.write(model, jsonMimeType, new ServletServerHttpResponse(response));
    } catch (HttpMessageNotWritableException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }

    return null;
}