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

Tomohiro Hashidate commented on KAFKA-10200:
--------------------------------------------

This issue seems to occur again.

I met `IllegalArgumentException` when I used MockProcessorContext with 
WindowStore.

 

The code for reproducing.
{code:java}
    this.context = new MockProcessorContext<>(props);
    var store =
        Stores.windowStoreBuilder(
                Stores.inMemoryWindowStore(
                    "store-name", Duration.ofDays(1), Duration.ofDays(1), 
false),
                Serdes.String(),
                Serdes.String())
            .withCachingDisabled()
            .withLoggingDisabled()
            .build();
    store.init(context.getStateStoreContext(), store);
{code}
The code throws `IllegalArgumentException` at 
`ProcessorContextUtils.asInternalProcessorContext`.

It seems there is no way to bypass this process in the WindowsStore.init.

> MockProcessorContext doesn't work with WindowStores
> ---------------------------------------------------
>
>                 Key: KAFKA-10200
>                 URL: https://issues.apache.org/jira/browse/KAFKA-10200
>             Project: Kafka
>          Issue Type: Bug
>          Components: streams, streams-test-utils
>            Reporter: John Roesler
>            Assignee: John Roesler
>            Priority: Major
>             Fix For: 2.7.0
>
>
> The recommended pattern for testing custom Processor implementations is to 
> use the test-utils MockProcessorContext. If a Processor implementation needs 
> a store, the store also has to be initialized with the same context. However, 
> the existing (in-memory and persistent) Windowed store implementations 
> perform internal casts that result in class cast exceptions if you attempt to 
> initialize them with the MockProcessorContext.
> A workaround is to instead embed the processor in an application and use the 
> TopologyTestDriver instead.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to