use of org.springframework.beans.testfixture.beans.Pet in project spring-framework by spring-projects.
the class RadioButtonTagTests method collectionOfPets.
@Test
void collectionOfPets() throws Exception {
this.tag.setPath("pets");
this.tag.setValue(new Pet("Rudiger"));
int result = this.tag.doStartTag();
assertThat(result).isEqualTo(Tag.SKIP_BODY);
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 = document.getRootElement().elements().get(0);
assertThat(checkboxElement.getName()).isEqualTo("input");
assertThat(checkboxElement.attribute("type").getValue()).isEqualTo("radio");
assertThat(checkboxElement.attribute("name").getValue()).isEqualTo("pets");
assertThat(checkboxElement.attribute("value").getValue()).isEqualTo("Rudiger");
assertThat(checkboxElement.attribute("checked").getValue()).isEqualTo("checked");
}
use of org.springframework.beans.testfixture.beans.Pet in project spring-framework by spring-projects.
the class CheckboxTagTests method collectionOfPetsNotSelected.
@Test
void collectionOfPetsNotSelected() throws Exception {
this.tag.setPath("pets");
this.tag.setValue(new Pet("Santa's Little Helper"));
int result = this.tag.doStartTag();
assertThat(result).isEqualTo(Tag.SKIP_BODY);
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 = document.getRootElement().elements().get(0);
assertThat(checkboxElement.getName()).isEqualTo("input");
assertThat(checkboxElement.attribute("type").getValue()).isEqualTo("checkbox");
assertThat(checkboxElement.attribute("name").getValue()).isEqualTo("pets");
assertThat(checkboxElement.attribute("value").getValue()).isEqualTo("Santa's Little Helper");
assertThat(checkboxElement.attribute("checked")).isNull();
}
use of org.springframework.beans.testfixture.beans.Pet in project spring-framework by spring-projects.
the class CheckboxTagTests method collectionOfPets.
@Test
void collectionOfPets() throws Exception {
this.tag.setPath("pets");
this.tag.setValue(new Pet("Rudiger"));
int result = this.tag.doStartTag();
assertThat(result).isEqualTo(Tag.SKIP_BODY);
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 = document.getRootElement().elements().get(0);
assertThat(checkboxElement.getName()).isEqualTo("input");
assertThat(checkboxElement.attribute("type").getValue()).isEqualTo("checkbox");
assertThat(checkboxElement.attribute("name").getValue()).isEqualTo("pets");
assertThat(checkboxElement.attribute("value").getValue()).isEqualTo("Rudiger");
assertThat(checkboxElement.attribute("checked").getValue()).isEqualTo("checked");
}
use of org.springframework.beans.testfixture.beans.Pet in project spring-framework by spring-projects.
the class RadioButtonsTagTests method createTestBean.
@Override
protected TestBean createTestBean() {
List colours = new ArrayList();
colours.add(Colour.BLUE);
colours.add(Colour.RED);
colours.add(Colour.GREEN);
List pets = new ArrayList();
pets.add(new Pet("Rudiger"));
pets.add(new Pet("Spot"));
pets.add(new Pet("Fluffy"));
pets.add(new Pet("Mufty"));
this.bean = new TestBean();
this.bean.setDate(getDate());
this.bean.setName("Rob Harrop");
this.bean.setJedi(true);
this.bean.setSomeBoolean(Boolean.TRUE);
this.bean.setStringArray(new String[] { "bar", "foo" });
this.bean.setSomeIntegerArray(new Integer[] { 2, 1 });
this.bean.setOtherColours(colours);
this.bean.setPets(pets);
List list = new ArrayList();
list.add("foo");
list.add("bar");
this.bean.setSomeList(list);
return this.bean;
}
Aggregations