Example #1
0
        public void IncorrectConfigurationInterface()
        {
            var mockSchemaClient = new MockSchemaRegistryClient();
            var config           = new Mock <IStreamConfig>();
            var serdes           = new MockAvroSerDes(mockSchemaClient);

            Assert.Throws <StreamConfigException>(() => serdes.Initialize(new Net.SerDes.SerDesContext(config.Object)));
        }
Example #2
0
        public void DefaultSchemaRegistryConfig()
        {
            var mockSchemaClient = new MockSchemaRegistryClient();
            var config           = new StreamConfig();

            var serdes = new MockAvroSerDes(mockSchemaClient);

            serdes.Initialize(new Net.SerDes.SerDesContext(config));

            Assert.AreEqual(100, mockSchemaClient.MaxCachedSchemas);
            Assert.AreEqual(30000, mockSchemaClient.RequestTimeoutMs);
        }
Example #3
0
        public void SerializeOK()
        {
            var mockSchemaClient = new MockSchemaRegistryClient();
            var config           = new StreamConfig();
            var serdes           = new MockAvroSerDes(mockSchemaClient);

            serdes.Initialize(new Net.SerDes.SerDesContext(config));
            var person = new Person {
                age = 18, firstName = "TEST", lastName = "TEST"
            };
            var bytes = serdes.Serialize(person, new Confluent.Kafka.SerializationContext(Confluent.Kafka.MessageComponentType.Value, topic));

            Assert.IsNotNull(bytes);
            Assert.IsTrue(bytes.Length > 0);
        }
Example #4
0
        public void SchemaRegistryConfig()
        {
            var mockSchemaClient = new MockSchemaRegistryClient();
            var config           = new StreamConfig();

            config.AutoRegisterSchemas            = true;
            config.SchemaRegistryMaxCachedSchemas = 1;
            config.SchemaRegistryRequestTimeoutMs = 30;
            config.SubjectNameStrategy            = SubjectNameStrategy.TopicRecord;

            var serdes = new MockAvroSerDes(mockSchemaClient);

            serdes.Initialize(new Net.SerDes.SerDesContext(config));

            Assert.AreEqual(1, mockSchemaClient.MaxCachedSchemas);
            Assert.AreEqual(30, mockSchemaClient.RequestTimeoutMs);
        }
Example #5
0
        public void DeserializeOK()
        {
            var mockSchemaClient = new MockSchemaRegistryClient();
            var config           = new StreamConfig();
            var serdes           = new MockAvroSerDes(mockSchemaClient);

            serdes.Initialize(new Net.SerDes.SerDesContext(config));
            var person = new Person {
                age = 18, firstName = "TEST", lastName = "TEST"
            };
            var bytes = serdes.Serialize(person, new Confluent.Kafka.SerializationContext(Confluent.Kafka.MessageComponentType.Value, topic));
            var pbis  = serdes.Deserialize(bytes, new Confluent.Kafka.SerializationContext(Confluent.Kafka.MessageComponentType.Value, topic));

            Assert.AreEqual(18, pbis.age);
            Assert.AreEqual("TEST", pbis.firstName);
            Assert.AreEqual("TEST", pbis.lastName);
        }