org.springframework.test.web.client.MockMvcClientHttpRequestFactory Java Examples

The following examples show how to use org.springframework.test.web.client.MockMvcClientHttpRequestFactory. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MockMvcClientHttpRequestFactoryTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Test
@SuppressWarnings("deprecation")
public void testAsyncTemplate() throws Exception {
	org.springframework.web.client.AsyncRestTemplate template = new org.springframework.web.client.AsyncRestTemplate(
			new MockMvcClientHttpRequestFactory(this.mockMvc));
	ListenableFuture<ResponseEntity<String>> entity = template.getForEntity("/foo", String.class);
	assertEquals("bar", entity.get().getBody());
}
 
Example #2
Source File: MockMvcClientHttpRequestFactoryTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Test
@SuppressWarnings("deprecation")
public void testAsyncTemplate() throws Exception {
	org.springframework.web.client.AsyncRestTemplate template = new org.springframework.web.client.AsyncRestTemplate(
			new MockMvcClientHttpRequestFactory(this.mockMvc));
	ListenableFuture<ResponseEntity<String>> entity = template.getForEntity("/foo", String.class);
	assertEquals("bar", entity.get().getBody());
}
 
Example #3
Source File: RestTemplateBenchmark.java    From spring-cloud-sleuth with Apache License 2.0 5 votes vote down vote up
@Setup
public void setup() {
	new SpringApplication(SleuthBenchmarkingSpringApp.class).run(
			"--spring.jmx.enabled=false", "--spring.application.name=withSleuth");
	this.mockMvc = MockMvcBuilders
			.standaloneSetup(
					this.withSleuth.getBean(SleuthBenchmarkingSpringApp.class))
			.build();
	this.tracedTemplate = new RestTemplate(
			new MockMvcClientHttpRequestFactory(this.mockMvc));
	this.tracedTemplate.setInterceptors(Collections.singletonList(
			this.withSleuth.getBean(TracingClientHttpRequestInterceptor.class)));
	this.untracedTemplate = new RestTemplate(
			new MockMvcClientHttpRequestFactory(this.mockMvc));
}
 
Example #4
Source File: MockMvcClientHttpRequestFactoryTests.java    From spring-analysis-note with MIT License 4 votes vote down vote up
@Test
public void test() throws Exception {
	RestTemplate template = new RestTemplate(new MockMvcClientHttpRequestFactory(this.mockMvc));
	String result = template.getForObject("/foo", String.class);
	assertEquals("bar", result);
}
 
Example #5
Source File: MockMvcClientHttpRequestFactoryTests.java    From java-technology-stack with MIT License 4 votes vote down vote up
@Test
public void test() throws Exception {
	RestTemplate template = new RestTemplate(new MockMvcClientHttpRequestFactory(this.mockMvc));
	String result = template.getForObject("/foo", String.class);
	assertEquals("bar", result);
}
 
Example #6
Source File: MockMvcClientHttpRequestFactoryTests.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Before
public void setup() {
	MockMvc mockMvc = MockMvcBuilders.webAppContextSetup(this.wac).alwaysExpect(status().isOk()).build();
	this.restTemplate = new RestTemplate(new MockMvcClientHttpRequestFactory(mockMvc));
}