How to write a Testify test for an onActivate() that returns a URL?

View: New views
2 Messages — Rating Filter:   Alert me  

How to write a Testify test for an onActivate() that returns a URL?

by Olle Hallin-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

I'm struggling with writing a test for a page that just redirects to an
external page.

The page basically looks like this:

public class Redirecter {

  @Inject
  private UrlManager urlManager;

  public Object onActivate() {
    java.net.URL url = new URL(urlManager.getExternalUrlFor(some-string));
    return url;
  }
}

I have managed to mock urlManager.getExternalUrlFor(), but then Testify
throws

java.lang.RuntimeException: TestableResponse: Method sendRedirect() not yet
implemented.

Any ideas?

Olle Hallin
Senior Java Developer and Architect
olle.hallin@...
www.crisp.se

Re: How to write a Testify test for an onActivate() that returns a URL?

by Paul Field-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

olle.hallin@... wrote on 09/10/2009 16:24:43:

> I'm struggling with writing a test for a page that just redirects to an
> external page.
>
> The page basically looks like this:
>
> public class Redirecter {
>
>   @Inject
>   private UrlManager urlManager;
>
>   public Object onActivate() {
>     java.net.URL url = new
URL(urlManager.getExternalUrlFor(some-string));
>     return url;
>   }
> }
>
> I have managed to mock urlManager.getExternalUrlFor(), but then Testify
> throws
>
> java.lang.RuntimeException: TestableResponse: Method sendRedirect() not
yet
> implemented.
>

Sorry for the delay replying - I've been on holiday.

TestableResponse and its implementation TestableResponseImpl are a part of
Tapestry not Testify.

They are bound as a service into the IOC registry in
org.apache.tapestry5.internal.test.PageTesterModule so you should be able
to get round the problem by subclassing TestableResponseImpl to provide an
implementation and then overriding the service. However, there is
something unusual happening in PageTesterModule where the service is
getting attached to aliases so there might be some fun involved - I
haven't got much time to think about it myself at the moment :-(.

Also, please raise a JIRA against Tapestry (
https://issues.apache.org/jira/browse/TAP5 ) if you'd like the
implementation fixed properly in Tapestry.

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.