I am trying to test my wicket design using the Wicket Page Test.
Running the test causes Jetty to throw this error:
2015-03-24 17:46:24,789 WARN [:] [main] [] [||] - org.eclipse.jetty.webapp.WebAppContext - Failed startup of context oejwWebAppContext java.lang.IllegalStateException: No LoginService for org.eclipse.jetty.security.authentication.BasicAuthenticator@4c4 51268 in org.eclipse.jetty.security.ConstraintSecurityHandler@4abb90f6
My testng set is as follows:
<suite name="wicket-page-test-sample"> <test verbose="2" name="tests" annotations="JDK"> <packages> <package name="..."></package> </packages> <classes> <class name="com.ttdev.wicketpagetest.WebPageTestContext"></class> <class name="nl.pack.test.MessagePanelTest"></class> </classes> </test>
The testing class is as follows:
@Test public class MessagePanelTest { public void testOpenComponent() { final StringBuffer log = new StringBuffer(); MockableSpringBeanInjector.mockBean("hibernateService", mock(HibernateService.class)); WicketSeleniumDriver ws = WebPageTestContext.getWicketSelenium(); ws.openComponent(new ComponentFactory() { private static final long serialVersionUID = 1L; public Component createComponent(String id) { return new MessagePanel(mock(AjaxRequestTarget.class)); } }); assert ws.getText(By.id("info")).equals("Hello"); } }
I found several suggestions on the Internet for modifying the Jetty configuration as follows:
<?xml version="1.0" encoding="ISO-8859-1"?> <!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd"> <Configure class="org.eclipse.jetty.webapp.WebAppContext"> <Get name="securityHandler"> <Set name="loginService"> <New class="org.eclipse.jetty.security.HashLoginService"> <Set name="name">MySecurityRealm</Set> <Set name="config">src/test/resources/jetty-realm.properties</Set> <Call name="start"/> </New> </Set> <Set name="checkWelcomeFiles">true</Set> </Get> </Configure>
But I would not now include this configuration in my tests. What am I missing? How do I set up a jetty for my test?
Cloud source share