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:io.pivotal.cla.webdriver.ActuatorSecurityTests.java
@Test @WithClaAuthorUser// ww w . ja v a 2 s.c o m public void actuatorAllowsClaAuthorUser() throws Exception { mockMvc.perform(get("/manage/beans").accept(MediaType.APPLICATION_JSON)).andExpect(status().isOk()); }
From source file:io.github.howiefh.jeews.modules.sys.controller.SignupControllerTest.java
@Test public void testLogin() throws Exception { String requestBody = "{\"username\":\"fh" + UUID.randomUUID() + "\",\"password\":\"123456\",\"email\":\"" + UUID.randomUUID() + "@qq.om\"}"; mockMvc.perform(post("/signup").contentType(MediaType.APPLICATION_JSON).content(requestBody) .accept(MediaTypes.HAL_JSON)) // .andExpect(status().isCreated()) // 201 .andExpect(jsonPath("$.msg").exists()) // Json path?JSON .andExpect(content().contentType(MediaTypes.HAL_JSON)).andReturn(); }
From source file:net.kaczmarzyk.LikeE2eTest.java
@Test public void filtersByFirstName() throws Exception { mockMvc.perform(get("/customers").param("lastName", "im").accept(MediaType.APPLICATION_JSON)) .andExpect(jsonPath("$").isArray()).andExpect(jsonPath("$[?(@.firstName=='Homer')]").exists()) .andExpect(jsonPath("$[?(@.firstName=='Marge')]").exists()) .andExpect(jsonPath("$[?(@.firstName=='Bart')]").exists()) .andExpect(jsonPath("$[?(@.firstName=='Lisa')]").exists()) .andExpect(jsonPath("$[?(@.firstName=='Maggie')]").exists()) .andExpect(jsonPath("$[5]").doesNotExist()); }
From source file:com.webfileanalyzer.testcontroller.IndexControllerTest.java
@Ignore @Test// w w w . j a v a 2 s.co m public void getFileStatTestResp200() throws Exception { this.mockMvc.perform( get("/getFileStat/149").param("from", "0").param("qty", "100").accept(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()); }
From source file:spring.travel.site.AppConfigurer.java
@Override public void configureContentNegotiation(ContentNegotiationConfigurer configurer) { configurer.favorPathExtension(false).useJaf(false).defaultContentType(MediaType.TEXT_HTML).mediaType("json", MediaType.APPLICATION_JSON); }
From source file:gt.dakaik.config.WebContext.java
@Override public void configureContentNegotiation(ContentNegotiationConfigurer configurer) { configurer.favorPathExtension(false).favorParameter(false).ignoreAcceptHeader(false).useJaf(false) .defaultContentType(MediaType.APPLICATION_JSON).mediaType("xml", MediaType.APPLICATION_XML) .mediaType("json", MediaType.APPLICATION_JSON); }
From source file:org.zalando.github.spring.UsersTemplatePublicKeyTest.java
@Test public void getPublicKeys() throws Exception { mockServer.expect(requestTo("https://api.github.com/user/keys")).andExpect(method(HttpMethod.GET)) // .andExpect(header("Authorization", "Bearer ACCESS_TOKEN")) .andRespond(withSuccess(new ClassPathResource("listPublicKeys.json", getClass()), MediaType.APPLICATION_JSON)); List<ExtPubKey> publicKeyList = usersTemplate.listPublicKeys(); Assertions.assertThat(publicKeyList).isNotNull(); Assertions.assertThat(publicKeyList.size()).isEqualTo(1); Assertions.assertThat(publicKeyList.get(0).getKey()).isEqualTo("ssh-rsa AAA..."); }
From source file:com.salmon.security.xacml.demo.springmvc.services.RestQueryUnitTest.java
@Test public void getOneDriver() throws Exception { when(marketPlaceController.getDriverDetails(driver)).thenReturn(DriverFixtures.standardDriver()); this.mockMvc.perform(get("/aggregators/dvla/drivers/{license}", driver).accept(MediaType.APPLICATION_JSON)) //.andDo(print()) .andExpect(status().isOk()); }
From source file:org.makersoft.mvc.unit.FormatHandlerMethodReturnValueHandlerTests.java
@Test public void testExcludes() throws Exception { HttpHeaders httpHeaders = new HttpHeaders(); httpHeaders.setContentType(MediaType.APPLICATION_JSON); mockMvc.perform(get("/account/user/excludes/1").accept(MediaType.APPLICATION_JSON).headers(httpHeaders)) .andDo(print()).andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON)).andExpect(content().encoding("UTF-8")) .andExpect(jsonPath("$.id").value(1)).andExpect(jsonPath("$.password").doesNotExist()) .andExpect(jsonPath("$.dept").doesNotExist()).andExpect(jsonPath("$.roles").doesNotExist()); }
From source file:io.pivotal.springtrader.accounts.config.WebConfig.java
/** * configure the message converters with the date formatter. *///from www . j a v a 2 s. c o m @Override public void configureMessageConverters(List<HttpMessageConverter<?>> converters) { MappingJackson2HttpMessageConverter mappingJacksonHttpMessageConverter = new MappingJackson2HttpMessageConverter(); mappingJacksonHttpMessageConverter.setSupportedMediaTypes(Arrays.asList(MediaType.APPLICATION_JSON)); SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:SS"); mappingJacksonHttpMessageConverter.getObjectMapper().setDateFormat(format); converters.add(mappingJacksonHttpMessageConverter); }