use of com.github.bordertech.wcomponents.WDropdown in project wcomponents by BorderTech.
the class WDropdownRenderer_Test method testDataList.
@Test
public void testDataList() throws IOException, SAXException, XpathException {
WDropdown drop = new WDropdown(TestLookupTable.CACHEABLE_DAY_OF_WEEK_TABLE);
assertSchemaMatch(drop);
String code = drop.getCode(drop.getOptions().get(0), 0);
String desc = drop.getDesc(drop.getOptions().get(0), 0);
assertXpathEvaluatesTo("1", "count(//ui:dropdown/ui:option)", drop);
assertXpathEvaluatesTo(desc, "//ui:dropdown/ui:option[@value='" + code + "']/text()", drop);
assertXpathEvaluatesTo(drop.getListCacheKey(), "//ui:dropdown/@data", drop);
}
use of com.github.bordertech.wcomponents.WDropdown in project wcomponents by BorderTech.
the class WDropdownRenderer_Test method testRendererCorrectlyConfigured.
@Test
public void testRendererCorrectlyConfigured() {
WDropdown component = new WDropdown();
Assert.assertTrue("Incorrect renderer supplied", getWebXmlRenderer(component) instanceof WDropdownRenderer);
}
use of com.github.bordertech.wcomponents.WDropdown in project wcomponents by BorderTech.
the class WDropdownRenderer_Test method testXssEscaping.
@Test
public void testXssEscaping() throws IOException, SAXException, XpathException {
OptionGroup optionGroup = new OptionGroup(getMaliciousAttribute("ui:optgroup"), Arrays.asList(new String[] { "dummy" }));
WDropdown drop = new WDropdown(Arrays.asList(new Object[] { getInvalidCharSequence(), getMaliciousContent(), optionGroup }));
assertSafeContent(drop);
drop.setToolTip(getMaliciousAttribute("ui:dropdown"));
assertSafeContent(drop);
drop.setAccessibleText(getMaliciousAttribute("ui:dropdown"));
assertSafeContent(drop);
}
use of com.github.bordertech.wcomponents.WDropdown in project wcomponents by BorderTech.
the class WDropdownRenderer_Test method testNullOption.
@Test
public void testNullOption() throws IOException, SAXException, XpathException {
String[] options = new String[] { null, "A", "B", "C" };
WDropdown drop = new WDropdown(options);
assertSchemaMatch(drop);
assertXpathEvaluatesTo("4", "count(//ui:dropdown/ui:option)", drop);
assertXpathEvaluatesTo("", "//ui:dropdown/ui:option[@value='']/text()", drop);
for (int i = 0; i < options.length; i++) {
String code = drop.optionToCode(options[i]);
String option;
if (i == 0) {
// null
option = "";
} else {
option = options[i];
}
assertXpathEvaluatesTo(option, "//ui:dropdown/ui:option[@value='" + code + "']/text()", drop);
}
}
use of com.github.bordertech.wcomponents.WDropdown in project wcomponents by BorderTech.
the class WDropdownRenderer_Test method testIsNullOption.
@Test
public void testIsNullOption() throws IOException, SAXException, XpathException {
String[] options = new String[] { null, "", "A", "B", "C" };
WDropdown drop = new WDropdown(options);
assertSchemaMatch(drop);
assertXpathEvaluatesTo("5", "count(//ui:dropdown/ui:option)", drop);
assertXpathEvaluatesTo("", "//ui:dropdown/ui:option[@value='']/text()", drop);
for (int i = 0; i < options.length; i++) {
String code = drop.optionToCode(options[i]);
String option = options[i];
if (option == null || option.equals("")) {
assertXpathEvaluatesTo("", "//ui:dropdown/ui:option[@value='" + code + "']/text()", drop);
assertXpathEvaluatesTo("true", "//ui:dropdown/ui:option[@value='" + code + "']/@isNull", drop);
} else {
assertXpathEvaluatesTo(option, "//ui:dropdown/ui:option[@value='" + code + "']/text()", drop);
assertXpathEvaluatesTo("", "//ui:dropdown/ui:option[@value='" + code + "']/@isNull", drop);
}
}
}
Aggregations