You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Adam Hardy <ah...@cyberspaceroad.com> on 2009/03/05 09:22:33 UTC
[beanutils] testing around ConvertUtils
In my unit tests I sometimes have the situation where I need to register my
custom converters for ConvertUtils in order to make everything behave as it
would in real life.
Normally the conversions are incidental to the test so it seems unnecessary to
need to set up ConvertUtils.
Seeing inside the ConvertUtils class that there is a ConvertUtilsBean, I had the
idea of using the ConvertUtilsBean in my classes, and initializing it via
dependency injection.
Then I could mock it.
However all access to the ConvertUtilsBean via the singleton getInstance factory
method is protected. Would it be unwise to instantiate it myself in my
dependency injection container?
Thanks
Adam
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org
Re: [beanutils] testing around ConvertUtils
Posted by Adam Hardy <ah...@cyberspaceroad.com>.
Hi Paul,
I do register them now, but I asked the question because I wanted to avoid it,
to keep my unit testing faster and easier.
I guess now that I've written a routine to set up the Converter, it's no more
hassle than setting up a mock, but in my ideal architecture, I would want to see
it mocked out instead.
Paul Benedict on 12/03/09 02:42, wrote:
> Why can't you set up the test just like you would in real life? How do
> you register your converters today?
>
> On Thu, Mar 5, 2009 at 3:22 AM, Adam Hardy
> <ah...@cyberspaceroad.com> wrote:
>> In my unit tests I sometimes have the situation where I need to register my
>> custom converters for ConvertUtils in order to make everything behave as it
>> would in real life.
>>
>> Normally the conversions are incidental to the test so it seems unnecessary
>> to need to set up ConvertUtils.
>>
>> Seeing inside the ConvertUtils class that there is a ConvertUtilsBean, I had
>> the idea of using the ConvertUtilsBean in my classes, and initializing it
>> via dependency injection.
>>
>> Then I could mock it.
>>
>> However all access to the ConvertUtilsBean via the singleton getInstance
>> factory method is protected. Would it be unwise to instantiate it myself in
>> my dependency injection container?
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org
Re: [beanutils] testing around ConvertUtils
Posted by Paul Benedict <pb...@apache.org>.
Why can't you set up the test just like you would in real life? How do
you register your converters today?
On Thu, Mar 5, 2009 at 3:22 AM, Adam Hardy
<ah...@cyberspaceroad.com> wrote:
> In my unit tests I sometimes have the situation where I need to register my
> custom converters for ConvertUtils in order to make everything behave as it
> would in real life.
>
> Normally the conversions are incidental to the test so it seems unnecessary
> to need to set up ConvertUtils.
>
> Seeing inside the ConvertUtils class that there is a ConvertUtilsBean, I had
> the idea of using the ConvertUtilsBean in my classes, and initializing it
> via dependency injection.
>
> Then I could mock it.
>
> However all access to the ConvertUtilsBean via the singleton getInstance
> factory method is protected. Would it be unwise to instantiate it myself in
> my dependency injection container?
>
>
> Thanks
> Adam
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org