private Dictionary <TopicPartition, RecordQueue> GetPartitions() { var timestampEx = new FailOnInvalidTimestamp(); var partitions = new Dictionary <TopicPartition, RecordQueue>(); var sourceProcessor = new SourceProcessor <string, string>("source1", "test", serdes, serdes, timestampEx); var sourceProcessor2 = new SourceProcessor <string, string>("source2", "test2", serdes, serdes, timestampEx); var recordQueue = new RecordQueue("", "source_queue", timestampEx, topicPart1, sourceProcessor); var recordQueue2 = new RecordQueue("", "source2_queue", timestampEx, topicPart2, sourceProcessor2); partitions.Add(topicPart1, recordQueue); partitions.Add(topicPart2, recordQueue2); return(partitions); }
public void QueueOneMessageTest() { var timestampEx = new FailOnInvalidTimestamp(); var serdes = new StringSerDes(); var sourceProcessor = new SourceProcessor <string, string>("source", "test", serdes, serdes, timestampEx); var recordQueue = new RecordQueue("", "", timestampEx, new TopicPartition("test", 0), sourceProcessor); int size = recordQueue.Queue(new ConsumeResult <byte[], byte[]>() { Message = new Message <byte[], byte[]> { Key = serdes.Serialize("key", new SerializationContext()), Value = serdes.Serialize("test", new SerializationContext()) } }); Assert.AreEqual(1, size); }
public void QueueDequeueOneMessageTest() { var timestampEx = new FailOnInvalidTimestamp(); var serdes = new StringSerDes(); var sourceProcessor = new SourceProcessor <string, string>("source", "test", serdes, serdes, timestampEx); var recordQueue = new RecordQueue("", "", timestampEx, new TopicPartition("test", 0), sourceProcessor); recordQueue.Queue(new ConsumeResult <byte[], byte[]>() { Message = new Message <byte[], byte[]> { Key = serdes.Serialize("key", new SerializationContext()), Value = serdes.Serialize("test", new SerializationContext()) } }); var r = recordQueue.Poll(); Assert.IsNotNull(r); Assert.AreEqual("key", serdes.Deserialize(r.Message.Key, new SerializationContext())); Assert.AreEqual("test", serdes.Deserialize(r.Message.Value, new SerializationContext())); Assert.AreEqual(0, recordQueue.Size); Assert.IsTrue(recordQueue.IsEmpty); }