當前位置: 首頁>>代碼示例>>Java>>正文


Java MockRestServiceServer類代碼示例

本文整理匯總了Java中org.springframework.test.web.client.MockRestServiceServer的典型用法代碼示例。如果您正苦於以下問題:Java MockRestServiceServer類的具體用法?Java MockRestServiceServer怎麽用?Java MockRestServiceServer使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


MockRestServiceServer類屬於org.springframework.test.web.client包,在下文中一共展示了MockRestServiceServer類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: mockMonitoring

import org.springframework.test.web.client.MockRestServiceServer; //導入依賴的package包/類
public static void mockMonitoring(MockRestServiceServer mockServer, URI baseUrl)
    throws Exception {

  // provider-RECAS-BARI
  mockServer.expect(requestTo(baseUrl + "/monitoring/adapters/zabbix/zones/indigo/types/"
        + "infrastructure/groups/Cloud_Providers/hosts/provider-RECAS-BARI")).andExpect(method(HttpMethod.GET))
      .andRespond(withSuccess(
          "{\"meta\":{\"status\":200,\"additionalProperties\":{}},\"result\":{\"groups\":[{\"groupName\":\"Cloud_Providers\",\"paasMachines\":[{\"machineName\":\"provider-RECAS-BARI\",\"ip\":\"127.0.0.1\",\"serviceCategory\":\"\",\"serviceId\":\"ID\",\"services\":[{\"serviceName\":\"\",\"paasMetrics\":[{\"metricName\":\"OCCI Create VM availability\",\"metricKey\":\"Cloud_Providers.provider-RECAS-BARI..OCCI Create VM availability\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"bit\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"OCCI CreateVM Response Time\",\"metricKey\":\"Cloud_Providers.provider-RECAS-BARI..OCCI CreateVM Response Time\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"ms\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"OCCI CreateVM Result\",\"metricKey\":\"Cloud_Providers.provider-RECAS-BARI..OCCI CreateVM Result\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"bit\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"OCCI Delete VM Availability\",\"metricKey\":\"Cloud_Providers.provider-RECAS-BARI..OCCI Delete VM Availability\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"bit\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"OCCI DeleteVM Response Time\",\"metricKey\":\"Cloud_Providers.provider-RECAS-BARI..OCCI DeleteVM Response Time\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"ms\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"OCCI DeleteVM Result\",\"metricKey\":\"Cloud_Providers.provider-RECAS-BARI..OCCI DeleteVM Result\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"bit\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"General OCCI API Availability\",\"metricKey\":\"Cloud_Providers.provider-RECAS-BARI..General OCCI API Availability\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"bit\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"General OCCI API Response Time\",\"metricKey\":\"Cloud_Providers.provider-RECAS-BARI..General OCCI API Response Time\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"ms\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"General OCCI API Result\",\"metricKey\":\"Cloud_Providers.provider-RECAS-BARI..General OCCI API Result\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"bit\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"OCCI Inspect VM availability\",\"metricKey\":\"Cloud_Providers.provider-RECAS-BARI..OCCI Inspect VM availability\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"bit\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"OCCI InspectVM Response Time\",\"metricKey\":\"Cloud_Providers.provider-RECAS-BARI..OCCI InspectVM Response Time\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"ms\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"OCCI InspectVM Result\",\"metricKey\":\"Cloud_Providers.provider-RECAS-BARI..OCCI InspectVM Result\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"bit\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]}]}]}]}]},\"additionalProperties\":{}}",
          MediaType.APPLICATION_JSON));

  // provider-UPV-GRyCAP
  mockServer.expect(requestTo(baseUrl + "/monitoring/adapters/zabbix/zones/indigo/types/"
        + "infrastructure/groups/Cloud_Providers/hosts/provider-UPV-GRyCAP")).andExpect(method(HttpMethod.GET))
      .andRespond(withSuccess(
          "{\"meta\":{\"status\":200,\"additionalProperties\":{}},\"result\":{\"groups\":[{\"groupName\":\"Cloud_Providers\",\"paasMachines\":[{\"machineName\":\"provider-UPV-GRyCAP\",\"ip\":\"127.0.0.1\",\"serviceCategory\":\"\",\"serviceId\":\"id\",\"services\":[{\"serviceName\":\"\",\"paasMetrics\":[{\"metricName\":\"OCCI Create VM availability\",\"metricKey\":\"Cloud_Providers.provider-UPV-GRyCAP..OCCI Create VM availability\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"bit\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"OCCI CreateVM Response Time\",\"metricKey\":\"Cloud_Providers.provider-UPV-GRyCAP..OCCI CreateVM Response Time\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"ms\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"OCCI CreateVM Result\",\"metricKey\":\"Cloud_Providers.provider-UPV-GRyCAP..OCCI CreateVM Result\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"bit\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"OCCI Delete VM Availability\",\"metricKey\":\"Cloud_Providers.provider-UPV-GRyCAP..OCCI Delete VM Availability\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"bit\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"OCCI DeleteVM Response Time\",\"metricKey\":\"Cloud_Providers.provider-UPV-GRyCAP..OCCI DeleteVM Response Time\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"ms\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"OCCI DeleteVM Result\",\"metricKey\":\"Cloud_Providers.provider-UPV-GRyCAP..OCCI DeleteVM Result\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"bit\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"General OCCI API Availability\",\"metricKey\":\"Cloud_Providers.provider-UPV-GRyCAP..General OCCI API Availability\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"bit\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"General OCCI API Response Time\",\"metricKey\":\"Cloud_Providers.provider-UPV-GRyCAP..General OCCI API Response Time\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"ms\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"General OCCI API Result\",\"metricKey\":\"Cloud_Providers.provider-UPV-GRyCAP..General OCCI API Result\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"bit\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"OCCI Inspect VM availability\",\"metricKey\":\"Cloud_Providers.provider-UPV-GRyCAP..OCCI Inspect VM availability\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"bit\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"OCCI InspectVM Response Time\",\"metricKey\":\"Cloud_Providers.provider-UPV-GRyCAP..OCCI InspectVM Response Time\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"ms\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]},{\"metricName\":\"OCCI InspectVM Result\",\"metricKey\":\"Cloud_Providers.provider-UPV-GRyCAP..OCCI InspectVM Result\",\"metricValue\":0.0,\"metricTime\":\"Instant null because no metrics were returned in the last 24hs\",\"metricUnit\":\"bit\",\"paasThresholds\":[],\"historyClocks\":[],\"historyValues\":[]}]}]}]}]},\"additionalProperties\":{}}",
          MediaType.APPLICATION_JSON));
}
 
