Skip to content

Commit

Permalink
add test for buildTemplateName method
Browse files Browse the repository at this point in the history
Verified that:
- default template name gets picked when no specific one is given
- specific template gets precedence over default one
  • Loading branch information
sdutry committed Jan 4, 2018
1 parent 0bfdc5e commit 476697f
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions core/src/test/java/org/apache/struts2/components/UIBeanTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -188,4 +188,20 @@ public TemplateEngine getTemplateEngine(Template template, String templateTypeOv
}
}

public void testBuildTemplate() throws Exception {
String defaultTemplateName = "default";
String customTemplateName = "custom";
ValueStack stack = ActionContext.getContext().getValueStack();
MockHttpServletRequest req = new MockHttpServletRequest();
MockHttpServletResponse res = new MockHttpServletResponse();

TextField txtFld = new TextField(stack, req, res);

Template defaultTemplate = txtFld.buildTemplateName(null, defaultTemplateName);
Template customTemplate = txtFld.buildTemplateName(customTemplateName, defaultTemplateName);

assertEquals(defaultTemplateName, defaultTemplate.getName());
assertEquals(customTemplateName, customTemplate.getName());
}

}

0 comments on commit 476697f

Please sign in to comment.