Skip to content

Commit cca19a5

Browse files
committed
Fix avro tests
1 parent 8b6b127 commit cca19a5

File tree

1 file changed

+22
-19
lines changed

1 file changed

+22
-19
lines changed

schema-registry/spring-cloud-stream-schema-registry-server/src/test/java/org/springframework/cloud/stream/schema/registry/server/SchemaRegistryServerAvroTests.java

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,8 @@ public void unsupportedFormat() {
151151
fail("Expects: " + HttpStatus.BAD_REQUEST + " error");
152152
}
153153
catch (HttpClientErrorException.BadRequest badRequest) {
154-
assertThat(badRequest.getMessage()).isEqualTo("400 on POST request for \"http://localhost:8990\": \"Format not supported: Invalid format, supported types are: avro\"");
154+
assertThat(badRequest.getMessage()).contains("Format not supported: Invalid format, supported types are: avro");
155+
assertThat(badRequest.getMessage()).contains("400");
155156
}
156157

157158
}
@@ -164,7 +165,8 @@ public void invalidSchema() {
164165
fail("Expects: " + HttpStatus.BAD_REQUEST + " error");
165166
}
166167
catch (HttpClientErrorException.BadRequest badRequest) {
167-
assertThat(badRequest.getMessage()).isEqualTo("400 on POST request for \"http://localhost:8990\": \"Invalid Schema: No type: {}\"");
168+
assertThat(badRequest.getMessage()).contains("\"Invalid Schema: No type: {}\"");
169+
assertThat(badRequest.getMessage()).contains("400");
168170
}
169171

170172
}
@@ -178,8 +180,8 @@ public void invalidSchemaGh22() {
178180
fail("Expects: " + HttpStatus.BAD_REQUEST + " error");
179181
}
180182
catch (HttpClientErrorException.BadRequest badRequest) {
181-
assertThat(badRequest.getMessage()).isEqualTo("400 on POST request for \"http://localhost:8990\": " +
182-
"\"Invalid Schema: \"SomeType\" is not a defined name. The type of the \"field\" field must be a defined name or a {\"type\": ...} expression.\"");
183+
assertThat(badRequest.getMessage()).contains("\"Invalid Schema: \"SomeType\" is not a defined name");
184+
assertThat(badRequest.getMessage()).contains("400");
183185
}
184186

185187
}
@@ -223,8 +225,8 @@ public void findByIdNotFound() {
223225
fail("Expects: " + HttpStatus.NOT_FOUND + " error");
224226
}
225227
catch (HttpClientErrorException.NotFound notFound) {
226-
assertThat(notFound.getMessage()).isEqualTo("404 on GET request for \"http://localhost:8990/schemas/2\": " +
227-
"\"Schema not found: Could not find Schema by id: 2\"");
228+
assertThat(notFound.getMessage()).contains("Could not find Schema by id: 2");
229+
assertThat(notFound.getMessage()).contains("404");
228230
}
229231
}
230232

@@ -269,8 +271,8 @@ public void schemaDeletionBySubjectFormatVersion() {
269271
this.client.getForEntity(subjectFormatVersionUri, Schema.class);
270272
}
271273
catch (HttpClientErrorException.NotFound notFound) {
272-
assertThat(notFound.getMessage()).isEqualTo("404 on GET request for \"http://localhost:8990/user/avro/v1\": " +
273-
"\"Schema not found: Could not find Schema by subject: user, format: avro, version 1\"");
274+
assertThat(notFound.getMessage()).contains("404");
275+
assertThat(notFound.getMessage()).contains("Schema not found: Could not find Schema by subject: user, format: avro, version 1");
274276
}
275277

276278
}
@@ -291,8 +293,8 @@ public void schemaDeletionBySubjectFormatVersionNotFound() {
291293
this.client.exchange(new RequestEntity<>(HttpMethod.DELETE, subjectFormatVersionUri), Void.class);
292294
}
293295
catch (HttpClientErrorException.NotFound notFound) {
294-
assertThat(notFound.getMessage()).isEqualTo("404 on DELETE request for \"http://localhost:8990/user/avro/v100\": " +
295-
"\"Schema not found: Could not find Schema by subject: user, format: avro, version 100\"");
296+
assertThat(notFound.getMessage()).contains("404");
297+
assertThat(notFound.getMessage()).contains("Schema not found: Could not find Schema by subject: user, format: avro, version 100");
296298
}
297299

