diff --git a/spring-cloud-stream-schema/src/main/java/org/springframework/cloud/stream/schema/client/DefaultSchemaRegistryClient.java b/spring-cloud-stream-schema/src/main/java/org/springframework/cloud/stream/schema/client/DefaultSchemaRegistryClient.java index d1ca29c1a..c3f81606c 100644 --- a/spring-cloud-stream-schema/src/main/java/org/springframework/cloud/stream/schema/client/DefaultSchemaRegistryClient.java +++ b/spring-cloud-stream-schema/src/main/java/org/springframework/cloud/stream/schema/client/DefaultSchemaRegistryClient.java @@ -36,7 +36,16 @@ public class DefaultSchemaRegistryClient implements SchemaRegistryClient { private String endpoint = "http://localhost:8990"; public DefaultSchemaRegistryClient() { - this.template = new RestTemplate(); + this(new RestTemplate()); + } + + public DefaultSchemaRegistryClient(RestTemplate restTemplate) { + Assert.notNull(restTemplate,"restTemplate cannot be null."); + this.template = restTemplate; + } + + protected String getEndpoint() { + return this.endpoint; } public void setEndpoint(String endpoint) { @@ -44,6 +53,15 @@ public class DefaultSchemaRegistryClient implements SchemaRegistryClient { this.endpoint = endpoint; } + protected RestTemplate getRestTemplate() { + return this.template; + } + + public void setRestTemplate(RestTemplate restTemplate) { + Assert.notNull(restTemplate,"restTemplate cannot be null."); + this.template = restTemplate; + } + @Override public SchemaRegistrationResponse register(String subject, String format, String schema) { Map requestBody = new HashMap<>();