Search in sources :

Example 6 with MockSourceNode

use of org.apache.kafka.test.MockSourceNode in project kafka by apache.

the class SourceNodeTest method shouldProvideTopicHeadersAndDataToValueDeserializer.

@Test
public void shouldProvideTopicHeadersAndDataToValueDeserializer() {
    final SourceNode<String, String> sourceNode = new MockSourceNode<>(new TheDeserializer(), new TheDeserializer());
    final RecordHeaders headers = new RecordHeaders();
    final String deserializedValue = sourceNode.deserializeValue("topic", headers, "data".getBytes(StandardCharsets.UTF_8));
    assertThat(deserializedValue, is("topic" + headers + "data"));
}
Also used : RecordHeaders(org.apache.kafka.common.header.internals.RecordHeaders) MockSourceNode(org.apache.kafka.test.MockSourceNode) Test(org.junit.Test)

Example 7 with MockSourceNode

use of org.apache.kafka.test.MockSourceNode in project apache-kafka-on-k8s by banzaicloud.

the class SourceNodeTest method shouldProvideTopicHeadersAndDataToKeyDeserializer.

@Test
public void shouldProvideTopicHeadersAndDataToKeyDeserializer() {
    final SourceNode<String, String> sourceNode = new MockSourceNode<>(new String[] { "" }, new TheExtendedDeserializer(), new TheExtendedDeserializer());
    final RecordHeaders headers = new RecordHeaders();
    final String deserializeKey = sourceNode.deserializeKey("topic", headers, "data".getBytes(StandardCharsets.UTF_8));
    assertThat(deserializeKey, is("topic" + headers + "data"));
}
Also used : RecordHeaders(org.apache.kafka.common.header.internals.RecordHeaders) MockSourceNode(org.apache.kafka.test.MockSourceNode) Test(org.junit.Test)

Aggregations

MockSourceNode (org.apache.kafka.test.MockSourceNode)7 Test (org.junit.Test)6 RecordHeaders (org.apache.kafka.common.header.internals.RecordHeaders)4 ConsumerRecord (org.apache.kafka.clients.consumer.ConsumerRecord)2 MockProcessorNode (org.apache.kafka.test.MockProcessorNode)2 KafkaException (org.apache.kafka.common.KafkaException)1 Metric (org.apache.kafka.common.Metric)1 KafkaMetric (org.apache.kafka.common.metrics.KafkaMetric)1 MetricConfig (org.apache.kafka.common.metrics.MetricConfig)1 Metrics (org.apache.kafka.common.metrics.Metrics)1 MockTime (org.apache.kafka.common.utils.MockTime)1 StreamsException (org.apache.kafka.streams.errors.StreamsException)1 Record (org.apache.kafka.streams.processor.api.Record)1 OffsetCheckpoint (org.apache.kafka.streams.state.internals.OffsetCheckpoint)1