Commit 976619f4 by Johannes Edmeier

Fix: use application_id from VCAP

parent 80eaf615
......@@ -23,7 +23,7 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
@lombok.Data
@ConfigurationProperties("vcap.application")
public class CloudFoundryApplicationProperties {
private String instanceId;
private String applicationId;
private String instanceIndex;
private List<String> uris = new ArrayList<>();
}
......@@ -32,10 +32,10 @@ public class CloudFoundryMetadataContributor implements MetadataContributor {
@Override
public Map<String, String> getMetadata() {
if (StringUtils.hasText(this.cfApplicationProperties.getInstanceId()) &&
if (StringUtils.hasText(this.cfApplicationProperties.getApplicationId()) &&
StringUtils.hasText(this.cfApplicationProperties.getInstanceIndex())) {
Map<String, String> map = new HashMap<>();
map.put("applicationId", this.cfApplicationProperties.getInstanceId());
map.put("applicationId", this.cfApplicationProperties.getApplicationId());
map.put("instanceId", this.cfApplicationProperties.getInstanceIndex());
return map;
}
......
......@@ -55,6 +55,7 @@ public class SpringBootAdminClientCloudFoundryAutoConfigurationTest {
@Test
public void cloudfoundry() {
String vcap = "VCAP_APPLICATION:{\"application_users\":[]," +
"\"application_id\":\"9958288f-9842-4ddc-93dd-1ea3c90634cd\"," +
"\"instance_id\":\"bb7935245adf3e650dfb7c58a06e9ece\"," +
"\"instance_index\":0,\"version\":\"3464e092-1c13-462e-a47c-807c30318a50\"," +
"\"name\":\"foo\",\"uris\":[\"foo.cfapps.io\"]," +
......@@ -70,7 +71,7 @@ public class SpringBootAdminClientCloudFoundryAutoConfigurationTest {
load("spring.boot.admin.client.url:http://localhost:8081", vcap);
ApplicationFactory factory = context.getBean(ApplicationFactory.class);
CloudFoundryMetadataContributor contributor = context.getBean(CloudFoundryMetadataContributor.class);
assertThat(contributor.getMetadata()).containsEntry("applicationId", "bb7935245adf3e650dfb7c58a06e9ece")
assertThat(contributor.getMetadata()).containsEntry("applicationId", "9958288f-9842-4ddc-93dd-1ea3c90634cd")
.containsEntry("instanceId", "0");
assertThat(factory).isInstanceOf(CloudFoundryApplicationFactory.class);
assertThat(factory.createApplication().getServiceUrl()).isEqualTo("http://dsyerenv.cfapps.io/");
......
......@@ -34,7 +34,7 @@ public class CloudFoundryMetadataContributorTest {
@Test
public void should_return_metadata() {
CloudFoundryApplicationProperties cfApplicationProperties = new CloudFoundryApplicationProperties();
cfApplicationProperties.setInstanceId("appId");
cfApplicationProperties.setApplicationId("appId");
cfApplicationProperties.setInstanceIndex("1");
CloudFoundryMetadataContributor contributor = new CloudFoundryMetadataContributor(cfApplicationProperties);
assertThat(contributor.getMetadata()).containsEntry("applicationId", "appId").containsEntry("instanceId", "1");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment