use of jakarta.servlet.jsp.PageContext in project spring-framework by spring-projects.
the class MessageTagTests method messageTagWithCodeAndArguments.
@Test
void messageTagWithCodeAndArguments() throws JspException {
PageContext pc = createPageContext();
final StringBuilder message = new StringBuilder();
MessageTag tag = new MessageTag() {
@Override
protected void writeMessage(String msg) {
message.append(msg);
}
};
tag.setPageContext(pc);
tag.setCode("testArgs");
tag.setArguments("arg1,arg2");
assertThat(tag.doStartTag() == Tag.EVAL_BODY_INCLUDE).as("Correct doStartTag return value").isTrue();
assertThat(tag.doEndTag()).as("Correct doEndTag return value").isEqualTo(Tag.EVAL_PAGE);
assertThat(message.toString()).as("Correct message").isEqualTo("test arg1 message arg2");
}
use of jakarta.servlet.jsp.PageContext in project spring-framework by spring-projects.
the class MessageTagTests method messageTagWithCodeAndArgumentAndNestedArgument.
@Test
void messageTagWithCodeAndArgumentAndNestedArgument() throws JspException {
PageContext pc = createPageContext();
final StringBuilder message = new StringBuilder();
MessageTag tag = new MessageTag() {
@Override
protected void writeMessage(String msg) {
message.append(msg);
}
};
tag.setPageContext(pc);
tag.setCode("testArgs");
assertThat(tag.doStartTag() == Tag.EVAL_BODY_INCLUDE).as("Correct doStartTag return value").isTrue();
tag.setArguments(5);
tag.addArgument(7);
assertThat(tag.doEndTag()).as("Correct doEndTag return value").isEqualTo(Tag.EVAL_PAGE);
assertThat(message.toString()).as("Correct message").isEqualTo("test 5 message 7");
}
use of jakarta.servlet.jsp.PageContext in project spring-framework by spring-projects.
the class MessageTagTests method messageTagWithCode.
@Test
void messageTagWithCode() throws JspException {
PageContext pc = createPageContext();
final StringBuilder message = new StringBuilder();
MessageTag tag = new MessageTag() {
@Override
protected void writeMessage(String msg) {
message.append(msg);
}
};
tag.setPageContext(pc);
tag.setCode("test");
assertThat(tag.doStartTag() == Tag.EVAL_BODY_INCLUDE).as("Correct doStartTag return value").isTrue();
assertThat(tag.doEndTag()).as("Correct doEndTag return value").isEqualTo(Tag.EVAL_PAGE);
assertThat(message.toString()).as("Correct message").isEqualTo("test message");
}
use of jakarta.servlet.jsp.PageContext in project spring-framework by spring-projects.
the class MessageTagTests method messageTagWithCodeAndText.
@Test
void messageTagWithCodeAndText() throws JspException {
PageContext pc = createPageContext();
final StringBuilder message = new StringBuilder();
MessageTag tag = new MessageTag() {
@Override
protected void writeMessage(String msg) {
message.append(msg);
}
};
tag.setPageContext(pc);
tag.setCode("test");
tag.setText("testtext");
assertThat(tag.doStartTag() == Tag.EVAL_BODY_INCLUDE).as("Correct doStartTag return value").isTrue();
assertThat(tag.doEndTag()).as("Correct doEndTag return value").isEqualTo(Tag.EVAL_PAGE);
assertThat((message.toString())).as("Correct message").isEqualTo("test message");
}
use of jakarta.servlet.jsp.PageContext in project spring-framework by spring-projects.
the class ThemeTagTests method themeTag.
@Test
@SuppressWarnings("serial")
void themeTag() throws JspException {
PageContext pc = createPageContext();
final StringBuilder message = new StringBuilder();
ThemeTag tag = new ThemeTag() {
@Override
protected void writeMessage(String msg) {
message.append(msg);
}
};
tag.setPageContext(pc);
tag.setCode("themetest");
assertThat(tag.doStartTag() == Tag.EVAL_BODY_INCLUDE).as("Correct doStartTag return value").isTrue();
assertThat(tag.doEndTag()).as("Correct doEndTag return value").isEqualTo(Tag.EVAL_PAGE);
assertThat(message.toString()).isEqualTo("theme test message");
}
Aggregations