3 Replies Latest reply on Mar 5, 2009 4:05 PM by Clint Popetz

    Wicket : There is no application attached to current thread main

    Michel Jazz Newbie

      Hi everybody,


      I trie to test a login form throw seam/wicket.So i tried something like this :


      @Test
              public void testAuthenticate() throws Exception {
                      wicketTester.startPage(ProjectLogin.class);
                      final FormTester formTester=wicketTester.newFormTester('signInForm');
                      formTester.setValue('username', 'onclezeb');
                      formTester.setValue('password', 'password');
                      new FacesRequest() {
                              @Override
                              protected void invokeApplication() {
                              formTester.submit("submit");
      
                              wicketTester.assertNoErrorMessage();
                              wicketTester.assertRenderedPage(Home.class);
                              }
                      }.run();
              }



      Behind the authenticator, there is EJB3. That why i need new FacesRequest().
      I've got this error :




      java.lang.AssertionError: org.apache.wicket.WicketRuntimeException: There is no application attached to current thread main
              at org.jboss.seam.mock.AbstractSeamTest$Request.onException(AbstractSeamTest.java:455)
              at org.jboss.seam.mock.AbstractSeamTest$Request$2.doFilter(AbstractSeamTest.java:504)
              at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
              at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:58)
              at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
              at org.jboss.seam.web.HotDeployFilter.doFilter(HotDeployFilter.java:53)
              at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
              at org.jboss.seam.web.IdentityFilter.doFilter(IdentityFilter.java:40)
              at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
              at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:90)
              at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
              at org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:234)
              at org.jboss.seam.web.WicketFilter$1.process(WicketFilter.java:128)
              at org.jboss.seam.servlet.ContextualHttpServletRequest.run(ContextualHttpServletRequest.java:53)
              at org.jboss.seam.web.WicketFilter.doFilter(WicketFilter.java:74)
              at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
              at org.jboss.seam.wicket.web.WicketRedirectFilter.doFilter(WicketRedirectFilter.java:42)
              at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
              at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
              at org.jboss.seam.mock.AbstractSeamTest$Request.run(AbstractSeamTest.java:491)
              at fr.test.LoginTest.testAuthenticate(LoginTest.java:58)

      Caused by: org.apache.wicket.WicketRuntimeException: There is no application attached to current thread main
              at org.apache.wicket.Application.get(Application.java:166)
              at org.apache.wicket.Session.findOrCreate(Session.java:221)
              at org.apache.wicket.Session.findOrCreate(Session.java:211)
              at org.apache.wicket.protocol.http.MockWebApplication.createRequestCycle(MockWebApplication.java:518)
              at org.apache.wicket.util.tester.FormTester.submit(FormTester.java:613)
              at org.apache.wicket.util.tester.FormTester.submit(FormTester.java:664)
              at fr.test.LoginTest$1.invokeApplication(LoginTest.java:53)
              at org.jboss.seam.mock.AbstractSeamTest$Request.invokeApplicationPhase(AbstractSeamTest.java:646)
              at org.jboss.seam.mock.AbstractSeamTest$Request.emulateJsfLifecycle(AbstractSeamTest.java:595)
              at org.jboss.seam.mock.AbstractSeamTest$Request.access$300(AbstractSeamTest.java:177)
              at org.jboss.seam.mock.AbstractSeamTest$Request$2.doFilter(AbstractSeamTest.java:497)
              ... 41 more
      ... Removed 22 stack frames

      Any ideas ?