WicketTester

13 views
Skip to first unread message

Rubens Melo

unread,
Nov 5, 2009, 12:46:36 PM11/5/09
to Wicket em Português
Pessoal,

Alguém ai conseguiu executar os testes unitários com Wicket? Mesmo
aqueles em que o Maven cria a classe de testes, quando criamos um
projeto usando o archetype do Wicket:

public class TestHomePage extends TestCase {
private WicketTester tester;

@Override
public void setUp() {
tester = new WicketTester(new WicketApplication());
}

public void testRenderMyPage() {
tester.startPage(HomePage.class);
tester.assertRenderedPage(HomePage.class);

}
}

A seguinte exceção está sendo lançada:

java.lang.IllegalStateException: No WebApplicationContext found: no
ContextLoaderListener registered?
at
org.springframework.web.context.support.WebApplicationContextUtils.getRequiredWebApplicationContext
(WebApplicationContextUtils.java:70)
at
org.apache.wicket.spring.injection.annot.SpringComponentInjector.<init>
(SpringComponentInjector.java:74)

Mesmo tendo no meu web.xml:

<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>WEB-INF/applicationContext.xml</param-value>
</context-param>

<listener>
<listener-
class>org.springframework.web.context.ContextLoaderListener</listener-
class>
</listener>

Rubens Melo

unread,
Nov 5, 2009, 1:36:11 PM11/5/09
to Wicket em Português
Pessoal, consegui resolver. Segue abaixo a solução e o link que me ajudou:

Código:   Basta apenas alterar o método setUp() e carregar o applicationContext e sobreescrever o método init(), da classe Application do seu projeto. Por enquanto este teste apenas valida a renderização da página, mais pra frente vou deixando-a mais robusta.

  public void setUp() {

        WicketApplication webApp = new WicketApplication() {
            ApplicationContext context =
                    new ClassPathXmlApplicationContext(new String[] {"applicationContext.xml"});

            @Override
            public void init() {
                addComponentInstantiationListener(new SpringComponentInjector(this, context));
            }
        };
        tester = new WicketTester(webApp);
    }

Link: http://cwiki.apache.org/WICKET/spring.html

2009/11/5 Rubens Melo <rubens...@gmail.com>

Bruno Borges

unread,
Nov 5, 2009, 1:39:22 PM11/5/09
to wicke...@googlegroups.com
Rubens, muito obrigado pela contribuição!! :-)

Abraço,
Bruno Borges
blog.brunoborges.com.br
+55 21 76727099

"The glory of great men should always be
measured by the means they have used to
acquire it."
- Francois de La Rochefoucauld
Sent from San Mateo, CA, United States

jun...@infobusiness.com.br

unread,
Nov 6, 2009, 7:32:11 AM11/6/09
to wicke...@googlegroups.com
Alguém em Porto Alegre (ou RS) usando Wicket?
Abraço,
Júnior.

Pedro Santos

unread,
Nov 6, 2009, 7:47:42 AM11/6/09
to wicke...@googlegroups.com
Olá Junior, eu tinha dado uma olhada no ohloh por curiosidade um tempo atrás, e parece ter poucas pessoas. Mas tem :)



Alguém em Porto Alegre (ou RS) usando Wicket?
Abraço,
Júnior.





--
Pedro Henrique Oliveira dos Santos

David Palmeira

unread,
Nov 11, 2009, 7:22:32 AM11/11/09
to wicke...@googlegroups.com
Trabalho com wicket em Brasília e já pensei em ir para Porto alegre algumas vezes. Como é o mercado de TI por ai?

Abraco

David Palmeira

2009/11/6 Pedro Santos <pedr...@gmail.com>
Reply all
Reply to author
Forward
0 new messages