use of org.dom4j.io.SAXReader in project spring-framework by spring-projects.
the class CheckboxTagTests method withSingleValueNull.
@Test
public void withSingleValueNull() throws Exception {
this.bean.setName(null);
this.tag.setPath("name");
this.tag.setValue("Rob Harrop");
int result = this.tag.doStartTag();
assertEquals(Tag.SKIP_BODY, result);
String output = getOutput();
// wrap the output so it is valid XML
output = "<doc>" + output + "</doc>";
SAXReader reader = new SAXReader();
Document document = reader.read(new StringReader(output));
Element checkboxElement = (Element) document.getRootElement().elements().get(0);
assertEquals("input", checkboxElement.getName());
assertEquals("checkbox", checkboxElement.attribute("type").getValue());
assertEquals("name", checkboxElement.attribute("name").getValue());
assertNull(checkboxElement.attribute("checked"));
assertEquals("Rob Harrop", checkboxElement.attribute("value").getValue());
}
use of org.dom4j.io.SAXReader in project spring-framework by spring-projects.
the class CheckboxTagTests method withSingleValueBooleanObjectChecked.
@Test
public void withSingleValueBooleanObjectChecked() throws Exception {
this.tag.setPath("someBoolean");
int result = this.tag.doStartTag();
assertEquals(Tag.SKIP_BODY, result);
String output = getOutput();
// wrap the output so it is valid XML
output = "<doc>" + output + "</doc>";
SAXReader reader = new SAXReader();
Document document = reader.read(new StringReader(output));
Element rootElement = document.getRootElement();
assertEquals("Both tag and hidden element not rendered", 2, rootElement.elements().size());
Element checkboxElement = (Element) rootElement.elements().get(0);
assertEquals("input", checkboxElement.getName());
assertEquals("checkbox", checkboxElement.attribute("type").getValue());
assertEquals("someBoolean1", checkboxElement.attribute("id").getValue());
assertEquals("someBoolean", checkboxElement.attribute("name").getValue());
assertEquals("checked", checkboxElement.attribute("checked").getValue());
assertEquals("true", checkboxElement.attribute("value").getValue());
}
use of org.dom4j.io.SAXReader in project spring-framework by spring-projects.
the class CheckboxTagTests method withSingleValueNotNull.
@Test
public void withSingleValueNotNull() throws Exception {
this.bean.setName("Rob Harrop");
this.tag.setPath("name");
this.tag.setValue("Rob Harrop");
int result = this.tag.doStartTag();
assertEquals(Tag.SKIP_BODY, result);
String output = getOutput();
// wrap the output so it is valid XML
output = "<doc>" + output + "</doc>";
SAXReader reader = new SAXReader();
Document document = reader.read(new StringReader(output));
Element checkboxElement = (Element) document.getRootElement().elements().get(0);
assertEquals("input", checkboxElement.getName());
assertEquals("checkbox", checkboxElement.attribute("type").getValue());
assertEquals("name", checkboxElement.attribute("name").getValue());
assertEquals("checked", checkboxElement.attribute("checked").getValue());
assertEquals("Rob Harrop", checkboxElement.attribute("value").getValue());
}
use of org.dom4j.io.SAXReader in project spring-framework by spring-projects.
the class CheckboxTagTests method withObjectChecked.
@Test
public void withObjectChecked() throws Exception {
this.tag.setPath("date");
this.tag.setValue(getDate());
int result = this.tag.doStartTag();
assertEquals(Tag.SKIP_BODY, result);
String output = getOutput();
// wrap the output so it is valid XML
output = "<doc>" + output + "</doc>";
SAXReader reader = new SAXReader();
Document document = reader.read(new StringReader(output));
Element checkboxElement = (Element) document.getRootElement().elements().get(0);
assertEquals("input", checkboxElement.getName());
assertEquals("checkbox", checkboxElement.attribute("type").getValue());
assertEquals("date", checkboxElement.attribute("name").getValue());
assertEquals("checked", checkboxElement.attribute("checked").getValue());
assertEquals(getDate().toString(), checkboxElement.attribute("value").getValue());
}
use of org.dom4j.io.SAXReader in project spring-framework by spring-projects.
the class CheckboxTagTests method collectionOfPetsAsString.
@Test
public void collectionOfPetsAsString() throws Exception {
this.tag.setPath("pets");
this.tag.setValue("Spot");
int result = this.tag.doStartTag();
assertEquals(Tag.SKIP_BODY, result);
String output = getOutput();
// wrap the output so it is valid XML
output = "<doc>" + output + "</doc>";
SAXReader reader = new SAXReader();
Document document = reader.read(new StringReader(output));
Element checkboxElement = (Element) document.getRootElement().elements().get(0);
assertEquals("input", checkboxElement.getName());
assertEquals("checkbox", checkboxElement.attribute("type").getValue());
assertEquals("pets", checkboxElement.attribute("name").getValue());
assertEquals("checked", checkboxElement.attribute("checked").getValue());
}
Aggregations