Package org.apache.kafka.streams
Class TestInputTopic<K,V>
java.lang.Object
org.apache.kafka.streams.TestInputTopic<K,V>
- Type Parameters:
K
- the type of the record keyV
- the type of the record value
TestInputTopic
is used to pipe records to topic in TopologyTestDriver
.
To use TestInputTopic
create a new instance via
TopologyTestDriver.createInputTopic(String, Serializer, Serializer)
.
In actual test code, you can pipe new record values, keys and values or list of KeyValue
pairs.
If you have multiple source topics, you need to create a TestInputTopic
for each.
Processing messages
private TestInputTopic<Long, String> inputTopic;
...
inputTopic = testDriver.createInputTopic(INPUT_TOPIC, longSerializer, stringSerializer);
...
inputTopic.pipeInput("Hello");
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionvoid
advanceTime
(Duration advance) Advances the internally tracked event time of this input topic.void
Send an input record with the given key and value on the topic and then commit the records.void
Send an input record with the given key, value and timestamp on the topic and then commit the records.void
Send an input record with the given key, value and timestamp on the topic and then commit the records.void
pipeInput
(TestRecord<K, V> record) Send an input record with the given record on the topic and then commit the records.void
Send an input record with the given value on the topic and then commit the records.void
Send an input record with the given value and timestamp on the topic and then commit the records.void
pipeKeyValueList
(List<KeyValue<K, V>> keyValues) Send input records with the given KeyValue list on the topic then commit each record individually.void
Send input records with the givenKeyValue
list on the topic then commit each record individually.void
pipeRecordList
(List<? extends TestRecord<K, V>> records) Send input records with the given KeyValue list on the topic then commit each record individually.void
pipeValueList
(List<V> values) Send input records with the given value list on the topic then commit each record individually.void
pipeValueList
(List<V> values, Instant startTimestamp, Duration advance) Send input records with the given value list on the topic then commit each record individually.toString()
-
Method Details
-
advanceTime
Advances the internally tracked event time of this input topic. Each time a record without explicitly defined timestamp is piped, the current topic event time is used as record timestamp.Note: advancing the event time on the input topic, does not advance the tracked stream time in
TopologyTestDriver
as long as no new input records are piped. Furthermore, it does not advance the wall-clock time ofTopologyTestDriver
.- Parameters:
advance
- the duration of time to advance
-
pipeInput
Send an input record with the given record on the topic and then commit the records. May auto advance topic time.- Parameters:
record
- the record to sent
-
pipeInput
Send an input record with the given value on the topic and then commit the records. May auto advance topic time.- Parameters:
value
- the record value
-
pipeInput
Send an input record with the given key and value on the topic and then commit the records. May auto advance topic time- Parameters:
key
- the record keyvalue
- the record value
-
pipeInput
Send an input record with the given value and timestamp on the topic and then commit the records. Does not auto advance internally tracked time.- Parameters:
value
- the record valuetimestamp
- the record timestamp
-
pipeInput
Send an input record with the given key, value and timestamp on the topic and then commit the records. Does not auto advance internally tracked time.- Parameters:
key
- the record keyvalue
- the record valuetimestampMs
- the record timestamp
-
pipeInput
Send an input record with the given key, value and timestamp on the topic and then commit the records. Does not auto advance internally tracked time.- Parameters:
key
- the record keyvalue
- the record valuetimestamp
- the record timestamp
-
pipeRecordList
Send input records with the given KeyValue list on the topic then commit each record individually. The timestamp will be generated based on the constructor provided start time and time will auto advance.- Parameters:
records
- the list of TestRecord records
-
pipeKeyValueList
Send input records with the given KeyValue list on the topic then commit each record individually. The timestamp will be generated based on the constructor provided start time and time will auto advance based onautoAdvance
setting. -
pipeValueList
Send input records with the given value list on the topic then commit each record individually. The timestamp will be generated based on the constructor provided start time and time will auto advance based onautoAdvance
setting. -
pipeKeyValueList
public void pipeKeyValueList(List<KeyValue<K, V>> keyValues, Instant startTimestamp, Duration advance) Send input records with the givenKeyValue
list on the topic then commit each record individually. Does not auto advance internally tracked time. -
pipeValueList
Send input records with the given value list on the topic then commit each record individually. The timestamp will be generated based on the constructor provided start time and time will auto advance based onautoAdvance
setting.- Parameters:
values
- theList
of valuesstartTimestamp
- the timestamp for the first generated recordadvance
- the time difference between two consecutive generated records
-
toString
-