You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Olle Hallin <ol...@hit.se> on 2009/10/09 17:24:43 UTC

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

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@crisp.se
www.crisp.se

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

Posted by Paul Field <pa...@db.com>.
olle.hallin@gmail.com 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.