Sure, this is the test code:
public class AbstractBasePageTester {
private WicketTester tester;
private StartApplication app;
@Mock
private CustomerService aService;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
app = new StartApplication() {
@Override
public ServletContext getServletContext() {
ServletContext servletContext =
super.getServletContext();
XmlWebApplicationContext applicationContext =
new
XmlWebApplicationContext();
applicationContext
.setConfigLocation("classpath:applicationContext.xml");
applicationContext.setServletContext(servletContext);
// applicationContext.refresh();
servletContext
.setAttribute(
WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE,
applicationContext);
return servletContext;
}
};
org.apache.log4j.Logger logger = org.apache.log4j.Logger
.getLogger("org.apache.wicket.util.tester");
logger.setLevel(Level.DEBUG);
tester = new WicketTester(app);
}
@Test
public void homepageRendersSuccessfully() {
// start and render the test page
tester.startPage(Start.class);
tester.assertRenderedPage(Start.class);
tester.assertNoErrorMessage();
tester.debugComponentTrees();
tester.assertComponent("createCustomerLink",
BookmarkablePageLink.class);
tester.assertComponent("showCustomersLink",
BookmarkablePageLink.class);
tester.clickLink("createCustomerLink");
}
}
And this the normal code:
public class Start extends WebPage {
public Start() {
BookmarkablePageLink<CreateCustomer> customerLink = new
BookmarkablePageLink<CreateCustomer>(
"createCustomerLink", CreateCustomer.class);
customerLink.add(new Label("createCustomerLabel",
getString("createCustomerLabel")));
add(customerLink);
BookmarkablePageLink<ShowCustomers> showCustomersLink = new
BookmarkablePageLink<ShowCustomers>(
"showCustomersLink", ShowCustomers.class);
showCustomersLink.add(new Label("showCustomersLabel",
getString("showCustomersLabel")));
add(showCustomersLink);
}
}
public class StartApplication extends WebApplication {
@Override
public Class<Start> getHomePage() {
return Start.class;
}
@Override
protected void init() {
super.init();
SpringComponentInjector springComponentInjector = new
SpringComponentInjector(
this);
getComponentInstantiationListeners().add(springComponentInjector);
}
}
--
View this message in context:
http://apache-wicket.1842946.n4.nabble.com/Wicket-Tester-with-BookmarkablePageLink-tp4656921p4656954.html
Sent from the Users forum mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]