Java Code Examples for org.springframework.cloud.client.discovery.simple.SimpleDiscoveryProperties#SimpleServiceInstance
The following examples show how to use
org.springframework.cloud.client.discovery.simple.SimpleDiscoveryProperties#SimpleServiceInstance .
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: AdminApplicationDiscoveryTest.java From Moss with Apache License 2.0 | 6 votes |
private URI registerInstance() { //We register the instance by setting static values for the SimpleDiscoveryClient and issuing a //InstanceRegisteredEvent that makes sure the instance gets registered. SimpleDiscoveryProperties.SimpleServiceInstance serviceInstance = new SimpleDiscoveryProperties.SimpleServiceInstance(); serviceInstance.setServiceId("Test-Instance"); serviceInstance.setUri(URI.create("http://localhost:" + port)); serviceInstance.getMetadata().put("management.context-path", "/mgmt"); simpleDiscovery.getInstances().put("Test-Application", singletonList(serviceInstance)); instance.publishEvent(new InstanceRegisteredEvent<>(new Object(), null)); //To get the location of the registered instances we fetch the instance with the name. List<JSONObject> applications = webClient.get() .uri("/instances?name=Test-Instance") .accept(MediaType.APPLICATION_JSON) .exchange() .expectStatus() .isOk() .returnResult(JSONObject.class) .getResponseBody() .collectList() .block(); assertThat(applications).hasSize(1); return URI.create("http://localhost:" + port + "/instances/" + applications.get(0).optString("id")); }
Example 2
Source File: AdminApplicationDiscoveryTest.java From spring-boot-admin with Apache License 2.0 | 6 votes |
private URI registerInstance() { // We register the instance by setting static values for the SimpleDiscoveryClient // and issuing a // InstanceRegisteredEvent that makes sure the instance gets registered. SimpleDiscoveryProperties.SimpleServiceInstance serviceInstance = new SimpleDiscoveryProperties.SimpleServiceInstance(); serviceInstance.setServiceId("Test-Instance"); serviceInstance.setUri(URI.create("http://localhost:" + this.port)); serviceInstance.getMetadata().put("management.context-path", "/mgmt"); this.simpleDiscovery.getInstances().put("Test-Application", singletonList(serviceInstance)); this.instance.publishEvent(new InstanceRegisteredEvent<>(new Object(), null)); // To get the location of the registered instances we fetch the instance with the // name. List<JSONObject> applications = this.webClient.get().uri("/instances?name=Test-Instance") .accept(MediaType.APPLICATION_JSON).exchange().expectStatus().isOk().returnResult(JSONObject.class) .getResponseBody().collectList().block(); assertThat(applications).hasSize(1); return URI.create("http://localhost:" + this.port + "/instances/" + applications.get(0).optString("id")); }
Example 3
Source File: ReactorLoadBalancerExchangeFilterFunctionTests.java From spring-cloud-commons with Apache License 2.0 | 5 votes |
@BeforeEach void setUp() { SimpleDiscoveryProperties.SimpleServiceInstance instance = new SimpleDiscoveryProperties.SimpleServiceInstance(); instance.setServiceId("testservice"); instance.setUri(URI.create("http://localhost:" + this.port)); this.properties.getInstances().put("testservice", Collections.singletonList(instance)); }