public async void CanTestCompatibility() { using (var registry = TestsConfig.GetRegistryApi()) { var subject = (await registry.GetAllSubjects())[0]; var schema = (await registry.GetLatestSchemaMetadata(subject)).Schema; await registry.PutSubjectConfig(subject, CompatibilityLevel.Backward); Assert.IsTrue(await registry.TestCompatibility(subject, schema)); Assert.IsTrue(await registry.TestCompatibility(subject, FullyCompatibleSchema)); Assert.IsFalse(await registry.TestCompatibility(subject, BackwardsIncompatibleSchema)); Assert.IsFalse(await registry.TestCompatibility(subject, CompletelyIncompatibleSchema)); await registry.PutSubjectConfig(subject, CompatibilityLevel.Forward); Assert.IsTrue(await registry.TestCompatibility(subject, schema)); Assert.IsTrue(await registry.TestCompatibility(subject, ForwardCompatibleSchema)); Assert.IsFalse(await registry.TestCompatibility(subject, ForwardIncompatibleSchema)); Assert.IsFalse(await registry.TestCompatibility(subject, CompletelyIncompatibleSchema)); await registry.PutSubjectConfig(subject, CompatibilityLevel.Full); Assert.IsTrue(await registry.TestCompatibility(subject, schema)); Assert.IsTrue(await registry.TestCompatibility(subject, FullyCompatibleSchema)); Assert.IsFalse(await registry.TestCompatibility(subject, BackwardsIncompatibleSchema)); Assert.IsFalse(await registry.TestCompatibility(subject, ForwardCompatibleSchema)); Assert.IsFalse(await registry.TestCompatibility(subject, ForwardIncompatibleSchema)); Assert.IsFalse(await registry.TestCompatibility(subject, CompletelyIncompatibleSchema)); await registry.PutSubjectConfig(subject, CompatibilityLevel.Forward); } }
public async void CanReadSchemas() { using (var registry = TestsConfig.GetRegistryApi()) { var subjects = await registry.GetAllSubjects(); Console.WriteLine(subjects.ToJson()); var versions = await registry.GetSchemaVersions(subjects[0]); Console.WriteLine(versions.ToJson()); var schema = await registry.GetById(versions[0]); Console.WriteLine(schema.Schema); var schemaVersionSpecific = await registry.GetBySubjectAndId(subjects[0], versions[0]); Console.WriteLine(schemaVersionSpecific.ToJson()); var schemaVersionLatest = await registry.GetLatestSchemaMetadata(subjects[0]); Console.WriteLine(schemaVersionLatest.ToJson()); } }
public async void CanReadConfig() { using (var registry = TestsConfig.GetRegistryApi()) { await registry.GetGlobalConfig(); var subject = (await registry.GetAllSubjects())[0]; await registry.GetSubjectConfig(subject); } }
public async void CanCheckIfSchemaRegistered() { using (var registry = TestsConfig.GetRegistryApi()) { var subject = (await registry.GetAllSubjects())[0]; var schema = (await registry.GetLatestSchemaMetadata(subject)).Schema; var existing = await registry.CheckIfSchemaRegistered(subject, schema); Assert.IsNotNull(existing); Assert.AreEqual(schema, existing.Schema); Assert.AreNotEqual(existing.Id, 0); Assert.AreEqual(subject, existing.Subject); Assert.IsTrue((await registry.TestCompatibility(subject, schema))); } }
public void CanRegisterSchema() { using (var registry = TestsConfig.GetRegistryApi()) { var subject = "dotnet-schema-registry-api-test2"; registry.PutSubjectConfig(subject, CompatibilityLevel.Backward); var response1 = registry.Register(subject, InitialSchema); //var code = Assert.Throws<SchemaRegistryException>(() => registry.Register(subject, InitialSchema)); //Assert.AreEqual(code, SchemaRegistryErrorCode.IncompatibleAvroSchema); var response2 = registry.Register(subject, FullyCompatibleSchema); var code = Assert.Throws <SchemaRegistryException>(() => registry.Register(subject, CompletelyIncompatibleSchema)); } }