本文整理匯總了Java中org.springframework.test.web.client.MockRestServiceServer.createServer方法的典型用法代碼示例。如果您正苦於以下問題:Java MockRestServiceServer.createServer方法的具體用法?Java MockRestServiceServer.createServer怎麽用?Java MockRestServiceServer.createServer使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.springframework.test.web.client.MockRestServiceServer
的用法示例。
在下文中一共展示了MockRestServiceServer.createServer方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: setup
import org.springframework.test.web.client.MockRestServiceServer; //導入方法依賴的package包/類
@Before
public void setup() {
List<Person> composers = Arrays.asList(
new Person("Johann Sebastian Bach").setSomeDouble(21),
new Person("Johannes Brahms").setSomeDouble(.0025),
new Person("Edvard Grieg").setSomeDouble(1.6035),
new Person("Robert Schumann").setSomeDouble(Double.NaN));
List<Person> performers = Arrays.asList(
new Person("Vladimir Ashkenazy").setSomeBoolean(false),
new Person("Yehudi Menuhin").setSomeBoolean(true));
this.people = new PeopleWrapper(composers, performers);
List<HttpMessageConverter<?>> converters = new ArrayList<HttpMessageConverter<?>>();
converters.add(new Jaxb2RootElementHttpMessageConverter());
this.restTemplate = new RestTemplate();
this.restTemplate.setMessageConverters(converters);
this.mockServer = MockRestServiceServer.createServer(this.restTemplate);
}
示例2: routeError
import org.springframework.test.web.client.MockRestServiceServer; //導入方法依賴的package包/類
@Test
public void routeError() {
MockRestServiceServer mockServer = MockRestServiceServer.createServer(restTemplate);
String uri =
"http://maps/osrm/route/v1/driving/8.6916010000,53.0929840000;8.7335420000,53.0828570000?overview=false&alternatives=false&steps=true";
mockServer.expect(requestTo(uri))
.andExpect(method(HttpMethod.GET))
.andRespond(withStatus(HttpStatus.BAD_REQUEST).body(OsrmResponseProvider.osrm5ErrorResponse()));
GeoLocation start = new GeoLocation(new BigDecimal("53.092984"), new BigDecimal("8.691601"));
GeoLocation end = new GeoLocation(new BigDecimal("53.082857"), new BigDecimal("8.733542"));
RoutingQueryResult result = sut.route(start, end);
assertThat(result.noRoute(), is(true));
}
示例3: clientConfigured
import org.springframework.test.web.client.MockRestServiceServer; //導入方法依賴的package包/類
@Test
public void clientConfigured() throws Exception {
this.context = new SpringApplicationBuilder(ClientConfiguration.class)
.properties("spring.config.name=test", "server.port=0",
"security.oauth2.resource.userInfoUri:http://example.com",
"security.oauth2.client.clientId=foo")
.run();
RequestContextHolder.setRequestAttributes(
new ServletRequestAttributes(new MockHttpServletRequest()));
OAuth2ClientContext client = this.context.getBean(OAuth2ClientContext.class);
assertNull(client.getAccessToken());
UserInfoTokenServices services = context.getBean(UserInfoTokenServices.class);
OAuth2RestTemplate template = (OAuth2RestTemplate) ReflectionTestUtils
.getField(services, "restTemplate");
MockRestServiceServer server = MockRestServiceServer.createServer(template);
server.expect(requestTo("http://example.com"))
.andRespond(withSuccess("{\"id\":\"user\"}", MediaType.APPLICATION_JSON));
services.loadAuthentication("FOO");
assertEquals("FOO", client.getAccessToken().getValue());
server.verify();
}
開發者ID:spring-cloud,項目名稱:spring-cloud-security,代碼行數:22,代碼來源:ResourceServerTokenRelayAutoConfigurationTests.java
示例4: setup
import org.springframework.test.web.client.MockRestServiceServer; //導入方法依賴的package包/類
@Before
public void setup() {
List<Person> composers = Arrays.asList(
new Person("Johann Sebastian Bach").setSomeDouble(21),
new Person("Johannes Brahms").setSomeDouble(.0025),
new Person("Edvard Grieg").setSomeDouble(1.6035),
new Person("Robert Schumann").setSomeDouble(Double.NaN));
this.people = new PeopleWrapper(composers);
List<HttpMessageConverter<?>> converters = new ArrayList<HttpMessageConverter<?>>();
converters.add(new Jaxb2RootElementHttpMessageConverter());
this.restTemplate = new RestTemplate();
this.restTemplate.setMessageConverters(converters);
this.mockServer = MockRestServiceServer.createServer(this.restTemplate);
}
示例5: setup
import org.springframework.test.web.client.MockRestServiceServer; //導入方法依賴的package包/類
@Before
public void setup() {
this.people = new LinkedMultiValueMap<String, Person>();
this.people.add("composers", new Person("Johann Sebastian Bach"));
this.people.add("composers", new Person("Johannes Brahms"));
this.people.add("composers", new Person("Edvard Grieg"));
this.people.add("composers", new Person("Robert Schumann"));
this.people.add("performers", new Person("Vladimir Ashkenazy"));
this.people.add("performers", new Person("Yehudi Menuhin"));
List<HttpMessageConverter<?>> converters = new ArrayList<HttpMessageConverter<?>>();
converters.add(new MappingJacksonHttpMessageConverter());
this.restTemplate = new RestTemplate();
this.restTemplate.setMessageConverters(converters);
this.mockServer = MockRestServiceServer.createServer(this.restTemplate);
}
示例6: testLoadRemote
import org.springframework.test.web.client.MockRestServiceServer; //導入方法依賴的package包/類
@Test
@DirtiesContext
public void testLoadRemote() throws Exception {
MockRestServiceServer server = MockRestServiceServer.createServer(restTemplate);
server.expect(requestTo(sitemapUrl)).andRespond(withSuccess(resourceLoader.getResource("classpath:/xml/footer.xml"), MediaType.APPLICATION_XML));
Footer footer = restTemplate.getForObject(sitemapUrl, Footer.class);
assertEquals(7, footer.getMenuset().size());
SiteMap frSiteMap = footer.getMenuset().get(0);
assertEquals("fr", frSiteMap.getLanguage());
assertEquals(13, frSiteMap.getEntries().size());
assertEquals("/fr/association", frSiteMap.getEntries().get(0).getUrl());
assertEquals("Association", frSiteMap.getEntries().get(0).getLabel());
SiteMap enSiteMap = footer.getMenuset().get(1);
assertEquals("en", enSiteMap.getLanguage());
assertEquals(13, enSiteMap.getEntries().size());
server.verify();
}
示例7: setupMockRestServiceServer
import org.springframework.test.web.client.MockRestServiceServer; //導入方法依賴的package包/類
private MockRestServiceServer setupMockRestServiceServer(NFJSLoader loader, int numberOfLoads) {
MockRestServiceServer mockServer = MockRestServiceServer.createServer(loader.getRestTemplate());
for (int i=0; i < numberOfLoads; i++) {
mockServer.expect(
requestTo("https://springone2gx.com/m/data/show_short.json?showId=" + SHOW_ID))
.andExpect(method(GET))
.andRespond(ResponseCreators.withSuccess(new ClassPathResource("show_short.json", NFJSLoaderTest.class), APPLICATION_JSON));
mockServer.expect(
requestTo("https://springone2gx.com/m/data/show_schedule.json?showId=" + SHOW_ID))
.andExpect(method(GET))
.andRespond(ResponseCreators.withSuccess(new ClassPathResource("show_schedule.json", NFJSLoaderTest.class), APPLICATION_JSON));
mockServer.expect(
requestTo("https://springone2gx.com/m/data/show_speakers.json?showId=" + SHOW_ID))
.andExpect(method(GET))
.andRespond(ResponseCreators.withSuccess(new ClassPathResource("show_speakers.json", NFJSLoaderTest.class), APPLICATION_JSON));
mockServer.expect(
requestTo("https://springone2gx.com/m/data/show_topics.json?showId=" + SHOW_ID))
.andExpect(method(GET))
.andRespond(ResponseCreators.withSuccess(new ClassPathResource("show_topics.json", NFJSLoaderTest.class), APPLICATION_JSON));
}
return mockServer;
}
示例8: setup
import org.springframework.test.web.client.MockRestServiceServer; //導入方法依賴的package包/類
@Before
public void setup() throws Exception {
MockitoAnnotations.initMocks(this);
mockRestServer = MockRestServiceServer.createServer(restTemplate);
amqpReceiver = new AmqpReceiver(rule.getProcessEngine());
// default behavior for ReceiveTask's in process: just continue
when(orderProcess.waitsAtReceiveTask(anyString())).thenReturn((messageSubscription) -> messageSubscription.receive());
}
開發者ID:berndruecker,項目名稱:camunda-spring-boot-amqp-microservice-cloud-example,代碼行數:11,代碼來源:OrderProcessTest.java
示例9: TuPactRecordingServer
import org.springframework.test.web.client.MockRestServiceServer; //導入方法依賴的package包/類
protected TuPactRecordingServer(RestTemplate restTemplate, File pactFile, ObjectStringConverter objectConverter, MediaType contentType) {
this.restTemplate = restTemplate;
this.pactFile = pactFile;
this.objectConverter = objectConverter;
originalRequestFactory = restTemplate.getRequestFactory();
mockRestServiceServer = MockRestServiceServer.createServer(restTemplate);
this.contentType = contentType;
}
示例10: setUp
import org.springframework.test.web.client.MockRestServiceServer; //導入方法依賴的package包/類
@Before
public void setUp() {
restTemplate.setErrorHandler(new SeyrenResponseErrorHandler());
mockServer = MockRestServiceServer.createServer(restTemplate);
seyrenRepository.setRestTemplate(restTemplate);
seyrenRepository.setSeyrenUrl(seyrenUrl);
}
示例11: before
import org.springframework.test.web.client.MockRestServiceServer; //導入方法依賴的package包/類
@Before
public void before() {
RestTemplate restTemplate = VaultClients.createRestTemplate();
restTemplate.setUriTemplateHandler(new PrefixAwareUriTemplateHandler());
this.mockRest = MockRestServiceServer.createServer(restTemplate);
this.restTemplate = restTemplate;
}
示例12: setUp
import org.springframework.test.web.client.MockRestServiceServer; //導入方法依賴的package包/類
@Before
public void setUp()
{
config = new InstanceConfig("https", "my.eu1.fredhopperservices.com", Integer.valueOf(443), "fas:test1", "user", "pwd");
final RestTemplateProvider restTemplateProvider = new RestTemplateProvider();
final RestTemplate template = restTemplateProvider.createTemplate(config.getHost(), config.getPort(), config.getUsername(),
config.getPassword());
mockServer = MockRestServiceServer.createServer(template);
final RestTemplateProvider restTemplateProviderMock = Mockito.mock(RestTemplateProvider.class);
Mockito.when(restTemplateProviderMock.createTemplate(config.getHost(), config.getPort(), config.getUsername(),
config.getPassword())).thenReturn(template);
strategy = new RestPublishingStrategy();
strategy.setRestTemplateProvider(restTemplateProviderMock);
}
示例13: tearUp
import org.springframework.test.web.client.MockRestServiceServer; //導入方法依賴的package包/類
@Before
public void tearUp() {
MockitoAnnotations.initMocks(this);
this.mockServer = MockRestServiceServer.createServer(asyncRestTemplate);
// ensure JSON exchanges
ngsiRestClient.protocolRegistry.unregisterHost(baseUrl);
}
示例14: testOkMessage
import org.springframework.test.web.client.MockRestServiceServer; //導入方法依賴的package包/類
@Test
public void testOkMessage() throws Exception {
RestTemplate t = new RestTemplate();
MockRestServiceServer mockServer = MockRestServiceServer.createServer(t);
mockServer.expect(requestTo(TEST_REQUEST_PATH)).andRespond(
withSuccess(VALID_LISTCLIENTS_RESPONSE, MediaType.APPLICATION_XML));
ClientList clientList = t.getForObject(TEST_REQUEST_PATH, ClientList.class);
assertNotNull(clientList);
assertEquals(3, clientList.getMember().size());
}
示例15: setup
import org.springframework.test.web.client.MockRestServiceServer; //導入方法依賴的package包/類
@Before
public void setup() {
List<HttpMessageConverter<?>> converters = new ArrayList<HttpMessageConverter<?>>();
converters.add(new StringHttpMessageConverter());
converters.add(new MappingJackson2HttpMessageConverter());
this.restTemplate = new RestTemplate();
this.restTemplate.setMessageConverters(converters);
this.mockServer = MockRestServiceServer.createServer(this.restTemplate);
}