📄 formtagtest.java
字号:
tag.doAfterBody();
tag.doEndTag();
EasyMock.verify();
}
public void testAll3() throws Exception {
PageContext pageContext = EasyMock.createMock(PageContext.class);
HttpServletRequest request = createMock(HttpServletRequest.class);
HttpSession session = createMock(HttpSession.class);
BodyContent bodyContent = EasyMock.createMock(BodyContent.class);
JspWriter jspWriter = EasyMock.createMock(JspWriter.class);
String html = "plain text";
String dest = "plain text";
EasyMock.expect(pageContext.getRequest()).andReturn(request)
.anyTimes();
EasyMock.expect(pageContext.getSession()).andReturn(session)
.anyTimes();
expect(request.getAttribute("test")).andReturn(new Bean())
.anyTimes();
EasyMock.expect(bodyContent.getEnclosingWriter())
.andReturn(jspWriter).anyTimes();
EasyMock.expect(bodyContent.getString()).andReturn(html).anyTimes();
jspWriter.print(dest);
EasyMock.replay(pageContext);
replay(request);
replay(session);
EasyMock.replay(bodyContent);
EasyMock.replay(jspWriter);
tag.setBeans("test");
tag.setScopes("request");
tag.setPageContext(pageContext);
tag.setBodyContent(bodyContent);
tag.doStartTag();
tag.doAfterBody();
tag.doEndTag();
EasyMock.verify();
}
public void testAll4() throws Exception {
PageContext pageContext = EasyMock.createMock(PageContext.class);
HttpServletRequest request = createMock(HttpServletRequest.class);
HttpSession session = createMock(HttpSession.class);
BodyContent bodyContent = EasyMock.createMock(BodyContent.class);
JspWriter jspWriter = EasyMock.createMock(JspWriter.class);
String html = "<input type>" + "<input type='text' name>"
+ "<input type='text' name='nil'>";
String dest = "<input type>" + "<input type='text' name>"
+ "<input type='text' name='nil' value=\"\">";
EasyMock.expect(pageContext.getRequest()).andReturn(request)
.anyTimes();
EasyMock.expect(pageContext.getSession()).andReturn(session)
.anyTimes();
expect(request.getAttribute("test")).andReturn(new Bean())
.anyTimes();
EasyMock.expect(bodyContent.getEnclosingWriter())
.andReturn(jspWriter).anyTimes();
EasyMock.expect(bodyContent.getString()).andReturn(html).anyTimes();
jspWriter.print(dest);
EasyMock.replay(pageContext);
replay(request);
replay(session);
EasyMock.replay(bodyContent);
EasyMock.replay(jspWriter);
tag.setBeans("test");
tag.setScopes("request");
tag.setPageContext(pageContext);
tag.setBodyContent(bodyContent);
tag.doStartTag();
tag.doAfterBody();
tag.doEndTag();
EasyMock.verify();
}
public void testCheckbox() throws Exception {
PageContext pageContext = EasyMock.createMock(PageContext.class);
HttpServletRequest request = createMock(HttpServletRequest.class);
HttpSession session = createMock(HttpSession.class);
BodyContent bodyContent = EasyMock.createMock(BodyContent.class);
JspWriter jspWriter = EasyMock.createMock(JspWriter.class);
String html = "<input type='checkbox' name='name'>"
+ "<input type='checkbox' name='name' value='other'>"
+ "<input type='button' name='nil'>"
+ "<input type='radio' name='nil'>"
+ "<input type='radio' name='nil' value='other'>";
String dest = "<input type='checkbox' name='name'>"
+ "<input type='checkbox' name='name' value='other'>"
+ "<input type='button' name='nil'>"
+ "<input type='radio' name='nil'>"
+ "<input type='radio' name='nil' value='other'>";
EasyMock.expect(pageContext.getRequest()).andReturn(request)
.anyTimes();
EasyMock.expect(pageContext.getSession()).andReturn(session)
.anyTimes();
expect(request.getAttribute("test")).andReturn(new Bean())
.anyTimes();
EasyMock.expect(bodyContent.getEnclosingWriter())
.andReturn(jspWriter).anyTimes();
EasyMock.expect(bodyContent.getString()).andReturn(html).anyTimes();
jspWriter.print(dest);
EasyMock.replay(pageContext);
replay(request);
replay(session);
EasyMock.replay(bodyContent);
EasyMock.replay(jspWriter);
tag.setBeans("test");
tag.setScopes("request");
tag.setPageContext(pageContext);
tag.setBodyContent(bodyContent);
tag.doStartTag();
tag.doAfterBody();
tag.doEndTag();
EasyMock.verify();
}
public void testTextarea() throws Exception {
PageContext pageContext = EasyMock.createMock(PageContext.class);
HttpServletRequest request = createMock(HttpServletRequest.class);
HttpSession session = createMock(HttpSession.class);
BodyContent bodyContent = EasyMock.createMock(BodyContent.class);
JspWriter jspWriter = EasyMock.createMock(JspWriter.class);
String html = "<textarea name='other'></textarea>"
+ "<textarea name='nil'></textarea>";
String dest = "<textarea name='other'></textarea>"
+ "<textarea name='nil'></textarea>";
EasyMock.expect(pageContext.getRequest()).andReturn(request)
.anyTimes();
EasyMock.expect(pageContext.getSession()).andReturn(session)
.anyTimes();
expect(request.getAttribute("test")).andReturn(new Bean())
.anyTimes();
EasyMock.expect(bodyContent.getEnclosingWriter())
.andReturn(jspWriter).anyTimes();
EasyMock.expect(bodyContent.getString()).andReturn(html).anyTimes();
jspWriter.print(dest);
EasyMock.replay(pageContext);
replay(request);
replay(session);
EasyMock.replay(bodyContent);
EasyMock.replay(jspWriter);
tag.setBeans("test");
tag.setScopes("request");
tag.setPageContext(pageContext);
tag.setBodyContent(bodyContent);
tag.doStartTag();
tag.doAfterBody();
tag.doEndTag();
EasyMock.verify();
}
public void testSelect() throws Exception {
PageContext pageContext = EasyMock.createMock(PageContext.class);
HttpServletRequest request = createMock(HttpServletRequest.class);
HttpSession session = createMock(HttpSession.class);
BodyContent bodyContent = EasyMock.createMock(BodyContent.class);
JspWriter jspWriter = EasyMock.createMock(JspWriter.class);
String html = "<select name='other'></select>"
+ "<option value='output select'>output select</option>"
+ "<select name='nil'><option></option></select>"
+ "<select name='other'><option value='test'>test</option></select>"
+ "<select name='nil'><option value='bean'>bean</option></select>"
+ "<select name='types'><option value='1'>1</option><option value='2'>2</option></select>"
+ "<select name='name'><option value='1'>1</option></select>"
+ "<select name='objects'><option value='object'>object</option></select>";
String dest = "<select name='other'></select>"
+ "<option value='output select'>output select</option>"
+ "<select name='nil'><option></option></select>"
+ "<select name='other'><option value='test'>test</option></select>"
+ "<select name='nil'><option value='bean'>bean</option></select>"
+ "<select name='types'><option value='1' selected>1</option><option value='2' selected>2</option></select>"
+ "<select name='name'><option value='1'>1</option></select>"
+ "<select name='objects'><option value='object' selected>object</option></select>";
EasyMock.expect(pageContext.getRequest()).andReturn(request)
.anyTimes();
EasyMock.expect(pageContext.getSession()).andReturn(session)
.anyTimes();
expect(request.getAttribute("test")).andReturn(new Bean())
.anyTimes();
EasyMock.expect(bodyContent.getEnclosingWriter())
.andReturn(jspWriter).anyTimes();
EasyMock.expect(bodyContent.getString()).andReturn(html).anyTimes();
jspWriter.print(dest);
EasyMock.replay(pageContext);
replay(request);
replay(session);
EasyMock.replay(bodyContent);
EasyMock.replay(jspWriter);
tag.setBeans("test");
tag.setScopes("request");
tag.setPageContext(pageContext);
tag.setBodyContent(bodyContent);
tag.doStartTag();
tag.doAfterBody();
tag.doEndTag();
EasyMock.verify();
}
public class Bean {
String name = "bean";
String nil = null;
String[] types = new String[] {"1", "2", null};
Object[] objects = new Object[] {"object", null};
public void setName(String nameIn) {
name = nameIn;
}
public String getName() {
return name;
}
public void setNil(String nil2) {
nil = nil2;
}
public String getNil() {
return nil;
}
public void setTypes(String[] types2) {
types = types2;
}
public String[] getTypes() {
return types;
}
public void setObjects(Object[] objects2) {
objects = objects2;
}
public Object[] getObjects() {
return objects;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -