List of usage examples for org.springframework.http MediaType APPLICATION_JSON
MediaType APPLICATION_JSON
To view the source code for org.springframework.http MediaType APPLICATION_JSON.
Click Source Link
From source file:org.craftercms.commons.jackson.mvc.GDataPropertyFilterTest.java
@Test public void testSimpleSelector() throws Exception { this.mockMvc.perform(get(FilterTestController.SELECTOR + "?selector=Person(name)") //Url .contentType(MediaType.APPLICATION_JSON)) // .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON_VALUE)) // Check that is JSON .andExpect(jsonPath("$.name").exists()).andExpect(jsonPath("$.birthday").doesNotExist()) .andExpect(jsonPath("$" + ".id").doesNotExist()); }
From source file:net.orpiske.tcs.client.services.TagCloudServiceClient.java
private HttpHeaders getHeaders() { String user = System.getenv("TCS_USER"); String password = System.getenv("TCS_PASSWORD"); if (user == null || user.isEmpty()) { logger.fatal("The backend system username is not provided (please set " + "the TCS_USER environment variable)"); throw new InvalidCredentialsException("The backend system username is not provided"); }/*from ww w . jav a 2s . co m*/ if (password == null || password.isEmpty()) { logger.fatal("The backend system password is not provided (please set " + "the TCS_PASSWORD environment variable)"); throw new InvalidCredentialsException("The backend system password is not provided"); } String auth = user + ":" + password; HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.APPLICATION_JSON); headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON)); byte[] encodedAuth = Base64.encodeBase64(auth.getBytes()); headers.add("Authorization", "Basic " + new String(encodedAuth)); return headers; }
From source file:org.craftercms.commerce.client.AbstractRestCRUDService.java
public AbstractRestCRUDService(String crafterCommerceServerUrl) { this.crafterCommerceServerUrl = crafterCommerceServerUrl; restTemplate = new RestTemplate(); httpHeaders = new HttpHeaders(); httpHeaders.setContentType(MediaType.APPLICATION_JSON); }
From source file:org.openbaton.autoscaling.api.exceptions.GlobalExceptionHandler.java
@ExceptionHandler({ BadFormatException.class, NetworkServiceIntegrityException.class, WrongStatusException.class }) @ResponseStatus(value = HttpStatus.BAD_REQUEST) protected ResponseEntity<Object> handleInvalidRequest(Exception e, WebRequest request) { log.error("Exception with message " + e.getMessage() + " was thrown"); ExceptionResource exc = new ExceptionResource("Bad Request", e.getMessage()); HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.APPLICATION_JSON); return handleExceptionInternal(e, exc, headers, HttpStatus.UNPROCESSABLE_ENTITY, request); }
From source file:com.expedia.seiso.SeisoWebConfigBeansV1.java
@Bean public MappingJackson2HttpMessageConverter origMappingJackson2HttpMessageConverter() { val converter = new MappingJackson2HttpMessageConverter(origMapper()); converter.setSupportedMediaTypes(Arrays.asList(MediaType.APPLICATION_JSON)); return converter; }
From source file:org.openbaton.vnfm.api.exceptions.GlobalExceptionHandler.java
@ExceptionHandler({ BadFormatException.class, NetworkServiceIntegrityException.class, WrongStatusException.class }) @ResponseStatus(value = HttpStatus.BAD_REQUEST) protected ResponseEntity<Object> handleInvalidRequest(Exception e, WebRequest request) { log.error("Exception with message " + e.getMessage() + " was thrown"); ExceptionResource exc = new ExceptionResource("Bad Request", e.getMessage()); HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.APPLICATION_JSON); return handleExceptionInternal(e, exc, headers, HttpStatus.BAD_REQUEST, request); }
From source file:fi.helsinki.opintoni.server.CoursePageServer.java
public void expectStudentCourseImplementationEventsRequest(String courseImplementationId) { server.expect(requestTo(eventsUrl(courseImplementationId))).andExpect(method(HttpMethod.GET)).andRespond( withSuccess(SampleDataFiles.toText("coursepage/studentevents.json"), MediaType.APPLICATION_JSON)); }
From source file:org.openlmis.fulfillment.web.BaseController.java
ResponseEntity<String> getAuditLogResponse(Map<UUID, Class> pairs, String author, String changedPropertyName, Pageable page) {//from w ww. j a v a 2 s . c om String auditLogs = getAuditLog(pairs, author, changedPropertyName, page); HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.APPLICATION_JSON); return new ResponseEntity<>(auditLogs, headers, HttpStatus.OK); }
From source file:org.apereo.openlrs.controllers.AboutControllerIntegrationTest.java
@Test public void thatAboutWithNoVersionHeaderReturns400() throws Exception { this.mockMvc.perform(get("/xAPI/about").accept(MediaType.APPLICATION_JSON)).andDo(print()) .andExpect(status().isBadRequest()); }
From source file:org.zalando.github.spring.UsersTemplate.java
@Override public void deleteEmails(List<String> emails) { RequestEntity<List<String>> reqEntity = RequestEntity.method(HttpMethod.DELETE, buildUri(USER_EMAILS_PATH)) .contentType(MediaType.APPLICATION_JSON).body(emails); getRestOperations().exchange(reqEntity, Void.class); }