@Test public void render() throws Exception { this.tag.setPath("name"); int result = this.tag.doStartTag(); assertEquals(Tag.SKIP_BODY, result); String output = getOutput(); assertTagOpened(output); assertTagClosed(output); assertContainsAttribute(output, "type", "hidden"); assertContainsAttribute(output, "value", "Sally Greenwood"); assertAttributeNotPresent(output, "disabled"); }
@Override @SuppressWarnings("serial") protected void onSetUp() { this.tag = new HiddenInputTag() { @Override protected TagWriter createTagWriter() { return new TagWriter(getWriter()); } }; this.tag.setPageContext(getPageContext()); }
@Override protected TagWriter createTagWriter() { return new TagWriter(getWriter()); } };
@Test public void disabledFalse() throws Exception { this.tag.setDisabled(false); this.tag.doStartTag(); this.tag.doEndTag(); String output = getOutput(); assertTagOpened(output); assertTagClosed(output); assertAttributeNotPresent(output, "disabled"); }
@Test public void disabledTrue() throws Exception { this.tag.setDisabled(true); this.tag.doStartTag(); this.tag.doEndTag(); String output = getOutput(); assertTagOpened(output); assertTagClosed(output); assertContainsAttribute(output, "disabled", "disabled"); }
@Test public void withCustomBinder() throws Exception { this.tag.setPath("myFloat"); BeanPropertyBindingResult errors = new BeanPropertyBindingResult(this.bean, COMMAND_NAME); errors.getPropertyAccessor().registerCustomEditor(Float.class, new SimpleFloatEditor()); exposeBindingResult(errors); assertEquals(Tag.SKIP_BODY, this.tag.doStartTag()); String output = getOutput(); assertTagOpened(output); assertTagClosed(output); assertContainsAttribute(output, "type", "hidden"); assertContainsAttribute(output, "value", "12.34f"); }