Skip to content

Commit

Permalink
Use user passed values instead of hardcoding
Browse files Browse the repository at this point in the history
  • Loading branch information
aureamunoz committed Oct 18, 2024
1 parent 59540c9 commit 205eb31
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public Uni<Void> registerServiceInstance(String serviceName, Metadata<EurekaMeta
int defaultPort) {

return registerApplicationInstance(client, serviceName,
metadata.getMetadata().get(EurekaMetadataKey.META_EUREKA_SERVICE_ID).toString(), "192.5.10.236", "acme.com",
metadata.getMetadata().get(EurekaMetadataKey.META_EUREKA_SERVICE_ID).toString(), ipAddress, null,
defaultPort, null, -1, "UP", "");

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import io.smallrye.stork.impl.EurekaMetadataKey;
import io.smallrye.stork.test.StorkTestUtils;
import io.smallrye.stork.test.TestConfigProviderBean;
import io.vertx.core.json.JsonObject;
import io.vertx.ext.web.client.WebClientOptions;
import io.vertx.mutiny.core.Vertx;
import io.vertx.mutiny.core.buffer.Buffer;
Expand Down Expand Up @@ -93,7 +94,7 @@ public void testRegistrationServiceInstances(TestInfo info) {

CountDownLatch registrationLatch = new CountDownLatch(1);
eurekaServiceRegistrar.registerServiceInstance(serviceName, Metadata.of(EurekaMetadataKey.class)
.with(EurekaMetadataKey.META_EUREKA_SERVICE_ID, serviceName), "acme.com", 8406).subscribe()
.with(EurekaMetadataKey.META_EUREKA_SERVICE_ID, serviceName), "localhost", 8406).subscribe()
.with(success -> registrationLatch.countDown(), failure -> fail(""));

await().atMost(Duration.ofSeconds(10))
Expand All @@ -109,6 +110,14 @@ public void testRegistrationServiceInstances(TestInfo info) {
assertThat(httpResponse).isNotNull();
assertThat(httpResponse.statusCode()).isEqualTo(200);

JsonObject jsonResponse = httpResponse.bodyAsJsonObject();
JsonObject application = jsonResponse.getJsonObject("application");
JsonObject jsonServiceInstance = application.getJsonArray("instance").getJsonObject(0);

assertThat(jsonServiceInstance.getString("instanceId")).isEqualTo("my-service");
assertThat(jsonServiceInstance.getString("ipAddr")).isEqualTo("localhost");
assertThat(jsonServiceInstance.getJsonObject("port").getInteger("$")).isEqualTo(8406);

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import io.smallrye.stork.impl.EurekaMetadataKey;
import io.smallrye.stork.test.StorkTestUtils;
import io.smallrye.stork.test.TestConfigProvider;
import io.vertx.core.json.JsonObject;
import io.vertx.ext.web.client.WebClientOptions;
import io.vertx.mutiny.core.Vertx;
import io.vertx.mutiny.core.buffer.Buffer;
Expand Down Expand Up @@ -77,7 +78,7 @@ public void testRegistrationServiceInstances(TestInfo info) {
CountDownLatch registrationLatch = new CountDownLatch(1);

eurekaServiceRegistrar.registerServiceInstance(serviceName, Metadata.of(EurekaMetadataKey.class)
.with(EurekaMetadataKey.META_EUREKA_SERVICE_ID, serviceName), "acme.com", 8406).subscribe()
.with(EurekaMetadataKey.META_EUREKA_SERVICE_ID, serviceName), "localhost", 8406).subscribe()
.with(success -> registrationLatch.countDown(), failure -> fail(""));

await().atMost(Duration.ofSeconds(10))
Expand All @@ -93,6 +94,14 @@ public void testRegistrationServiceInstances(TestInfo info) {
assertThat(httpResponse).isNotNull();
assertThat(httpResponse.statusCode()).isEqualTo(200);

JsonObject jsonResponse = httpResponse.bodyAsJsonObject();
JsonObject application = jsonResponse.getJsonObject("application");
JsonObject jsonServiceInstance = application.getJsonArray("instance").getJsonObject(0);

assertThat(jsonServiceInstance.getString("instanceId")).isEqualTo("my-service");
assertThat(jsonServiceInstance.getString("ipAddr")).isEqualTo("localhost");
assertThat(jsonServiceInstance.getJsonObject("port").getInteger("$")).isEqualTo(8406);

}

}

0 comments on commit 205eb31

Please sign in to comment.