298300
}
@@ -309,8 +311,8 @@ public void schemaDeletionBySubjectFormatVersionNotAllowed() {
309311
this.client.exchange(new RequestEntity<>(HttpMethod.DELETE, versionUri), Void.class);
310312
}
311313
catch (HttpClientErrorException.MethodNotAllowed methodNotAllowed) {
312-
assertThat(methodNotAllowed.getMessage()).isEqualTo("405 on DELETE request for \"http://localhost:8990/user/avro/v1\": " +
313-
"\"Schema deletion is not permitted: Not permitted deletion of Schema by subject: user, format: avro, version 1\"");
314+
assertThat(methodNotAllowed.getMessage()).contains("405");
315+
assertThat(methodNotAllowed.getMessage()).contains("Schema deletion is not permitted: Not permitted deletion of Schema by subject: user, format: avro, version 1");
314316
}
315317

316318
}
@@ -330,8 +332,8 @@ public void schemaDeletionById() {
330332
fail("Expects: " + HttpStatus.NOT_FOUND + " error");
331333
}
332334
catch (HttpClientErrorException.NotFound notFound) {
333-
assertThat(notFound.getMessage()).isEqualTo("404 on GET request for \"http://localhost:8990/user/avro/v1\": " +
334-
"\"Schema not found: Could not find Schema by subject: user, format: avro, version 1\"");
335+
assertThat(notFound.getMessage()).contains("Schema not found: Could not find Schema by subject: user, format: avro, version 1\"");
336+
assertThat(notFound.getMessage()).contains("404");
335337
}
336338

337339
}
@@ -349,7 +351,8 @@ public void schemaDeletionByIdNotFound() {
349351
fail("Expects: " + HttpStatus.NOT_FOUND + " error");
350352
}
351353
catch (HttpClientErrorException.NotFound notFound) {
352-
assertThat(notFound.getMessage()).isEqualTo("404 on DELETE request for \"http://localhost:8990/schemas/2\": \"Schema not found: Could not find Schema by id: 2\"");
354+
assertThat(notFound.getMessage()).contains("Schema not found: Could not find Schema by id: 2\"");
355+
assertThat(notFound.getMessage()).contains("404");
353356
}
354357

355358
}
@@ -368,8 +371,8 @@ public void schemaDeletionByIdNotAllowed() {
368371
fail("Expects: " + HttpStatus.METHOD_NOT_ALLOWED + " error");
369372
}
370373
catch (HttpClientErrorException.MethodNotAllowed methodNotAllowed) {
371-
assertThat(methodNotAllowed.getMessage()).isEqualTo("405 on DELETE request for \"http://localhost:8990/schemas/1\": " +
372-
"\"Schema deletion is not permitted: Not permitted deletion of Schema by id: 1\"");
374+
assertThat(methodNotAllowed.getMessage()).contains("Not permitted deletion of Schema by id: 1");
375+
assertThat(methodNotAllowed.getMessage()).contains("405");
373376
}
374377

375378
}
@@ -439,8 +442,8 @@ public void schemaDeletionBySubjectNotAllowed() {
439442
fail("Expects: " + HttpStatus.METHOD_NOT_ALLOWED + " error");
440443
}
441444
catch (HttpClientErrorException.MethodNotAllowed methodNotAllowed) {
442-
assertThat(methodNotAllowed.getMessage()).isEqualTo("405 on DELETE request for \"http://localhost:8990/user\": " +
443-
"\"Schema deletion is not permitted: Not permitted deletion of Schema by subject: user\"");
445+
assertThat(methodNotAllowed.getMessage()).contains("405");
446+
assertThat(methodNotAllowed.getMessage()).contains("Schema deletion is not permitted: Not permitted deletion of Schema by subject: user");
444447
}
445448

446449
}

0 commit comments

Comments
 (0)