Skip to content

Commit

Permalink
Re-enable SchemaRegistryServerAvroTests
Browse files Browse the repository at this point in the history
* Update the expected error messages
  • Loading branch information
sobychacko committed Aug 7, 2024
1 parent dffbe6d commit b898e39
Showing 1 changed file with 21 additions and 21 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016-2023 the original author or authors.
* Copyright 2016-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -30,7 +30,6 @@

import org.apache.avro.Schema.Parser;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;

import org.springframework.beans.factory.annotation.Autowired;
Expand Down Expand Up @@ -71,7 +70,6 @@
*/
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT, properties = "spring.main.allow-bean-definition-overriding=true")
@DirtiesContext(classMode = AFTER_EACH_TEST_METHOD)
@Disabled
class SchemaRegistryServerAvroTests {

private static final String AVRO_FORMAT_NAME = "avro";
Expand Down Expand Up @@ -101,6 +99,7 @@ class SchemaRegistryServerAvroTests {
private static final Schema AAVRO_USER_REGISTRY_SCHEMA_V1_WITH_QUAL_SUBJECT = toSchema(
AVRO_USER_SCHEMA_QUALIFED_NAME_STRATEGY_SUBJECT,
AVRO_FORMAT_NAME, AVRO_USER_AVRO_SCHEMA_V1.toString());

@Autowired
private TestRestTemplate client;

Expand Down Expand Up @@ -151,7 +150,7 @@ public void unsupportedFormat() {
fail("Expects: " + HttpStatus.BAD_REQUEST + " error");
}
catch (HttpClientErrorException.BadRequest badRequest) {
assertThat(badRequest.getMessage()).isEqualTo("400 : \"Format not supported: Invalid format, supported types are: avro\"");
assertThat(badRequest.getMessage()).isEqualTo("400 on POST request for \"http://localhost:8990\": \"Format not supported: Invalid format, supported types are: avro\"");
}

}
Expand All @@ -164,7 +163,7 @@ public void invalidSchema() {
fail("Expects: " + HttpStatus.BAD_REQUEST + " error");
}
catch (HttpClientErrorException.BadRequest badRequest) {
assertThat(badRequest.getMessage()).isEqualTo("400 : \"Invalid Schema: No type: {}\"");
assertThat(badRequest.getMessage()).isEqualTo("400 on POST request for \"http://localhost:8990\": \"Invalid Schema: No type: {}\"");
}

}
Expand All @@ -178,8 +177,8 @@ public void invalidSchemaGh22() {
fail("Expects: " + HttpStatus.BAD_REQUEST + " error");
}
catch (HttpClientErrorException.BadRequest badRequest) {
assertThat(badRequest.getMessage()).isEqualTo("400 : \"Invalid Schema: \"SomeType\" is not a defined name. " +
"The type of the \"field\" field must be a defined name or a {\"type\": ...} expression.\"");
assertThat(badRequest.getMessage()).isEqualTo("400 on POST request for \"http://localhost:8990\": " +
"\"Invalid Schema: \"SomeType\" is not a defined name. The type of the \"field\" field must be a defined name or a {\"type\": ...} expression.\"");
}

}
Expand Down Expand Up @@ -223,7 +222,8 @@ public void findByIdNotFound() {
fail("Expects: " + HttpStatus.NOT_FOUND + " error");
}
catch (HttpClientErrorException.NotFound notFound) {
assertThat(notFound.getMessage()).isEqualTo("404 : \"Schema not found: Could not find Schema by id: 2\"");
assertThat(notFound.getMessage()).isEqualTo("404 on GET request for \"http://localhost:8990/schemas/2\": " +
"\"Schema not found: Could not find Schema by id: 2\"");
}
}

