📄 testshoeformbean.java
字号:
package net.sf.irunninglog.servlet.formbean;
import net.sf.irunninglog.canonical.Shoe;
import net.sf.irunninglog.junit.MockHttpServletRequest;
import net.sf.irunninglog.junit.MockHttpSession;
import net.sf.irunninglog.junit.MockPrincipal;
import net.sf.irunninglog.util.ConstantValues;
public class TestShoeFormBean extends ReferenceDataFormBeanTestCase {
public TestShoeFormBean(String name) {
super(name);
}
public void testFields() {
super.testFields();
doFieldTests(Shoe.FIELD_START_DATE);
doFieldTests(Shoe.FIELD_START_MILEAGE);
doFieldTests(Shoe.FIELD_MILEAGE);
doFieldTests(Shoe.FIELD_TOTAL_MILEAGE);
doFieldTests(Shoe.FIELD_RETIRED);
}
public void testReset() {
super.testReset();
ShoeFormBean typedBean = (ShoeFormBean) bean;
MockPrincipal principal = new MockPrincipal();
MockHttpSession session = new MockHttpSession();
typedBean.setStartMileage(null);
typedBean.setStartDate(null);
typedBean.setMileage(null);
typedBean.setTotalMileage(null);
typedBean.setRetired(null);
typedBean.reset(null, new MockHttpServletRequest(principal, session));
assertEquals(ConstantValues.STRING_ZERO, typedBean.getStartMileage());
assertNull(typedBean.getStartDate());
assertNull(typedBean.getMileage());
assertNull(typedBean.getTotalMileage());
assertEquals(ConstantValues.STRING_FALSE, typedBean.getDefault());
typedBean.setStartMileage(STRING_FOO);
typedBean.setStartDate(STRING_FOO);
typedBean.setMileage(STRING_FOO);
typedBean.setTotalMileage(STRING_FOO);
typedBean.setRetired(STRING_FOO);
typedBean.reset(null, new MockHttpServletRequest(principal, session));
assertEquals(STRING_FOO, typedBean.getStartMileage());
assertEquals(STRING_FOO, typedBean.getStartDate());
assertEquals(STRING_FOO, typedBean.getMileage());
assertEquals(STRING_FOO, typedBean.getTotalMileage());
assertEquals(ConstantValues.STRING_FALSE, typedBean.getDefault());
MockHttpServletRequest request = new MockHttpServletRequest(principal, session);
request.addParameter(Shoe.FIELD_RETIRED, STRING_FOO);
assertNotNull(request.getParameter(Shoe.FIELD_RETIRED));
typedBean.setRetired(STRING_FOO);
typedBean.reset(null, request);
assertEquals(STRING_FOO, typedBean.getRetired());
}
protected ValueBean newValueBean() {
return new ShoeFormBean();
}
protected String getValueBeanType() {
return Shoe.CANONICAL_ID;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -