[ 
https://issues.apache.org/jira/browse/KAFKA-6460?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16773714#comment-16773714
 ] 

Matthias J. Sax commented on KAFKA-6460:
----------------------------------------

Personally, I would not use EasyMock for this but implement everything from 
scratch (this about this as "manual mocking"). The factory, suppliers, don't 
need to track anything. Only the actual `MockXxxStores` should track their 
usage.

I personally also don't think we need something similar to 
`KeyValueStoreTestDriver` at this point. But you can have a look into 
`org.apache.kafka.test.MockKeyValueStore` what a mocked store could provide. We 
need to figure out the details on-the-go.

For `TopologyTestDriver` – it can access `InternalTopologyBuilder` and update 
the stores:

[https://github.com/apache/kafka/blob/trunk/streams/src/main/java/org/apache/kafka/streams/processor/internals/InternalTopologyBuilder.java#L63]

These we would replace the existing `StoreBuilder` with MockStoreBuilders 
before the build the topology to switch out the store (this should be an opt-in 
or opt-out for users – we should preserve the ability to test both actual 
stores).

Hope this helps. Looking forward to your KIP.

> Add mocks for state stores used in Streams unit testing
> -------------------------------------------------------
>
>                 Key: KAFKA-6460
>                 URL: https://issues.apache.org/jira/browse/KAFKA-6460
>             Project: Kafka
>          Issue Type: Improvement
>          Components: streams, unit tests
>            Reporter: Guozhang Wang
>            Assignee: Yishun Guan
>            Priority: Major
>              Labels: newbie++
>
> We'd like to use mocks for different types of state stores: kv, window, 
> session that can be used to record the number of expected put / get calls 
> used in the DSL operator unit testing. This involves implementing the two 
> interfaces {{StoreSupplier}} and {{StoreBuilder}} that can return a object 
> created from, say, EasyMock, and the object can then be set up with the 
> expected calls.
> In addition, we should also add a mock record collector which can be returned 
> from the mock processor context so that with logging enabled store, users can 
> also validate if the changes have been forwarded to the changelog as well.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to