On Mon, Feb 13, 2012 at 1:19 AM, stebac <bachl...@sbox.tugraz.at> wrote:
> What is the mock used for (particularly in this case)?
> I commented out these two lines and it still worked, what is the purpose of
> the SessionSource?

Of course it "works" if you don't need the SessionSource (which is a
T5 concept, not Hibernate). If your service takes a SessionSource as
an injected parameter to obtain the Session, you have to pass a
SessionSource to it for things to work. It should be fairly obvious
from the sample code that the testing strategy (for those types of
tests) is exercising the actual persistence logic, mocking up the
Tapestry services as needed that are built on top of the specific
persistence technology.

You want to use the SessionSource to create a new Session if the
execution of your operation lasts longer than the lifetime of the
request is. If you are injecting a session, T5 manages the lifetime of
it and closes it at the end of the request handling.

> Just for beeing sure:
> using your approach a can use the imlementation of the service, making
> things more convinient. Here I use injection by contructor for the session.
> So when T5 injects the current session, I can now hand it over in my
> testcases. Is this the way it was meant originally?

That's one use case. The right approach for a given situation depends
on what specifically you are testing and what the circumstances are
for that particular use case. Similarly, the PageTester is hugely
beneficial for testing the logic within your pages, but there's no
benefit using it for testing your persistence queries.

Kalle

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Reply via email to