* by multiple threads.
*/
public void testClassAttributeRendering() {
// PickList uses Velocity to render its template. In this test we start a
// MockContainer which also configures Velocity
MockContainer container = new MockContainer("web");
container.start();
// MockContext is created when a container tests a page. There
// is no page to test so we manually create a MockContext
// and reuse the Mock Servlet objects created in the container.
MockContext.initContext(container.getServletConfig(),
container.getRequest(), container.getResponse(), container.getClickServlet());
PickList pickList = new PickList("pickList");
pickList.addStyleClass("white");
pickList.setAttribute("title", "test");
String pickListStr = pickList.toString();
// Perform checks within the first 100 characters
pickListStr = pickListStr.substring(0, 100);
// Check that class attribute was rendered
assertEquals(1, StringUtils.countMatches(pickListStr, "class=\"white picklist\""));
// Check that the title attribute was rendered
assertEquals(1, StringUtils.countMatches(pickListStr, "title=\"test\""));
// Check that class attribute was rendered once
assertEquals(1, StringUtils.countMatches(pickListStr, "class="));
container.stop();
}