tester.startPage(new LayerPage());
tester.assertRenderedPage(LayerPage.class);
tester.assertNoErrorMessage();
// check it has two layers
GeoServerTablePanel table = (GeoServerTablePanel) tester.getComponentFromLastRenderedPage("table");
assertEquals(2, table.getDataProvider().size());
List<String> workspaces = getWorkspaces(table);
assertTrue(workspaces.contains("cite"));
assertTrue(workspaces.contains("gs"));
// sort on workspace once (top to bottom)
String wsSortPath = "table:listContainer:sortableLinks:1:header:link";
tester.clickLink(wsSortPath, true);
workspaces = getWorkspaces(table);
assertEquals("cite", workspaces.get(0));
assertEquals("gs", workspaces.get(1));
// sort on workspace twice (bottom to top)
tester.clickLink(wsSortPath, true);
workspaces = getWorkspaces(table);
assertEquals("gs", workspaces.get(0));
assertEquals("cite", workspaces.get(1));
// select second layer
String checkBoxPath = "table:listContainer:items:6:selectItemContainer:selectItem";
CheckBox selector = (CheckBox) tester.getComponentFromLastRenderedPage(checkBoxPath);
// dirty trick, how to set a form component value without a form
tester.getServletRequest().setParameter(selector.getInputName(), "true");
tester.executeAjaxEvent(selector, "onclick");
assertEquals(1, table.getSelection().size());
LayerInfo li = (LayerInfo) table.getSelection().get(0);
assertEquals("cite", li.getResource().getStore().getWorkspace().getName());
}