| <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> |
| <!-- NewPage --> |
| <html lang="en"> |
| <head> |
| <!-- Generated by javadoc (9) on Wed Mar 28 12:13:01 BST 2018 --> |
| <title>TopologyTestDriver (kafka 1.1.0 API)</title> |
| <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> |
| <meta name="date" content="2018-03-28"> |
| <link rel="stylesheet" type="text/css" href="../../../../stylesheet.css" title="Style"> |
| <link rel="stylesheet" type="text/css" href="../../../../jquery/jquery-ui.css" title="Style"> |
| <script type="text/javascript" src="../../../../script.js"></script> |
| <script type="text/javascript" src="../../../../jquery/jszip/dist/jszip.min.js"></script> |
| <script type="text/javascript" src="../../../../jquery/jszip-utils/dist/jszip-utils.min.js"></script> |
| <!--[if IE]> |
| <script type="text/javascript" src="../../../../jquery/jszip-utils/dist/jszip-utils-ie.min.js"></script> |
| <![endif]--> |
| <script type="text/javascript" src="../../../../jquery/jquery-1.10.2.js"></script> |
| <script type="text/javascript" src="../../../../jquery/jquery-ui.js"></script> |
| </head> |
| <body> |
| <script type="text/javascript"><!-- |
| try { |
| if (location.href.indexOf('is-external=true') == -1) { |
| parent.document.title="TopologyTestDriver (kafka 1.1.0 API)"; |
| } |
| } |
| catch(err) { |
| } |
| //--> |
| var methods = {"i0":10,"i1":10,"i2":10,"i3":10,"i4":10,"i5":10,"i6":10,"i7":10,"i8":10,"i9":10,"i10":10}; |
| var tabs = {65535:["t0","All Methods"],2:["t2","Instance Methods"],8:["t4","Concrete Methods"]}; |
| var altColor = "altColor"; |
| var rowColor = "rowColor"; |
| var tableTab = "tableTab"; |
| var activeTableTab = "activeTableTab"; |
| var pathtoroot = "../../../../";loadScripts(document, 'script');</script> |
| <noscript> |
| <div>JavaScript is disabled on your browser.</div> |
| </noscript> |
| <div class="fixedNav"> |
| <!-- ========= START OF TOP NAVBAR ======= --> |
| <div class="topNav"><a name="navbar.top"> |
| <!-- --> |
| </a> |
| <div class="skipNav"><a href="#skip.navbar.top" title="Skip navigation links">Skip navigation links</a></div> |
| <a name="navbar.top.firstrow"> |
| <!-- --> |
| </a> |
| <ul class="navList" title="Navigation"> |
| <li><a href="../../../../overview-summary.html">Overview</a></li> |
| <li><a href="package-summary.html">Package</a></li> |
| <li class="navBarCell1Rev">Class</li> |
| <li><a href="package-tree.html">Tree</a></li> |
| <li><a href="../../../../deprecated-list.html">Deprecated</a></li> |
| <li><a href="../../../../index-all.html">Index</a></li> |
| <li><a href="../../../../help-doc.html">Help</a></li> |
| </ul> |
| </div> |
| <div class="subNav"> |
| <ul class="navList"> |
| <li><a href="../../../../org/apache/kafka/streams/TopologyDescription.Subtopology.html" title="interface in org.apache.kafka.streams"><span class="typeNameLink">Prev Class</span></a></li> |
| <li>Next Class</li> |
| </ul> |
| <ul class="navList"> |
| <li><a href="../../../../index.html?org/apache/kafka/streams/TopologyTestDriver.html" target="_top">Frames</a></li> |
| <li><a href="TopologyTestDriver.html" target="_top">No Frames</a></li> |
| </ul> |
| <ul class="navList" id="allclasses_navbar_top"> |
| <li><a href="../../../../allclasses-noframe.html">All Classes</a></li> |
| </ul> |
| <ul class="navListSearch"> |
| <li><span>SEARCH: </span> |
| <input type="text" id="search" value=" " disabled="disabled"> |
| <input type="reset" id="reset" value=" " disabled="disabled"> |
| </li> |
| </ul> |
| <div> |
| <script type="text/javascript"><!-- |
| allClassesLink = document.getElementById("allclasses_navbar_top"); |
| if(window==top) { |
| allClassesLink.style.display = "block"; |
| } |
| else { |
| allClassesLink.style.display = "none"; |
| } |
| //--> |
| </script> |
| <noscript> |
| <div>JavaScript is disabled on your browser.</div> |
| </noscript> |
| </div> |
| <div> |
| <ul class="subNavList"> |
| <li>Summary: </li> |
| <li>Nested | </li> |
| <li>Field | </li> |
| <li><a href="#constructor.summary">Constr</a> | </li> |
| <li><a href="#method.summary">Method</a></li> |
| </ul> |
| <ul class="subNavList"> |
| <li>Detail: </li> |
| <li>Field | </li> |
| <li><a href="#constructor.detail">Constr</a> | </li> |
| <li><a href="#method.detail">Method</a></li> |
| </ul> |
| </div> |
| <a name="skip.navbar.top"> |
| <!-- --> |
| </a></div> |
| <!-- ========= END OF TOP NAVBAR ========= --> |
| </div> |
| <div class="navPadding"> </div> |
| <script type="text/javascript"><!-- |
| $('.navPadding').css('padding-top', $('.fixedNav').css("height")); |
| //--> |
| </script> |
| <!-- ======== START OF CLASS DATA ======== --> |
| <div class="header"> |
| <div class="subTitle"><span class="packageLabelInType">Package</span> <a href="../../../../org/apache/kafka/streams/package-summary.html">org.apache.kafka.streams</a></div> |
| <h2 title="Class TopologyTestDriver" class="title">Class TopologyTestDriver</h2> |
| </div> |
| <div class="contentContainer"> |
| <ul class="inheritance"> |
| <li>java.lang.Object</li> |
| <li> |
| <ul class="inheritance"> |
| <li>org.apache.kafka.streams.TopologyTestDriver</li> |
| </ul> |
| </li> |
| </ul> |
| <div class="description"> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <hr> |
| <br> |
| <pre><a href="../../../../org/apache/kafka/common/annotation/InterfaceStability.Evolving.html" title="annotation in org.apache.kafka.common.annotation">@Evolving</a> |
| public class <span class="typeNameLabel">TopologyTestDriver</span> |
| extends java.lang.Object</pre> |
| <div class="block">This class makes it easier to write tests to verify the behavior of topologies created with <a href="../../../../org/apache/kafka/streams/Topology.html" title="class in org.apache.kafka.streams"><code>Topology</code></a> or |
| <a href="../../../../org/apache/kafka/streams/StreamsBuilder.html" title="class in org.apache.kafka.streams"><code>StreamsBuilder</code></a>. |
| You can test simple topologies that have a single processor, or very complex topologies that have multiple sources, |
| processors, sinks, or sub-topologies. |
| Best of all, the class works without a real Kafka broker, so the tests execute very quickly with very little overhead. |
| <p> |
| Using the <code>TopologyTestDriver</code> in tests is easy: simply instantiate the driver and provide a <a href="../../../../org/apache/kafka/streams/Topology.html" title="class in org.apache.kafka.streams"><code>Topology</code></a> |
| (cf. <a href="../../../../org/apache/kafka/streams/StreamsBuilder.html#build--"><code>StreamsBuilder.build()</code></a>) and <code>configs</code>, use the driver to supply an |
| input message to the topology, and then use the driver to read and verify any messages output by the topology. |
| <p> |
| Although the driver doesn't use a real Kafka broker, it does simulate Kafka <a href="../../../../org/apache/kafka/clients/consumer/Consumer.html" title="interface in org.apache.kafka.clients.consumer"><code>consumers</code></a> and |
| <a href="../../../../org/apache/kafka/clients/producer/Producer.html" title="interface in org.apache.kafka.clients.producer"><code>producers</code></a> that read and write raw <code>byte[]</code> messages. |
| You can either deal with messages that have <code>byte[]</code> keys and values or you use <a href="../../../../org/apache/kafka/streams/test/ConsumerRecordFactory.html" title="class in org.apache.kafka.streams.test"><code>ConsumerRecordFactory</code></a> |
| and <a href="../../../../org/apache/kafka/streams/test/OutputVerifier.html" title="class in org.apache.kafka.streams.test"><code>OutputVerifier</code></a> that work with regular Java objects instead of raw bytes. |
| |
| <h2>Driver setup</h2> |
| In order to create a <code>TopologyTestDriver</code> instance, you need a <a href="../../../../org/apache/kafka/streams/Topology.html" title="class in org.apache.kafka.streams"><code>Topology</code></a> and a <code>config</code>. |
| The configuration needs to be representative of what you'd supply to the real topology, so that means including |
| several key properties (cf. <a href="../../../../org/apache/kafka/streams/StreamsConfig.html" title="class in org.apache.kafka.streams"><code>StreamsConfig</code></a>). |
| For example, the following code fragment creates a configuration that specifies a local Kafka broker list (which is |
| needed but not used), a timestamp extractor, and default serializers and deserializers for string keys and values: |
| |
| <pre><code> |
| Properties props = new Properties(); |
| props.setProperty(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "localhost:9091"); |
| props.setProperty(StreamsConfig.DEFAULT_TIMESTAMP_EXTRACTOR_CLASS_CONFIG, CustomTimestampExtractor.class.getName()); |
| props.setProperty(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.String().getClass().getName()); |
| props.setProperty(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, Serdes.String().getClass().getName()); |
| Topology topology = ... |
| TopologyTestDriver driver = new TopologyTestDriver(topology, props); |
| </code></pre> |
| |
| <h2>Processing messages</h2> |
| <p> |
| Your test can supply new input records on any of the topics that the topology's sources consume. |
| This test driver simulates single-partitioned input topics. |
| Here's an example of an input message on the topic named <code>input-topic</code>: |
| |
| <pre> |
| ConsumerRecordFactory factory = new ConsumerRecordFactory(strSerializer, strSerializer); |
| driver.pipeInput(factory.create("input-topic","key1", "value1")); |
| </pre> |
| |
| When <code>#pipeInput()</code> is called, the driver passes the input message through to the appropriate source that |
| consumes the named topic, and will invoke the processor(s) downstream of the source. |
| If your topology's processors forward messages to sinks, your test can then consume these output messages to verify |
| they match the expected outcome. |
| For example, if our topology should have generated 2 messages on <code>output-topic-1</code> and 1 message on |
| <code>output-topic-2</code>, then our test can obtain these messages using the |
| <a href="../../../../org/apache/kafka/streams/TopologyTestDriver.html#readOutput-java.lang.String-org.apache.kafka.common.serialization.Deserializer-org.apache.kafka.common.serialization.Deserializer-"><code>readOutput(String, Deserializer, Deserializer)</code></a> method: |
| |
| <pre><code> |
| ProducerRecord<String, String> record1 = driver.readOutput("output-topic-1", strDeserializer, strDeserializer); |
| ProducerRecord<String, String> record2 = driver.readOutput("output-topic-1", strDeserializer, strDeserializer); |
| ProducerRecord<String, String> record3 = driver.readOutput("output-topic-2", strDeserializer, strDeserializer); |
| </code></pre> |
| |
| Again, our example topology generates messages with string keys and values, so we supply our string deserializer |
| instance for use on both the keys and values. Your test logic can then verify whether these output records are |
| correct. |
| Note, that calling <a href="../../../../org/apache/kafka/clients/producer/ProducerRecord.html#equals-java.lang.Object-"><code>ProducerRecord.equals(Object)</code></a> compares all attributes including key, value, timestamp, |
| topic, partition, and headers. |
| If you only want to compare key and value (and maybe timestamp), using <a href="../../../../org/apache/kafka/streams/test/OutputVerifier.html" title="class in org.apache.kafka.streams.test"><code>OutputVerifier</code></a> instead of |
| <a href="../../../../org/apache/kafka/clients/producer/ProducerRecord.html#equals-java.lang.Object-"><code>ProducerRecord.equals(Object)</code></a> can simplify your code as you can ignore attributes you are not interested in. |
| <p> |
| Note, that calling <code>pipeInput()</code> will also trigger <a href="../../../../org/apache/kafka/streams/processor/PunctuationType.html#STREAM_TIME"><code>event-time</code></a> base |
| <a href="../../../../org/apache/kafka/streams/processor/ProcessorContext.html#schedule-long-org.apache.kafka.streams.processor.PunctuationType-org.apache.kafka.streams.processor.Punctuator-"><code>punctuation</code></a> callbacks. |
| However, you won't trigger <a href="../../../../org/apache/kafka/streams/processor/PunctuationType.html#WALL_CLOCK_TIME"><code>wall-clock</code></a> type punctuations that you must |
| trigger manually via <a href="../../../../org/apache/kafka/streams/TopologyTestDriver.html#advanceWallClockTime-long-"><code>advanceWallClockTime(long)</code></a>. |
| <p> |
| Finally, when completed, make sure your tests <a href="../../../../org/apache/kafka/streams/TopologyTestDriver.html#close--"><code>close()</code></a> the driver to release all resources and |
| <a href="../../../../org/apache/kafka/streams/processor/Processor.html" title="interface in org.apache.kafka.streams.processor"><code>processors</code></a>. |
| |
| <h2>Processor state</h2> |
| <p> |
| Some processors use Kafka <a href="../../../../org/apache/kafka/streams/processor/StateStore.html" title="interface in org.apache.kafka.streams.processor"><code>state storage</code></a>, so this driver class provides the generic |
| <a href="../../../../org/apache/kafka/streams/TopologyTestDriver.html#getStateStore-java.lang.String-"><code>getStateStore(String)</code></a> as well as store-type specific methods so that your tests can check the underlying |
| state store(s) used by your topology's processors. |
| In our previous example, after we supplied a single input message and checked the three output messages, our test |
| could also check the key value store to verify the processor correctly added, removed, or updated internal state. |
| Or, our test might have pre-populated some state <em>before</em> submitting the input message, and verified afterward |
| that the processor(s) correctly updated the state.</div> |
| <dl> |
| <dt><span class="seeLabel">See Also:</span></dt> |
| <dd><a href="../../../../org/apache/kafka/streams/test/ConsumerRecordFactory.html" title="class in org.apache.kafka.streams.test"><code>ConsumerRecordFactory</code></a>, |
| <a href="../../../../org/apache/kafka/streams/test/OutputVerifier.html" title="class in org.apache.kafka.streams.test"><code>OutputVerifier</code></a></dd> |
| </dl> |
| </li> |
| </ul> |
| </div> |
| <div class="summary"> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <!-- ======== CONSTRUCTOR SUMMARY ======== --> |
| <ul class="blockList"> |
| <li class="blockList"><a name="constructor.summary"> |
| <!-- --> |
| </a> |
| <h3>Constructor Summary</h3> |
| <table class="memberSummary" summary="Constructor Summary table, listing constructors, and an explanation"> |
| <caption><span>Constructors</span><span class="tabEnd"> </span></caption> |
| <tr> |
| <th class="colFirst" scope="col">Constructor</th> |
| <th class="colLast" scope="col">Description</th> |
| </tr> |
| <tr class="altColor"> |
| <th class="colConstructorName" scope="row"><code><span class="memberNameLink"><a href="../../../../org/apache/kafka/streams/TopologyTestDriver.html#TopologyTestDriver-org.apache.kafka.streams.Topology-java.util.Properties-">TopologyTestDriver</a></span>​(<a href="../../../../org/apache/kafka/streams/Topology.html" title="class in org.apache.kafka.streams">Topology</a> topology, |
| java.util.Properties config)</code></th> |
| <td class="colLast"> |
| <div class="block">Create a new test diver instance.</div> |
| </td> |
| </tr> |
| <tr class="rowColor"> |
| <th class="colConstructorName" scope="row"><code><span class="memberNameLink"><a href="../../../../org/apache/kafka/streams/TopologyTestDriver.html#TopologyTestDriver-org.apache.kafka.streams.Topology-java.util.Properties-long-">TopologyTestDriver</a></span>​(<a href="../../../../org/apache/kafka/streams/Topology.html" title="class in org.apache.kafka.streams">Topology</a> topology, |
| java.util.Properties config, |
| long initialWallClockTimeMs)</code></th> |
| <td class="colLast"> |
| <div class="block">Create a new test diver instance.</div> |
| </td> |
| </tr> |
| </table> |
| </li> |
| </ul> |
| <!-- ========== METHOD SUMMARY =========== --> |
| <ul class="blockList"> |
| <li class="blockList"><a name="method.summary"> |
| <!-- --> |
| </a> |
| <h3>Method Summary</h3> |
| <table class="memberSummary" summary="Method Summary table, listing methods, and an explanation"> |
| <caption><span id="t0" class="activeTableTab"><span>All Methods</span><span class="tabEnd"> </span></span><span id="t2" class="tableTab"><span><a href="javascript:show(2);">Instance Methods</a></span><span class="tabEnd"> </span></span><span id="t4" class="tableTab"><span><a href="javascript:show(8);">Concrete Methods</a></span><span class="tabEnd"> </span></span></caption> |
| <tr> |
| <th class="colFirst" scope="col">Modifier and Type</th> |
| <th class="colSecond" scope="col">Method</th> |
| <th class="colLast" scope="col">Description</th> |
| </tr> |
| <tr id="i0" class="altColor"> |
| <td class="colFirst"><code>void</code></td> |
| <th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="../../../../org/apache/kafka/streams/TopologyTestDriver.html#advanceWallClockTime-long-">advanceWallClockTime</a></span>​(long advanceMs)</code></th> |
| <td class="colLast"> |
| <div class="block">Advances the internally mocked wall-clock time.</div> |
| </td> |
| </tr> |
| <tr id="i1" class="rowColor"> |
| <td class="colFirst"><code>void</code></td> |
| <th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="../../../../org/apache/kafka/streams/TopologyTestDriver.html#close--">close</a></span>​()</code></th> |
| <td class="colLast"> |
| <div class="block">Close the driver, its topology, and all processors.</div> |
| </td> |
| </tr> |
| <tr id="i2" class="altColor"> |
| <td class="colFirst"><code>java.util.Map<java.lang.String,<a href="../../../../org/apache/kafka/streams/processor/StateStore.html" title="interface in org.apache.kafka.streams.processor">StateStore</a>></code></td> |
| <th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="../../../../org/apache/kafka/streams/TopologyTestDriver.html#getAllStateStores--">getAllStateStores</a></span>​()</code></th> |
| <td class="colLast"> |
| <div class="block">Get all <a href="../../../../org/apache/kafka/streams/processor/StateStore.html" title="interface in org.apache.kafka.streams.processor"><code>StateStores</code></a> from the topology.</div> |
| </td> |
| </tr> |
| <tr id="i3" class="rowColor"> |
| <td class="colFirst"><code><K,V> <a href="../../../../org/apache/kafka/streams/state/KeyValueStore.html" title="interface in org.apache.kafka.streams.state">KeyValueStore</a><K,V></code></td> |
| <th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="../../../../org/apache/kafka/streams/TopologyTestDriver.html#getKeyValueStore-java.lang.String-">getKeyValueStore</a></span>​(java.lang.String name)</code></th> |
| <td class="colLast"> |
| <div class="block">Get the <a href="../../../../org/apache/kafka/streams/state/KeyValueStore.html" title="interface in org.apache.kafka.streams.state"><code>KeyValueStore</code></a> with the given name.</div> |
| </td> |
| </tr> |
| <tr id="i4" class="altColor"> |
| <td class="colFirst"><code><K,V> <a href="../../../../org/apache/kafka/streams/state/SessionStore.html" title="interface in org.apache.kafka.streams.state">SessionStore</a><K,V></code></td> |
| <th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="../../../../org/apache/kafka/streams/TopologyTestDriver.html#getSessionStore-java.lang.String-">getSessionStore</a></span>​(java.lang.String name)</code></th> |
| <td class="colLast"> |
| <div class="block">Get the <a href="../../../../org/apache/kafka/streams/state/SessionStore.html" title="interface in org.apache.kafka.streams.state"><code>SessionStore</code></a> with the given name.</div> |
| </td> |
| </tr> |
| <tr id="i5" class="rowColor"> |
| <td class="colFirst"><code><a href="../../../../org/apache/kafka/streams/processor/StateStore.html" title="interface in org.apache.kafka.streams.processor">StateStore</a></code></td> |
| <th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="../../../../org/apache/kafka/streams/TopologyTestDriver.html#getStateStore-java.lang.String-">getStateStore</a></span>​(java.lang.String name)</code></th> |
| <td class="colLast"> |
| <div class="block">Get the <a href="../../../../org/apache/kafka/streams/processor/StateStore.html" title="interface in org.apache.kafka.streams.processor"><code>StateStore</code></a> with the given name.</div> |
| </td> |
| </tr> |
| <tr id="i6" class="altColor"> |
| <td class="colFirst"><code><K,V> <a href="../../../../org/apache/kafka/streams/state/WindowStore.html" title="interface in org.apache.kafka.streams.state">WindowStore</a><K,V></code></td> |
| <th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="../../../../org/apache/kafka/streams/TopologyTestDriver.html#getWindowStore-java.lang.String-">getWindowStore</a></span>​(java.lang.String name)</code></th> |
| <td class="colLast"> |
| <div class="block">Get the <a href="../../../../org/apache/kafka/streams/state/WindowStore.html" title="interface in org.apache.kafka.streams.state"><code>WindowStore</code></a> with the given name.</div> |
| </td> |
| </tr> |
| <tr id="i7" class="rowColor"> |
| <td class="colFirst"><code>void</code></td> |
| <th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="../../../../org/apache/kafka/streams/TopologyTestDriver.html#pipeInput-java.util.List-">pipeInput</a></span>​(java.util.List<<a href="../../../../org/apache/kafka/clients/consumer/ConsumerRecord.html" title="class in org.apache.kafka.clients.consumer">ConsumerRecord</a><byte[],byte[]>> records)</code></th> |
| <td class="colLast"> |
| <div class="block">Send input messages to the topology and then commit each message individually.</div> |
| </td> |
| </tr> |
| <tr id="i8" class="altColor"> |
| <td class="colFirst"><code>void</code></td> |
| <th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="../../../../org/apache/kafka/streams/TopologyTestDriver.html#pipeInput-org.apache.kafka.clients.consumer.ConsumerRecord-">pipeInput</a></span>​(<a href="../../../../org/apache/kafka/clients/consumer/ConsumerRecord.html" title="class in org.apache.kafka.clients.consumer">ConsumerRecord</a><byte[],byte[]> consumerRecord)</code></th> |
| <td class="colLast"> |
| <div class="block">Send an input message with the given key, value, and timestamp on the specified topic to the topology and then |
| commit the messages.</div> |
| </td> |
| </tr> |
| <tr id="i9" class="rowColor"> |
| <td class="colFirst"><code><a href="../../../../org/apache/kafka/clients/producer/ProducerRecord.html" title="class in org.apache.kafka.clients.producer">ProducerRecord</a><byte[],byte[]></code></td> |
| <th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="../../../../org/apache/kafka/streams/TopologyTestDriver.html#readOutput-java.lang.String-">readOutput</a></span>​(java.lang.String topic)</code></th> |
| <td class="colLast"> |
| <div class="block">Read the next record from the given topic.</div> |
| </td> |
| </tr> |
| <tr id="i10" class="altColor"> |
| <td class="colFirst"><code><K,V> <a href="../../../../org/apache/kafka/clients/producer/ProducerRecord.html" title="class in org.apache.kafka.clients.producer">ProducerRecord</a><K,V></code></td> |
| <th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="../../../../org/apache/kafka/streams/TopologyTestDriver.html#readOutput-java.lang.String-org.apache.kafka.common.serialization.Deserializer-org.apache.kafka.common.serialization.Deserializer-">readOutput</a></span>​(java.lang.String topic, |
| <a href="../../../../org/apache/kafka/common/serialization/Deserializer.html" title="interface in org.apache.kafka.common.serialization">Deserializer</a><K> keyDeserializer, |
| <a href="../../../../org/apache/kafka/common/serialization/Deserializer.html" title="interface in org.apache.kafka.common.serialization">Deserializer</a><V> valueDeserializer)</code></th> |
| <td class="colLast"> |
| <div class="block">Read the next record from the given topic.</div> |
| </td> |
| </tr> |
| </table> |
| <ul class="blockList"> |
| <li class="blockList"><a name="methods.inherited.from.class.java.lang.Object"> |
| <!-- --> |
| </a> |
| <h3>Methods inherited from class java.lang.Object</h3> |
| <code>clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait</code></li> |
| </ul> |
| </li> |
| </ul> |
| </li> |
| </ul> |
| </div> |
| <div class="details"> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <!-- ========= CONSTRUCTOR DETAIL ======== --> |
| <ul class="blockList"> |
| <li class="blockList"><a name="constructor.detail"> |
| <!-- --> |
| </a> |
| <h3>Constructor Detail</h3> |
| <a name="TopologyTestDriver-org.apache.kafka.streams.Topology-java.util.Properties-"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>TopologyTestDriver</h4> |
| <pre>public TopologyTestDriver​(<a href="../../../../org/apache/kafka/streams/Topology.html" title="class in org.apache.kafka.streams">Topology</a> topology, |
| java.util.Properties config)</pre> |
| <div class="block">Create a new test diver instance. |
| Initialized the internally mocked wall-clock time with <code>current system time</code>.</div> |
| <dl> |
| <dt><span class="paramLabel">Parameters:</span></dt> |
| <dd><code>topology</code> - the topology to be tested</dd> |
| <dd><code>config</code> - the configuration for the topology</dd> |
| </dl> |
| </li> |
| </ul> |
| <a name="TopologyTestDriver-org.apache.kafka.streams.Topology-java.util.Properties-long-"> |
| <!-- --> |
| </a> |
| <ul class="blockListLast"> |
| <li class="blockList"> |
| <h4>TopologyTestDriver</h4> |
| <pre>public TopologyTestDriver​(<a href="../../../../org/apache/kafka/streams/Topology.html" title="class in org.apache.kafka.streams">Topology</a> topology, |
| java.util.Properties config, |
| long initialWallClockTimeMs)</pre> |
| <div class="block">Create a new test diver instance.</div> |
| <dl> |
| <dt><span class="paramLabel">Parameters:</span></dt> |
| <dd><code>topology</code> - the topology to be tested</dd> |
| <dd><code>config</code> - the configuration for the topology</dd> |
| <dd><code>initialWallClockTimeMs</code> - the initial value of internally mocked wall-clock time</dd> |
| </dl> |
| </li> |
| </ul> |
| </li> |
| </ul> |
| <!-- ============ METHOD DETAIL ========== --> |
| <ul class="blockList"> |
| <li class="blockList"><a name="method.detail"> |
| <!-- --> |
| </a> |
| <h3>Method Detail</h3> |
| <a name="pipeInput-org.apache.kafka.clients.consumer.ConsumerRecord-"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>pipeInput</h4> |
| <pre>public void pipeInput​(<a href="../../../../org/apache/kafka/clients/consumer/ConsumerRecord.html" title="class in org.apache.kafka.clients.consumer">ConsumerRecord</a><byte[],byte[]> consumerRecord)</pre> |
| <div class="block">Send an input message with the given key, value, and timestamp on the specified topic to the topology and then |
| commit the messages.</div> |
| <dl> |
| <dt><span class="paramLabel">Parameters:</span></dt> |
| <dd><code>consumerRecord</code> - the record to be processed</dd> |
| </dl> |
| </li> |
| </ul> |
| <a name="pipeInput-java.util.List-"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>pipeInput</h4> |
| <pre>public void pipeInput​(java.util.List<<a href="../../../../org/apache/kafka/clients/consumer/ConsumerRecord.html" title="class in org.apache.kafka.clients.consumer">ConsumerRecord</a><byte[],byte[]>> records)</pre> |
| <div class="block">Send input messages to the topology and then commit each message individually.</div> |
| <dl> |
| <dt><span class="paramLabel">Parameters:</span></dt> |
| <dd><code>records</code> - a list of records to be processed</dd> |
| </dl> |
| </li> |
| </ul> |
| <a name="advanceWallClockTime-long-"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>advanceWallClockTime</h4> |
| <pre>public void advanceWallClockTime​(long advanceMs)</pre> |
| <div class="block">Advances the internally mocked wall-clock time. |
| This might trigger a <a href="../../../../org/apache/kafka/streams/processor/PunctuationType.html#WALL_CLOCK_TIME"><code>wall-clock</code></a> type |
| <a href="../../../../org/apache/kafka/streams/processor/ProcessorContext.html#schedule-long-org.apache.kafka.streams.processor.PunctuationType-org.apache.kafka.streams.processor.Punctuator-"><code>punctuations</code></a>.</div> |
| <dl> |
| <dt><span class="paramLabel">Parameters:</span></dt> |
| <dd><code>advanceMs</code> - the amount of time to advance wall-clock time in milliseconds</dd> |
| </dl> |
| </li> |
| </ul> |
| <a name="readOutput-java.lang.String-"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>readOutput</h4> |
| <pre>public <a href="../../../../org/apache/kafka/clients/producer/ProducerRecord.html" title="class in org.apache.kafka.clients.producer">ProducerRecord</a><byte[],byte[]> readOutput​(java.lang.String topic)</pre> |
| <div class="block">Read the next record from the given topic. |
| These records were output by the topology during the previous calls to <a href="../../../../org/apache/kafka/streams/TopologyTestDriver.html#pipeInput-org.apache.kafka.clients.consumer.ConsumerRecord-"><code>pipeInput(ConsumerRecord)</code></a>.</div> |
| <dl> |
| <dt><span class="paramLabel">Parameters:</span></dt> |
| <dd><code>topic</code> - the name of the topic</dd> |
| <dt><span class="returnLabel">Returns:</span></dt> |
| <dd>the next record on that topic, or <code>null</code> if there is no record available</dd> |
| </dl> |
| </li> |
| </ul> |
| <a name="readOutput-java.lang.String-org.apache.kafka.common.serialization.Deserializer-org.apache.kafka.common.serialization.Deserializer-"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>readOutput</h4> |
| <pre>public <K,V> <a href="../../../../org/apache/kafka/clients/producer/ProducerRecord.html" title="class in org.apache.kafka.clients.producer">ProducerRecord</a><K,V> readOutput​(java.lang.String topic, |
| <a href="../../../../org/apache/kafka/common/serialization/Deserializer.html" title="interface in org.apache.kafka.common.serialization">Deserializer</a><K> keyDeserializer, |
| <a href="../../../../org/apache/kafka/common/serialization/Deserializer.html" title="interface in org.apache.kafka.common.serialization">Deserializer</a><V> valueDeserializer)</pre> |
| <div class="block">Read the next record from the given topic. |
| These records were output by the topology during the previous calls to <a href="../../../../org/apache/kafka/streams/TopologyTestDriver.html#pipeInput-org.apache.kafka.clients.consumer.ConsumerRecord-"><code>pipeInput(ConsumerRecord)</code></a>.</div> |
| <dl> |
| <dt><span class="paramLabel">Parameters:</span></dt> |
| <dd><code>topic</code> - the name of the topic</dd> |
| <dd><code>keyDeserializer</code> - the deserializer for the key type</dd> |
| <dd><code>valueDeserializer</code> - the deserializer for the value type</dd> |
| <dt><span class="returnLabel">Returns:</span></dt> |
| <dd>the next record on that topic, or <code>null</code> if there is no record available</dd> |
| </dl> |
| </li> |
| </ul> |
| <a name="getAllStateStores--"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>getAllStateStores</h4> |
| <pre>public java.util.Map<java.lang.String,<a href="../../../../org/apache/kafka/streams/processor/StateStore.html" title="interface in org.apache.kafka.streams.processor">StateStore</a>> getAllStateStores​()</pre> |
| <div class="block">Get all <a href="../../../../org/apache/kafka/streams/processor/StateStore.html" title="interface in org.apache.kafka.streams.processor"><code>StateStores</code></a> from the topology. |
| The stores can be a "regular" or global stores. |
| <p> |
| This is often useful in test cases to pre-populate the store before the test case instructs the topology to |
| <a href="../../../../org/apache/kafka/streams/TopologyTestDriver.html#pipeInput-org.apache.kafka.clients.consumer.ConsumerRecord-"><code>process an input message</code></a>, and/or to check the store afterward.</div> |
| <dl> |
| <dt><span class="returnLabel">Returns:</span></dt> |
| <dd>all stores my name</dd> |
| <dt><span class="seeLabel">See Also:</span></dt> |
| <dd><a href="../../../../org/apache/kafka/streams/TopologyTestDriver.html#getStateStore-java.lang.String-"><code>getStateStore(String)</code></a>, |
| <a href="../../../../org/apache/kafka/streams/TopologyTestDriver.html#getKeyValueStore-java.lang.String-"><code>getKeyValueStore(String)</code></a>, |
| <a href="../../../../org/apache/kafka/streams/TopologyTestDriver.html#getWindowStore-java.lang.String-"><code>getWindowStore(String)</code></a>, |
| <a href="../../../../org/apache/kafka/streams/TopologyTestDriver.html#getSessionStore-java.lang.String-"><code>getSessionStore(String)</code></a></dd> |
| </dl> |
| </li> |
| </ul> |
| <a name="getStateStore-java.lang.String-"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>getStateStore</h4> |
| <pre>public <a href="../../../../org/apache/kafka/streams/processor/StateStore.html" title="interface in org.apache.kafka.streams.processor">StateStore</a> getStateStore​(java.lang.String name)</pre> |
| <div class="block">Get the <a href="../../../../org/apache/kafka/streams/processor/StateStore.html" title="interface in org.apache.kafka.streams.processor"><code>StateStore</code></a> with the given name. |
| The store can be a "regular" or global store. |
| <p> |
| This is often useful in test cases to pre-populate the store before the test case instructs the topology to |
| <a href="../../../../org/apache/kafka/streams/TopologyTestDriver.html#pipeInput-org.apache.kafka.clients.consumer.ConsumerRecord-"><code>process an input message</code></a>, and/or to check the store afterward.</div> |
| <dl> |
| <dt><span class="paramLabel">Parameters:</span></dt> |
| <dd><code>name</code> - the name of the store</dd> |
| <dt><span class="returnLabel">Returns:</span></dt> |
| <dd>the state store, or <code>null</code> if no store has been registered with the given name</dd> |
| <dt><span class="seeLabel">See Also:</span></dt> |
| <dd><a href="../../../../org/apache/kafka/streams/TopologyTestDriver.html#getAllStateStores--"><code>getAllStateStores()</code></a>, |
| <a href="../../../../org/apache/kafka/streams/TopologyTestDriver.html#getKeyValueStore-java.lang.String-"><code>getKeyValueStore(String)</code></a>, |
| <a href="../../../../org/apache/kafka/streams/TopologyTestDriver.html#getWindowStore-java.lang.String-"><code>getWindowStore(String)</code></a>, |
| <a href="../../../../org/apache/kafka/streams/TopologyTestDriver.html#getSessionStore-java.lang.String-"><code>getSessionStore(String)</code></a></dd> |
| </dl> |
| </li> |
| </ul> |
| <a name="getKeyValueStore-java.lang.String-"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>getKeyValueStore</h4> |
| <pre>public <K,V> <a href="../../../../org/apache/kafka/streams/state/KeyValueStore.html" title="interface in org.apache.kafka.streams.state">KeyValueStore</a><K,V> getKeyValueStore​(java.lang.String name)</pre> |
| <div class="block">Get the <a href="../../../../org/apache/kafka/streams/state/KeyValueStore.html" title="interface in org.apache.kafka.streams.state"><code>KeyValueStore</code></a> with the given name. |
| The store can be a "regular" or global store. |
| <p> |
| This is often useful in test cases to pre-populate the store before the test case instructs the topology to |
| <a href="../../../../org/apache/kafka/streams/TopologyTestDriver.html#pipeInput-org.apache.kafka.clients.consumer.ConsumerRecord-"><code>process an input message</code></a>, and/or to check the store afterward.</div> |
| <dl> |
| <dt><span class="paramLabel">Parameters:</span></dt> |
| <dd><code>name</code> - the name of the store</dd> |
| <dt><span class="returnLabel">Returns:</span></dt> |
| <dd>the key value store, or <code>null</code> if no <a href="../../../../org/apache/kafka/streams/state/KeyValueStore.html" title="interface in org.apache.kafka.streams.state"><code>KeyValueStore</code></a> has been registered with the given name</dd> |
| <dt><span class="seeLabel">See Also:</span></dt> |
| <dd><a href="../../../../org/apache/kafka/streams/TopologyTestDriver.html#getAllStateStores--"><code>getAllStateStores()</code></a>, |
| <a href="../../../../org/apache/kafka/streams/TopologyTestDriver.html#getStateStore-java.lang.String-"><code>getStateStore(String)</code></a>, |
| <a href="../../../../org/apache/kafka/streams/TopologyTestDriver.html#getWindowStore-java.lang.String-"><code>getWindowStore(String)</code></a>, |
| <a href="../../../../org/apache/kafka/streams/TopologyTestDriver.html#getSessionStore-java.lang.String-"><code>getSessionStore(String)</code></a></dd> |
| </dl> |
| </li> |
| </ul> |
| <a name="getWindowStore-java.lang.String-"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>getWindowStore</h4> |
| <pre>public <K,V> <a href="../../../../org/apache/kafka/streams/state/WindowStore.html" title="interface in org.apache.kafka.streams.state">WindowStore</a><K,V> getWindowStore​(java.lang.String name)</pre> |
| <div class="block">Get the <a href="../../../../org/apache/kafka/streams/state/WindowStore.html" title="interface in org.apache.kafka.streams.state"><code>WindowStore</code></a> with the given name. |
| The store can be a "regular" or global store. |
| <p> |
| This is often useful in test cases to pre-populate the store before the test case instructs the topology to |
| <a href="../../../../org/apache/kafka/streams/TopologyTestDriver.html#pipeInput-org.apache.kafka.clients.consumer.ConsumerRecord-"><code>process an input message</code></a>, and/or to check the store afterward.</div> |
| <dl> |
| <dt><span class="paramLabel">Parameters:</span></dt> |
| <dd><code>name</code> - the name of the store</dd> |
| <dt><span class="returnLabel">Returns:</span></dt> |
| <dd>the key value store, or <code>null</code> if no <a href="../../../../org/apache/kafka/streams/state/WindowStore.html" title="interface in org.apache.kafka.streams.state"><code>WindowStore</code></a> has been registered with the given name</dd> |
| <dt><span class="seeLabel">See Also:</span></dt> |
| <dd><a href="../../../../org/apache/kafka/streams/TopologyTestDriver.html#getAllStateStores--"><code>getAllStateStores()</code></a>, |
| <a href="../../../../org/apache/kafka/streams/TopologyTestDriver.html#getStateStore-java.lang.String-"><code>getStateStore(String)</code></a>, |
| <a href="../../../../org/apache/kafka/streams/TopologyTestDriver.html#getKeyValueStore-java.lang.String-"><code>getKeyValueStore(String)</code></a>, |
| <a href="../../../../org/apache/kafka/streams/TopologyTestDriver.html#getSessionStore-java.lang.String-"><code>(String)</code></a></dd> |
| </dl> |
| </li> |
| </ul> |
| <a name="getSessionStore-java.lang.String-"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>getSessionStore</h4> |
| <pre>public <K,V> <a href="../../../../org/apache/kafka/streams/state/SessionStore.html" title="interface in org.apache.kafka.streams.state">SessionStore</a><K,V> getSessionStore​(java.lang.String name)</pre> |
| <div class="block">Get the <a href="../../../../org/apache/kafka/streams/state/SessionStore.html" title="interface in org.apache.kafka.streams.state"><code>SessionStore</code></a> with the given name. |
| The store can be a "regular" or global store. |
| <p> |
| This is often useful in test cases to pre-populate the store before the test case instructs the topology to |
| <a href="../../../../org/apache/kafka/streams/TopologyTestDriver.html#pipeInput-org.apache.kafka.clients.consumer.ConsumerRecord-"><code>process an input message</code></a>, and/or to check the store afterward.</div> |
| <dl> |
| <dt><span class="paramLabel">Parameters:</span></dt> |
| <dd><code>name</code> - the name of the store</dd> |
| <dt><span class="returnLabel">Returns:</span></dt> |
| <dd>the key value store, or <code>null</code> if no <a href="../../../../org/apache/kafka/streams/state/SessionStore.html" title="interface in org.apache.kafka.streams.state"><code>SessionStore</code></a> has been registered with the given name</dd> |
| <dt><span class="seeLabel">See Also:</span></dt> |
| <dd><a href="../../../../org/apache/kafka/streams/TopologyTestDriver.html#getAllStateStores--"><code>getAllStateStores()</code></a>, |
| <a href="../../../../org/apache/kafka/streams/TopologyTestDriver.html#getStateStore-java.lang.String-"><code>getStateStore(String)</code></a>, |
| <a href="../../../../org/apache/kafka/streams/TopologyTestDriver.html#getKeyValueStore-java.lang.String-"><code>getKeyValueStore(String)</code></a>, |
| <a href="../../../../org/apache/kafka/streams/TopologyTestDriver.html#getWindowStore-java.lang.String-"><code>getWindowStore(String)</code></a></dd> |
| </dl> |
| </li> |
| </ul> |
| <a name="close--"> |
| <!-- --> |
| </a> |
| <ul class="blockListLast"> |
| <li class="blockList"> |
| <h4>close</h4> |
| <pre>public void close​()</pre> |
| <div class="block">Close the driver, its topology, and all processors.</div> |
| </li> |
| </ul> |
| </li> |
| </ul> |
| </li> |
| </ul> |
| </div> |
| </div> |
| <!-- ========= END OF CLASS DATA ========= --> |
| <!-- ======= START OF BOTTOM NAVBAR ====== --> |
| <div class="bottomNav"><a name="navbar.bottom"> |
| <!-- --> |
| </a> |
| <div class="skipNav"><a href="#skip.navbar.bottom" title="Skip navigation links">Skip navigation links</a></div> |
| <a name="navbar.bottom.firstrow"> |
| <!-- --> |
| </a> |
| <ul class="navList" title="Navigation"> |
| <li><a href="../../../../overview-summary.html">Overview</a></li> |
| <li><a href="package-summary.html">Package</a></li> |
| <li class="navBarCell1Rev">Class</li> |
| <li><a href="package-tree.html">Tree</a></li> |
| <li><a href="../../../../deprecated-list.html">Deprecated</a></li> |
| <li><a href="../../../../index-all.html">Index</a></li> |
| <li><a href="../../../../help-doc.html">Help</a></li> |
| </ul> |
| </div> |
| <div class="subNav"> |
| <ul class="navList"> |
| <li><a href="../../../../org/apache/kafka/streams/TopologyDescription.Subtopology.html" title="interface in org.apache.kafka.streams"><span class="typeNameLink">Prev Class</span></a></li> |
| <li>Next Class</li> |
| </ul> |
| <ul class="navList"> |
| <li><a href="../../../../index.html?org/apache/kafka/streams/TopologyTestDriver.html" target="_top">Frames</a></li> |
| <li><a href="TopologyTestDriver.html" target="_top">No Frames</a></li> |
| </ul> |
| <ul class="navList" id="allclasses_navbar_bottom"> |
| <li><a href="../../../../allclasses-noframe.html">All Classes</a></li> |
| </ul> |
| <div> |
| <script type="text/javascript"><!-- |
| allClassesLink = document.getElementById("allclasses_navbar_bottom"); |
| if(window==top) { |
| allClassesLink.style.display = "block"; |
| } |
| else { |
| allClassesLink.style.display = "none"; |
| } |
| //--> |
| </script> |
| <noscript> |
| <div>JavaScript is disabled on your browser.</div> |
| </noscript> |
| </div> |
| <div> |
| <ul class="subNavList"> |
| <li>Summary: </li> |
| <li>Nested | </li> |
| <li>Field | </li> |
| <li><a href="#constructor.summary">Constr</a> | </li> |
| <li><a href="#method.summary">Method</a></li> |
| </ul> |
| <ul class="subNavList"> |
| <li>Detail: </li> |
| <li>Field | </li> |
| <li><a href="#constructor.detail">Constr</a> | </li> |
| <li><a href="#method.detail">Method</a></li> |
| </ul> |
| </div> |
| <a name="skip.navbar.bottom"> |
| <!-- --> |
| </a></div> |
| <!-- ======== END OF BOTTOM NAVBAR ======= --> |
| </body> |
| </html> |