Expand Down Expand Up @@ -268,8 +268,8 @@ public void schemaDeletionBySubjectFormatVersion() {
this.client.getForEntity(subjectFormatVersionUri, Schema.class);
}
catch (HttpClientErrorException.NotFound notFound) {
assertThat(notFound.getMessage()).isEqualTo("404 : \"Schema not found: Could not find Schema by " +
"subject: user, format: avro, version 1\"");
assertThat(notFound.getMessage()).isEqualTo("404 on GET request for \"http://localhost:8990/user/avro/v1\": " +
"\"Schema not found: Could not find Schema by subject: user, format: avro, version 1\"");
}

}
Expand All @@ -290,8 +290,8 @@ public void schemaDeletionBySubjectFormatVersionNotFound() {
this.client.exchange(new RequestEntity<>(HttpMethod.DELETE, subjectFormatVersionUri), Void.class);
}
catch (HttpClientErrorException.NotFound notFound) {
assertThat(notFound.getMessage()).isEqualTo("404 : \"Schema not found: Could not find Schema by " +
"subject: user, format: avro, version 100\"");
assertThat(notFound.getMessage()).isEqualTo("404 on DELETE request for \"http://localhost:8990/user/avro/v100\": " +
"\"Schema not found: Could not find Schema by subject: user, format: avro, version 100\"");
}

}
Expand All @@ -308,8 +308,8 @@ public void schemaDeletionBySubjectFormatVersionNotAllowed() {
this.client.exchange(new RequestEntity<>(HttpMethod.DELETE, versionUri), Void.class);
}
catch (HttpClientErrorException.MethodNotAllowed methodNotAllowed) {
assertThat(methodNotAllowed.getMessage()).isEqualTo("405 : \"Schema deletion is not permitted: Not permitted " +
"deletion of Schema by subject: user, format: avro, version 1\"");
assertThat(methodNotAllowed.getMessage()).isEqualTo("405 on DELETE request for \"http://localhost:8990/user/avro/v1\": " +
"\"Schema deletion is not permitted: Not permitted deletion of Schema by subject: user, format: avro, version 1\"");
}

}
Expand All @@ -329,8 +329,8 @@ public void schemaDeletionById() {
fail("Expects: " + HttpStatus.NOT_FOUND + " error");
}
catch (HttpClientErrorException.NotFound notFound) {
assertThat(notFound.getMessage()).isEqualTo("404 : \"Schema not found: Could not find Schema by subject: " +
"user, format: avro, version 1\"");
assertThat(notFound.getMessage()).isEqualTo("404 on GET request for \"http://localhost:8990/user/avro/v1\": " +
"\"Schema not found: Could not find Schema by subject: user, format: avro, version 1\"");
}

}
Expand All @@ -348,7 +348,7 @@ public void schemaDeletionByIdNotFound() {
fail("Expects: " + HttpStatus.NOT_FOUND + " error");
}
catch (HttpClientErrorException.NotFound notFound) {
assertThat(notFound.getMessage()).isEqualTo("404 : \"Schema not found: Could not find Schema by id: 2\"");
assertThat(notFound.getMessage()).isEqualTo("404 on DELETE request for \"http://localhost:8990/schemas/2\": \"Schema not found: Could not find Schema by id: 2\"");
}

}
Expand All @@ -367,8 +367,8 @@ public void schemaDeletionByIdNotAllowed() {
fail("Expects: " + HttpStatus.METHOD_NOT_ALLOWED + " error");
}
catch (HttpClientErrorException.MethodNotAllowed methodNotAllowed) {
assertThat(methodNotAllowed.getMessage()).isEqualTo("405 : \"Schema deletion is not permitted: Not " +
"permitted deletion of Schema by id: 1\"");
assertThat(methodNotAllowed.getMessage()).isEqualTo("405 on DELETE request for \"http://localhost:8990/schemas/1\": " +
"\"Schema deletion is not permitted: Not permitted deletion of Schema by id: 1\"");
}

}
Expand Down Expand Up @@ -438,8 +438,8 @@ public void schemaDeletionBySubjectNotAllowed() {
fail("Expects: " + HttpStatus.METHOD_NOT_ALLOWED + " error");
}
catch (HttpClientErrorException.MethodNotAllowed methodNotAllowed) {
assertThat(methodNotAllowed.getMessage()).isEqualTo("405 : \"Schema deletion is not permitted: " +
"Not permitted deletion of Schema by subject: user\"");
assertThat(methodNotAllowed.getMessage()).isEqualTo("405 on DELETE request for \"http://localhost:8990/user\": " +
"\"Schema deletion is not permitted: Not permitted deletion of Schema by subject: user\"");
}

}
Expand Down

0 comments on commit b898e39

Please sign in to comment.