Skip to content

Commit c1ae668

Browse files
Merge branch '7.9.x' into 8.0.x by fangnx
2 parents e935a65 + 1c7e004 commit c1ae668

File tree

1 file changed

+40
-37
lines changed

1 file changed

+40
-37
lines changed

maven-plugin/src/test/java/io/confluent/kafka/schemaregistry/maven/SetCompatibilityMojoTest.java

Lines changed: 40 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -13,41 +13,44 @@
1313

1414
import static org.junit.Assert.assertThrows;
1515

16-
public class SetCompatibilityMojoTest extends SchemaRegistryTest{
17-
SetCompatibilityMojo mojo;
18-
19-
@Before
20-
public void createMojoAndFiles() {
21-
this.mojo = new SetCompatibilityMojo();
22-
this.mojo.client(new MockSchemaRegistryClient());
23-
}
24-
25-
@Test
26-
public void specificSubjects() throws IOException, RestClientException, MojoExecutionException {
27-
String keySubject = String.format("TestSubject-key");
28-
Schema keySchema = Schema.create(Schema.Type.STRING);
29-
30-
this.mojo.client().register(keySubject, new AvroSchema(keySchema));
31-
// Compatibility not set till now and hence should throw error
32-
assertThrows("Checking that compatibility hasn't been set",
33-
RestClientException.class, () -> this.mojo.client().getCompatibility(keySubject));
34-
35-
// Setting compatibility & checking if it matches
36-
this.mojo.compatibilityLevels.put(keySubject,"BACKWARD");
37-
this.mojo.execute();
38-
39-
assert(this.mojo.getConfig(keySubject).equals("BACKWARD"));
40-
41-
//Updating to a different compatibility
42-
this.mojo.compatibilityLevels.replace(keySubject, "BACKWARD", "FULL");
43-
this.mojo.execute();
44-
45-
assert(this.mojo.getConfig(keySubject).equals("FULL"));
46-
47-
//Checking for Global Compatibility
48-
this.mojo.compatibilityLevels.put("__GLOBAL", "BACKWARD_TRANSITIVE");
49-
this.mojo.execute();
50-
assert(this.mojo.getConfig(null).equals("BACKWARD_TRANSITIVE"));
51-
52-
}
16+
public class SetCompatibilityMojoTest extends SchemaRegistryTest {
17+
SetCompatibilityMojo mojo;
18+
19+
@Before
20+
public void createMojoAndFiles() {
21+
this.mojo = new SetCompatibilityMojo();
22+
this.mojo.client(new MockSchemaRegistryClient());
23+
}
24+
25+
@Test
26+
public void specificSubjects() throws IOException, RestClientException, MojoExecutionException {
27+
String keySubject = String.format("TestSubject-key");
28+
Schema keySchema = Schema.create(Schema.Type.STRING);
29+
30+
this.mojo.client().register(keySubject, new AvroSchema(keySchema));
31+
// Compatibility not set till now and hence should throw error
32+
assertThrows("Checking that compatibility hasn't been set",
33+
RestClientException.class, () -> this.mojo.client().getCompatibility(keySubject));
34+
35+
// Setting compatibility & checking if it matches
36+
this.mojo.compatibilityLevels.put(keySubject, "BACKWARD");
37+
this.mojo.execute();
38+
39+
assert (this.mojo.getConfig(keySubject).equals("BACKWARD"));
40+
41+
// Updating to a different compatibility
42+
this.mojo.compatibilityLevels.replace(keySubject, "BACKWARD", "FULL");
43+
this.mojo.execute();
44+
45+
assert (this.mojo.getConfig(keySubject).equals("FULL"));
46+
47+
// Checking for global compatibility
48+
this.mojo.compatibilityLevels.put("__GLOBAL", "BACKWARD_TRANSITIVE");
49+
this.mojo.execute();
50+
assert (this.mojo.getConfig(null).equals("BACKWARD_TRANSITIVE"));
51+
52+
// Checking for invalid compatibility level
53+
this.mojo.compatibilityLevels.put(keySubject, "INVALID_LEVEL");
54+
assertThrows(java.lang.IllegalArgumentException.class, () -> this.mojo.execute());
55+
}
5356
}

0 commit comments

Comments
 (0)