開發者ID:indigo-dc,項目名稱:orchestrator,代碼行數:18,代碼來源:RankCloudProvidersWorkflowIT.java

示例2: TracingRestTemplateTest

import org.springframework.test.web.client.MockRestServiceServer; //導入依賴的package包/類
public TracingRestTemplateTest() {
    final RestTemplate restTemplate = new RestTemplate();
    restTemplate.setInterceptors(Collections.<ClientHttpRequestInterceptor>singletonList(
            new TracingRestTemplateInterceptor(mockTracer)));

    client = new Client<RestTemplate>() {
        @Override
        public <T> ResponseEntity<T> getForEntity(String url, Class<T> clazz) {
            return restTemplate.getForEntity(url, clazz);
        }

        @Override
        public RestTemplate template() {
            return restTemplate;
        }
    };

    mockServer = MockRestServiceServer.bindTo(client.template()).build();
}
 
開發者ID:opentracing-contrib,項目名稱:java-spring-web,代碼行數:20,代碼來源:TracingRestTemplateTest.java

示例3: 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);
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:24,代碼來源:XpathRequestMatchersIntegrationTests.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);
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:20,代碼來源:XmlContentRequestMatchersIntegrationTests.java

示例5: testCreateCodes

import org.springframework.test.web.client.MockRestServiceServer; //導入依賴的package包/類
/**
 * Guess what? - a test!
 */
