You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by PhilipJohnson <jo...@hawaii.edu> on 2008/04/04 22:44:23 UTC

Error using JUnit: Can't instantiate page using constructor

Greetings, all,

I am getting started with Wicket and just wrote my first simple JUnit test
for a small Wicket application (taken from the Wicket in Action book). The
test is:

public class TestIndexPage {
  @Test public void labelContainsHelloWorld() {
    WicketTester tester = new WicketTester(); 
    tester.startPage(Index.class); 
    tester.assertContains("Gouda");
    }
}

When I run it, I get the following:

    [junit] 407 [main] ERROR org.apache.wicket.RequestCycle - Can't
instantiate page using constructor public com.cheesr.Index()
    [junit] org.apache.wicket.WicketRuntimeException: Can't instantiate page
using constructor public com.cheesr.Index()

I have searched this group but not found any relevant solutions.  I am too
new to Wicket to understand how to diagnose this problem.

I have written a page with a more complete description of my error,
including a link to a .zip file which you can use to reproduce the error
quickly and which includes complete sources at:

http://code.google.com/p/hackystat-ui-wicket/wiki/WicketJUnitError

I would be most grateful for any help you could provide.  I am a refugee
from the Stripes/Struts/GWT world and am quite excited by the approach taken
in Wicket. 

Thanks very much,
Philip Johnson
-- 
View this message in context: http://www.nabble.com/Error-using-JUnit%3A-Can%27t-instantiate-page-using-constructor-tp16498898p16498898.html
Sent from the Wicket - User mailing list archive at Nabble.com.


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


Re: Error using JUnit: Can't instantiate page using constructor

Posted by Igor Vaynberg <ig...@gmail.com>.
look at the stacktrace, the root cause is:

Caused by: java.lang.ClassCastException:
org.apache.wicket.util.tester.WicketTester$DummyWebApplication cannot
be cast to com.cheesr.CheesrApplication


in your page you are trying to cast application to cheesrapplicatio,
but by default wickettester uses its own internal application class,
so you should do

WicketTester tester=new WicketTester(new CheesrApplication());

-igor


On Fri, Apr 4, 2008 at 1:44 PM, PhilipJohnson <jo...@hawaii.edu> wrote:
>
>  Greetings, all,
>
>  I am getting started with Wicket and just wrote my first simple JUnit test
>  for a small Wicket application (taken from the Wicket in Action book). The
>  test is:
>
>  public class TestIndexPage {
>   @Test public void labelContainsHelloWorld() {
>     WicketTester tester = new WicketTester();
>     tester.startPage(Index.class);
>     tester.assertContains("Gouda");
>     }
>  }
>
>  When I run it, I get the following:
>
>     [junit] 407 [main] ERROR org.apache.wicket.RequestCycle - Can't
>  instantiate page using constructor public com.cheesr.Index()
>     [junit] org.apache.wicket.WicketRuntimeException: Can't instantiate page
>  using constructor public com.cheesr.Index()
>
>  I have searched this group but not found any relevant solutions.  I am too
>  new to Wicket to understand how to diagnose this problem.
>
>  I have written a page with a more complete description of my error,
>  including a link to a .zip file which you can use to reproduce the error
>  quickly and which includes complete sources at:
>
>  http://code.google.com/p/hackystat-ui-wicket/wiki/WicketJUnitError
>
>  I would be most grateful for any help you could provide.  I am a refugee
>  from the Stripes/Struts/GWT world and am quite excited by the approach taken
>  in Wicket.
>
>  Thanks very much,
>  Philip Johnson
>  --
>  View this message in context: http://www.nabble.com/Error-using-JUnit%3A-Can%27t-instantiate-page-using-constructor-tp16498898p16498898.html
>  Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
>  ---------------------------------------------------------------------
>  To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>  For additional commands, e-mail: users-help@wicket.apache.org
>
>

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