From 8dbea0719c9a9803ea628e2bb8ffecdfc8130f6b Mon Sep 17 00:00:00 2001 From: Soby Chacko Date: Mon, 19 Aug 2019 18:27:07 -0400 Subject: [PATCH] Restore a test in ConfluentSchemaRegistryClientTests This test was removed in the previous PR commit 10b6d16ca3c2. However, after making some slight adjustments, we can still test this scenario. --- .../ConfluentSchemaRegistryClientTests.java | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/spring-cloud-stream-schema/src/test/java/org/springframework/cloud/schema/avro/client/ConfluentSchemaRegistryClientTests.java b/spring-cloud-stream-schema/src/test/java/org/springframework/cloud/schema/avro/client/ConfluentSchemaRegistryClientTests.java index afa0655f9..23d8cacc9 100644 --- a/spring-cloud-stream-schema/src/test/java/org/springframework/cloud/schema/avro/client/ConfluentSchemaRegistryClientTests.java +++ b/spring-cloud-stream-schema/src/test/java/org/springframework/cloud/schema/avro/client/ConfluentSchemaRegistryClientTests.java @@ -139,4 +139,26 @@ public class ConfluentSchemaRegistryClientTests { String schema = client.fetch(reference); } + @Test + public void responseErrorFetch() { + this.mockRestServiceServer + .expect(requestTo("http://localhost:8081")) + .andExpect(method(HttpMethod.POST)) + .andExpect(header("Content-Type", "application/json")) + .andExpect(header("Accept", "application/vnd.schemaregistry.v1+json")) + .andRespond(withBadRequest()); + + ConfluentSchemaRegistryClient client = new ConfluentSchemaRegistryClient( + this.restTemplate); + Exception expected = null; + try { + SchemaRegistrationResponse response = client.register("user", "avro", "{}"); + } + catch (Exception e) { + expected = e; + } + assertThat(expected != null).isTrue(); + assertThat(expected.getCause() instanceof HttpStatusCodeException).isTrue(); + this.mockRestServiceServer.verify(); + } }