@Test
public void testCreateCodes() {
  InternetAccessCodeSvc iacSvcConfig = new InternetAccessCodeSvc();
  iacSvcConfig.setIacPostPath("/iacs");
  Mockito.when(appConfig.getInternetAccessCodeSvc()).thenReturn(iacSvcConfig);
  RestTemplate restTemplate = this.restClient.getRestTemplate();

  MockRestServiceServer mockServer = MockRestServiceServer.createServer(restTemplate);
  mockServer.expect(requestTo("http://localhost:8080/iacs"))
      .andExpect(method(HttpMethod.POST))
      .andExpect(content().string(containsString("\"count\":" + 3 + ",")))
      .andExpect(content().string(containsString("\"createdBy\":" + "\"SYSTEM\"")))
      .andRespond(withSuccess("[1,2,3]", MediaType.APPLICATION_JSON));

  List<String> codes = iacSvcClientService.generateIACs(3);
  assertTrue(codes != null);
  assertTrue(codes.containsAll(Arrays.asList(new String[] {"1", "2", "3"})));
  mockServer.verify();
}
 
開發者ID:ONSdigital,項目名稱:response-management-service,代碼行數:23,代碼來源:InternetAccessCodeSvcClientServiceImplTest.java

示例6: testCreateAction

import org.springframework.test.web.client.MockRestServiceServer; //導入依賴的package包/類
/**
 * Guess what? - a test!
 */
@Test
public void testCreateAction() {
  ActionSvc actionSvcConfig = new ActionSvc();
  actionSvcConfig.setActionsPath("/actions");
  Mockito.when(appConfig.getActionSvc()).thenReturn(actionSvcConfig);
  RestTemplate restTemplate = this.restClient.getRestTemplate();

  MockRestServiceServer mockServer = MockRestServiceServer.createServer(restTemplate);
  mockServer.expect(requestTo("http://localhost:8080/actions"))
      .andExpect(method(HttpMethod.POST))
      .andExpect(content().string(containsString("\"actionTypeName\":" + "\"GeneralEscalation\"" + ",")))
      .andExpect(content().string(containsString("\"caseId\":" + "123,")))
      .andExpect(content().string(containsString("\"createdBy\":" + "\"SYSTEM\"")))
      .andRespond(withSuccess());

  actionSvcClientService.createAndPostAction("GeneralEscalation", 123, "SYSTEM");
  mockServer.verify();
}
 
開發者ID:ONSdigital,項目名稱:response-management-service,代碼行數:22,代碼來源:ActionSvcClientServiceImplTest.java

示例7: execute

import org.springframework.test.web.client.MockRestServiceServer; //導入依賴的package包/類
@Override
public void execute(final String baseUrl, final UrlResolution resolution, final String uri,
        final HttpMethod method, final Consumer<Http> tester) {

    final MockSetup setup = new MockSetup(baseUrl);
    final Http unit = setup.getHttpBuilder().urlResolution(resolution).build();
    final MockRestServiceServer server = setup.getServer();

    server.expect(requestTo(requestUri))
            .andExpect(method(method))
            .andRespond(withSuccess());

    tester.accept(unit);
    server.verify();

}
 
開發者ID:zalando,項目名稱:riptide,代碼行數:17,代碼來源:RequestUriTest.java

示例8: shouldFailIfNoConverterFoundForBodyOfUnknownContentType

import org.springframework.test.web.client.MockRestServiceServer; //導入依賴的package包/類
@Test
public void shouldFailIfNoConverterFoundForBodyOfUnknownContentType() {
    final MockSetup setup = new MockSetup("https://api.example.com", Collections.emptyList());
    final MockRestServiceServer server = setup.getServer();
    final Http unit = setup.getHttpBuilder()
            .converter(new Jaxb2RootElementHttpMessageConverter()).build();

    // we never actually make the request, but the mock server is doing some magic pre-actively
    server.expect(requestTo(url))
            .andRespond(withSuccess());

    exception.expect(RestClientException.class);
    exception.expectMessage("no suitable HttpMessageConverter found ");
    exception.expectMessage("org.zalando.riptide.model.Success");

    unit.delete(url)
            .body(new Success(true))
            .dispatch(contentType());

    server.verify();
}
 
開發者ID:zalando,項目名稱:riptide,代碼行數:22,代碼來源:ExecuteTest.java

示例9: testHealthCheck

