You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Mats Henricson <ma...@henricson.se> on 2009/09/07 13:48:39 UTC

Problem with testify and @SessionState injection

Hi!

I am really close to get my Testify machinery working for
my first non-trivial page. The last hurdle (touch on wood)
is that the @ForComponents annotation doesn't inject my
mock object in fields annotated with @SessionState.

I can't see any example doing this, so, does it work? Am I
on the wrong way? Is there any other way of doing this?

Mats

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


Re: Problem with testify and @SessionState injection

Posted by Mats Henricson <ma...@henricson.se>.
Paul Field wrote:
> Mats Henricson <ma...@henricson.se> wrote on 08/09/2009 09:41:56:
>> Mats Henricson wrote:
>>> So, how should I inject my mocked @SessionState object? Is it
>>> possible through the tester object, before I render the page?
>> I'm testing this now. Hopefully it is kosher:
>>
>>   ApplicationStateManager stateManager =
>>       tester.getRegistry().getService(ApplicationStateManager.class);
>>   stateManager.set(GameUserState.class, myMockGameUserState);
>>   tester.renderPage(...);
> 
> That looks sensible to me - and it does make sense to use a mock in that 
> case.

And it works too! My Testify machinery is now functional, and I've
ironed out all ugly hacks as well.

I promise to help out on the mailing list if testify issues pops up.

Mats

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


Re: Problem with testify and @SessionState injection

Posted by Paul Field <pa...@db.com>.
Mats Henricson <ma...@henricson.se> wrote on 08/09/2009 09:41:56:
> Mats Henricson wrote:
> > So, how should I inject my mocked @SessionState object? Is it
> > possible through the tester object, before I render the page?
> 
> I'm testing this now. Hopefully it is kosher:
> 
>   ApplicationStateManager stateManager =
>       tester.getRegistry().getService(ApplicationStateManager.class);
>   stateManager.set(GameUserState.class, myMockGameUserState);
>   tester.renderPage(...);

That looks sensible to me - and it does make sense to use a mock in that 
case.

Paul


---

This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and delete this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden.

Please refer to http://www.db.com/en/content/eu_disclosures.htm for additional EU corporate and regulatory disclosures.

Re: Problem with testify and @SessionState injection

Posted by Mats Henricson <ma...@henricson.se>.
Mats Henricson wrote:
> Paul Field wrote:
>> Mats Henricson <ma...@henricson.se> wrote on 07/09/2009 12:48:39:
>>
>>> I am really close to get my Testify machinery working for
>>> my first non-trivial page. The last hurdle (touch on wood)
>>> is that the @ForComponents annotation doesn't inject my
>>> mock object in fields annotated with @SessionState.
>> I wouldn't expect you to use mock objects with @SessionState. Tapestry's 
>> PageTester (on which Testify is built) runs with a fake session so is able 
>> to store session information during your test. So I would expect 
>> @SessionState to work as it does in a live site. However, I haven't 
>> actually tried it - so I could be wrong.
> 
> So, how should I inject my mocked @SessionState object? Is it
> possible through the tester object, before I render the page?

I'm testing this now. Hopefully it is kosher:

  ApplicationStateManager stateManager =
      tester.getRegistry().getService(ApplicationStateManager.class);
  stateManager.set(GameUserState.class, myMockGameUserState);
  tester.renderPage(...);

Mats

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


Re: Problem with testify and @SessionState injection

Posted by Mats Henricson <ma...@henricson.se>.
Paul Field wrote:
> Mats Henricson <ma...@henricson.se> wrote on 07/09/2009 12:48:39:
> 
>> I am really close to get my Testify machinery working for
>> my first non-trivial page. The last hurdle (touch on wood)
>> is that the @ForComponents annotation doesn't inject my
>> mock object in fields annotated with @SessionState.
> 
> I wouldn't expect you to use mock objects with @SessionState. Tapestry's 
> PageTester (on which Testify is built) runs with a fake session so is able 
> to store session information during your test. So I would expect 
> @SessionState to work as it does in a live site. However, I haven't 
> actually tried it - so I could be wrong.

So, how should I inject my mocked @SessionState object? Is it
possible through the tester object, before I render the page?

Mats


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


Re: Problem with testify and @SessionState injection

Posted by Paul Field <pa...@db.com>.
Mats Henricson <ma...@henricson.se> wrote on 07/09/2009 12:48:39:

> I am really close to get my Testify machinery working for
> my first non-trivial page. The last hurdle (touch on wood)
> is that the @ForComponents annotation doesn't inject my
> mock object in fields annotated with @SessionState.

I wouldn't expect you to use mock objects with @SessionState. Tapestry's 
PageTester (on which Testify is built) runs with a fake session so is able 
to store session information during your test. So I would expect 
@SessionState to work as it does in a live site. However, I haven't 
actually tried it - so I could be wrong.

Paul



---

This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and delete this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden.

Please refer to http://www.db.com/en/content/eu_disclosures.htm for additional EU corporate and regulatory disclosures.