You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@kafka.apache.org by Vadim Keylis <vk...@gmail.com> on 2014/03/13 06:41:46 UTC

Best ways to unit test consumer that is based on simpleConsumer

Good evening. I am writing consumer that is based on SimpleConsumer. I
would like to write integration/unit  tests that simulate different error
responses from kafka to make sure my code handles it properly. How do you
guys advised to do this within my unit test? Do you have some kind of mock
kafka that capable of doing this? What would be your advise?

Thanks so much,
Vadim.

Re: Best ways to unit test consumer that is based on simpleConsumer

Posted by Neha Narkhede <ne...@gmail.com>.
I see. In that case, it might be easier to write a MockSimpleConsumer and
have it return different FetchResponse objects with the error codes you
want to test. We don't have a MockSimpleConsumer as well. If you happen to
write one, you could use it with EasyMock to get the fetch() API to return
the fetch responses you want to test.

Hope that helps,
Neha


On Thu, Mar 13, 2014 at 1:40 PM, Vadim Keylis <vk...@gmail.com> wrote:

> Neha. That is correct SimpleConsumer does not do much, but my code that is
> calling it need to react properly at error response and I wanted to test
> that.
>
>
> On Thu, Mar 13, 2014 at 1:21 PM, Neha Narkhede <neha.narkhede@gmail.com
> >wrote:
>
> > Currently, we don't have a mock class for the server. The SimpleConsumer
> > actually doesn't do much with the fetch request and response. Take a look
> > at the fetch() API on SimpleConsumer. It merely returns the response back
> > to the user.
> >
> > Thanks,
> > Neha
> >
> >
> > On Wed, Mar 12, 2014 at 11:58 PM, Vadim Keylis <vkeylis2009@gmail.com
> > >wrote:
> >
> > > Additional information. We currently using kafka 0.8 and client will be
> > > written in java.
> > >
> > >
> > > On Wed, Mar 12, 2014 at 10:41 PM, Vadim Keylis <vkeylis2009@gmail.com
> > > >wrote:
> > >
> > > > Good evening. I am writing consumer that is based on SimpleConsumer.
> I
> > > > would like to write integration/unit  tests that simulate different
> > error
> > > > responses from kafka to make sure my code handles it properly. How do
> > you
> > > > guys advised to do this within my unit test? Do you have some kind of
> > > mock
> > > > kafka that capable of doing this? What would be your advise?
> > > >
> > > > Thanks so much,
> > > > Vadim.
> > > >
> > > >
> > > >
> > >
> >
>

Re: Best ways to unit test consumer that is based on simpleConsumer

Posted by Vadim Keylis <vk...@gmail.com>.
Neha. That is correct SimpleConsumer does not do much, but my code that is
calling it need to react properly at error response and I wanted to test
that.


On Thu, Mar 13, 2014 at 1:21 PM, Neha Narkhede <ne...@gmail.com>wrote:

> Currently, we don't have a mock class for the server. The SimpleConsumer
> actually doesn't do much with the fetch request and response. Take a look
> at the fetch() API on SimpleConsumer. It merely returns the response back
> to the user.
>
> Thanks,
> Neha
>
>
> On Wed, Mar 12, 2014 at 11:58 PM, Vadim Keylis <vkeylis2009@gmail.com
> >wrote:
>
> > Additional information. We currently using kafka 0.8 and client will be
> > written in java.
> >
> >
> > On Wed, Mar 12, 2014 at 10:41 PM, Vadim Keylis <vkeylis2009@gmail.com
> > >wrote:
> >
> > > Good evening. I am writing consumer that is based on SimpleConsumer. I
> > > would like to write integration/unit  tests that simulate different
> error
> > > responses from kafka to make sure my code handles it properly. How do
> you
> > > guys advised to do this within my unit test? Do you have some kind of
> > mock
> > > kafka that capable of doing this? What would be your advise?
> > >
> > > Thanks so much,
> > > Vadim.
> > >
> > >
> > >
> >
>

Re: Best ways to unit test consumer that is based on simpleConsumer

Posted by Neha Narkhede <ne...@gmail.com>.
Currently, we don't have a mock class for the server. The SimpleConsumer
actually doesn't do much with the fetch request and response. Take a look
at the fetch() API on SimpleConsumer. It merely returns the response back
to the user.

Thanks,
Neha


On Wed, Mar 12, 2014 at 11:58 PM, Vadim Keylis <vk...@gmail.com>wrote:

> Additional information. We currently using kafka 0.8 and client will be
> written in java.
>
>
> On Wed, Mar 12, 2014 at 10:41 PM, Vadim Keylis <vkeylis2009@gmail.com
> >wrote:
>
> > Good evening. I am writing consumer that is based on SimpleConsumer. I
> > would like to write integration/unit  tests that simulate different error
> > responses from kafka to make sure my code handles it properly. How do you
> > guys advised to do this within my unit test? Do you have some kind of
> mock
> > kafka that capable of doing this? What would be your advise?
> >
> > Thanks so much,
> > Vadim.
> >
> >
> >
>

Re: Best ways to unit test consumer that is based on simpleConsumer

Posted by Vadim Keylis <vk...@gmail.com>.
Additional information. We currently using kafka 0.8 and client will be
written in java.


On Wed, Mar 12, 2014 at 10:41 PM, Vadim Keylis <vk...@gmail.com>wrote:

> Good evening. I am writing consumer that is based on SimpleConsumer. I
> would like to write integration/unit  tests that simulate different error
> responses from kafka to make sure my code handles it properly. How do you
> guys advised to do this within my unit test? Do you have some kind of mock
> kafka that capable of doing this? What would be your advise?
>
> Thanks so much,
> Vadim.
>
>
>