import org.springframework.test.web.client.MockRestServiceServer; //導入依賴的package包/類
@Test
public void testHealthCheck() throws Exception {
  
  //ASSERT
  RestTemplate restTemplate = this.daraService.getRestTemplate();
  MockRestServiceServer mockServer = MockRestServiceServer.bindTo(restTemplate).build();
  mockServer
    .expect(requestTo(this.daraService.getApiEndpoint() + DaraService.IS_ALiVE_ENDPOINT))
    .andRespond(withSuccess());
  
  //ACT
  boolean health = this.daraService.isDaraHealthy();
  
  //ASSERT
  assertThat(health, is(true));
}
 
開發者ID:dzhw,項目名稱:metadatamanagement,代碼行數:17,代碼來源:DaraServiceTest.java

示例10: testRelease

import org.springframework.test.web.client.MockRestServiceServer; //導入依賴的package包/類
@Test
public void testRelease() throws Exception {
  
  //ASSERT
  RestTemplate restTemplate = this.daraService.getRestTemplate();
  MockRestServiceServer mockServer = MockRestServiceServer.bindTo(restTemplate).build();
  mockServer
    .expect(requestTo(this.daraService.getApiEndpoint() + DaraService.REGISTRATION_ENDPOINT + "?registration=true"))
    .andRespond(withStatus(HttpStatus.CREATED));
  DataAcquisitionProject project = UnitTestCreateDomainObjectUtils.buildDataAcquisitionProject();
  dataAcquisitionProjectRepository.save(project);    
  Study study = UnitTestCreateDomainObjectUtils.buildStudy(project.getId());
  this.studyRepository.save(study);
  
  //ACT
  HttpStatus isRegistered = this.daraService.registerOrUpdateProjectToDara(project.getId()); 
  
  //ASSERT
  assertThat(isRegistered, is(HttpStatus.CREATED));
}
 
開發者ID:dzhw,項目名稱:metadatamanagement,代碼行數:21,代碼來源:DaraServiceTest.java

示例11: routeSuccess

import org.springframework.test.web.client.MockRestServiceServer; //導入依賴的package包/類
@Test
public void routeSuccess() {

    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(withSuccess(osrm5Response(), APPLICATION_JSON));

    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(false));
    assertThat(result.getTotalTime(), is(503.6));
    assertThat(result.getTotalDistance(), is(8249.1));
    assertThat(result.getToll(), is(new BigDecimal("5.2908")));
}
 
開發者ID:Contargo,項目名稱:iris,代碼行數:21,代碼來源:Osrm5QueryStrategyIntegrationTest.java

示例12: 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));
}
 
開發者ID:Contargo,項目名稱:iris,代碼行數:18,代碼來源:Osrm5QueryStrategyIntegrationTest.java

示例13: should_delete_message_after_fetching

import org.springframework.test.web.client.MockRestServiceServer; //導入依賴的package包/類
@Test
public void should_delete_message_after_fetching() throws WhatsAppConnectionException {
	final MockRestServiceServer mockServer = MockRestServiceServer.createServer(restTemplate);

	mockServer.expect(MockRestRequestMatchers.requestTo("base/messages/inbox")) //
	.andExpect(MockRestRequestMatchers.method(HttpMethod.GET)) //
	.andRespond(MockRestResponseCreators.withSuccess("[{" + //
			" \"_id\" : \"42\", " + //
			"\"_from\" : \"41214214\", " + //
			"\"participant\" : \"41214214\", " + //
			"\"body\" : \"41214214\" " + //
			"}]", MediaType.APPLICATION_JSON));

	mockServer.expect(MockRestRequestMatchers.requestTo("base/messages/inbox/42")) //
	.andExpect(MockRestRequestMatchers.method(HttpMethod.DELETE)) //
	.andRespond(MockRestResponseCreators.withSuccess("", MediaType.APPLICATION_JSON));

	final GroupMessage[] messages = cut.fetchGroupMessages();

	assertThat(messages, is(not(emptyArray())));
	mockServer.verify();

}
 
開發者ID:learning-spring-boot,項目名稱:contest-votesapp,代碼行數:24,代碼來源:YowsupRestClientTest.java

示例14: 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

示例15: 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);
}
 
開發者ID:deathspeeder,項目名稱:class-guard,代碼行數:19,代碼來源:JsonPathRequestMatcherTests.java


注:本文中的org.springframework.test.web.client.MockRestServiceServer類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。