Programmatic Testing of Lazy Loaded Associations

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Programmatic Testing of Lazy Loaded Associations

Justin N.
Hello all,
I am currently trying to familiarize myself with MyBatis and it's
various features.  One thing I am interested in doing is
programmaticly testing the lazy loading of associations.

I would like to be able to test that the lazy loaded association is
not loaded until a known "trigger" is called such as loading the
property, hashCode, equals, etc..  I have seen examples on the web and
also in the SpringIntegrationTest class that rely on a user examining
the output of the log in order to either pass or fail the assertion.

Has anyone implemented a more robust and repeatable process for
ensuring lazy loading is working in their application as they
intended?

Thanks in advance.

JRN
Reply | Threaded
Open this post in threaded view
|

Re: Programmatic Testing of Lazy Loaded Associations

Justin N.
This would still be something that I would like to do.  If my question
needs clarification, I would be happy to try and explain in a
different manner.

On Oct 7, 9:22 am, "Justin N." <[hidden email]> wrote:

> Hello all,
> I am currently trying to familiarize myself with MyBatis and it's
> various features.  One thing I am interested in doing is
> programmaticly testing the lazy loading of associations.
>
> I would like to be able to test that the lazy loaded association is
> not loaded until a known "trigger" is called such as loading the
> property, hashCode, equals, etc..  I have seen examples on the web and
> also in the SpringIntegrationTest class that rely on a user examining
> the output of the log in order to either pass or fail the assertion.
>
> Has anyone implemented a more robust and repeatable process for
> ensuring lazy loading is working in their application as they
> intended?
>
> Thanks in advance.
>
> JRN
Reply | Threaded
Open this post in threaded view
|

Re: Programmatic Testing of Lazy Loaded Associations

Larry Meadors
You could mock your jdbc driver and verify that it's not called until
you access a lazy loaded property.

IMO...it's WAY overkill for application testing.

One reason you use components is so that you can assume that they work
properly and not have to test them (I have never tested
String.toUpperCase(), I just assume it works).

The MyBatis tests should verify this for you. If they don't...that's a
better place to do that test. (Hint: check out the MyBatis source and
tests, then write a test to verify this if it is not already tested
there.)

Larry


On Tue, Oct 26, 2010 at 9:40 AM, Justin N. <[hidden email]> wrote:

> This would still be something that I would like to do.  If my question
> needs clarification, I would be happy to try and explain in a
> different manner.
>
> On Oct 7, 9:22 am, "Justin N." <[hidden email]> wrote:
>> Hello all,
>> I am currently trying to familiarize myself with MyBatis and it's
>> various features.  One thing I am interested in doing is
>> programmaticly testing the lazy loading of associations.
>>
>> I would like to be able to test that the lazy loaded association is
>> not loaded until a known "trigger" is called such as loading the
>> property, hashCode, equals, etc..  I have seen examples on the web and
>> also in the SpringIntegrationTest class that rely on a user examining
>> the output of the log in order to either pass or fail the assertion.
>>
>> Has anyone implemented a more robust and repeatable process for
>> ensuring lazy loading is working in their application as they
>> intended?
>>
>> Thanks in advance.
>>
>> JRN
Reply | Threaded
Open this post in threaded view
|

Re: Programmatic Testing of Lazy Loaded Associations

Raj Nagappan
There is one very good reason to test this though - to ensure you
configured it right. Whether that is a hand-test and inspect the logs,
or a fully automated repeatable test is a matter for taste / time /
carefulness / paranoia.

Raj.

On Oct 27, 2:57 am, Larry Meadors <[hidden email]> wrote:

> You could mock your jdbc driver and verify that it's not called until
> you access a lazy loaded property.
>
> IMO...it's WAY overkill for application testing.
>
> One reason you use components is so that you can assume that they work
> properly and not have to test them (I have never tested
> String.toUpperCase(), I just assume it works).
>
> The MyBatis tests should verify this for you. If they don't...that's a
> better place to do that test. (Hint: check out the MyBatis source and
> tests, then write a test to verify this if it is not already tested
> there.)
>
> Larry
>
> On Tue, Oct 26, 2010 at 9:40 AM, Justin N. <[hidden email]> wrote:
> > This would still be something that I would like to do.  If my question
> > needs clarification, I would be happy to try and explain in a
> > different manner.
>
> > On Oct 7, 9:22 am, "Justin N." <[hidden email]> wrote:
> >> Hello all,
> >> I am currently trying to familiarize myself with MyBatis and it's
> >> various features.  One thing I am interested in doing is
> >> programmaticly testing the lazy loading of associations.
>
> >> I would like to be able to test that the lazy loaded association is
> >> not loaded until a known "trigger" is called such as loading the
> >> property, hashCode, equals, etc..  I have seen examples on the web and
> >> also in the SpringIntegrationTest class that rely on a user examining
> >> the output of the log in order to either pass or fail the assertion.
>
> >> Has anyone implemented a more robust and repeatable process for
> >> ensuring lazy loading is working in their application as they
> >> intended?
>
> >> Thanks in advance.
>
> >> JRN