当前位置: 首页 > news >正文

网站建设初步策划方案自己做网站花钱么

网站建设初步策划方案,自己做网站花钱么,wordpress基本,网站开发实验结论在将单元测试postmortem编码到另一个项目创建的代码时,我遇到了如何使用initBinder模拟与控制器绑定的验证器的这个问题#xff1f;通常我会考虑确保我的输入是有效的,并且在验证器中进行一些额外的调用,但在这种情况下,验证器类与通过几个数据源进行检查相结合,并且测试变得相…在将单元测试postmortem编码到另一个项目创建的代码时,我遇到了如何使用initBinder模拟与控制器绑定的验证器的这个问题通常我会考虑确保我的输入是有效的,并且在验证器中进行一些额外的调用,但在这种情况下,验证器类与通过几个数据源进行检查相结合,并且测试变得相当麻烦.耦合可追溯到使用的一些旧的常用库,并且不在我目前的工作范围内来修复它们.起初,我试图使用PowerMock和嘲笑静态方法来嘲笑验证器的外部依赖关系,但是最终遇到一个类,当类被创建时需要一个数据源,没有找到一个方法.然后,我试图使用普通的mockito工具来嘲笑验证器,但是也没有.然后尝试将验证器设置在mockMvc调用中,但不会为验证器注册Mock注释.最后跑到this question.但是由于控制器本身没有现场验证器,所以也失败了.那么,我该如何解决这个问题呢验证器public class TerminationValidator implements Validator {// JSR-303 Bean Validator utility which converts ConstraintViolations to Springs BindingResultprivate CustomValidatorBean validator new CustomValidatorBean();private Class extends Default level;public TerminationValidator(Class extends Default level) {this.level level;validator.afterPropertiesSet();}public boolean supports(Class clazz) {return Termination.class.equals(clazz);}Overridepublic void validate(Object model,Errors errors) {BindingResult result (BindingResult) errors;// Check domain object against JSR-303 validation constraintsvalidator.validate(result.getTarget(),result,this.level);[...]}[...]}控制器public class TerminationController extends AbstractController {InitBinder(termination)public void initBinder(WebDataBinder binder,HttpServletRequest request) {binder.setValidator(new TerminationValidator(Default.class));binder.setAllowedFields(new String[] { termId[**],terminationDate,accountSelection,iban,bic });}[...]}测试类RunWith(MockitoJUnitRunner.class)public class StandaloneTerminationTests extends BaseControllerTest {Mockprivate TerminationValidator terminationValidator new TerminationValidator(Default.class);InjectMocksprivate TerminationController controller;private MockMvc mockMvc;OverrideBeforepublic void setUp() throws Exception {initMocks(this);mockMvc standaloneSetup(controller).setCustomArgumentResolvers(new TestHandlerMethodArgumentResolver()).setValidator(terminationValidator).build();ReflectionTestUtils.setField(controller,validator,terminationValidator);when(terminationValidator.supports(any(Class.class))).thenReturn(true);doNothing().when(terminationValidator).validate(any(),any(Errors.class));}[...]}例外java.lang.IllegalArgumentException: Could not find field [validator] of type [null] on target [my.application.web.controller.TerminationController560508be]at org.springframework.test.util.ReflectionTestUtils.setField(ReflectionTestUtils.java:111)at org.springframework.test.util.ReflectionTestUtils.setField(ReflectionTestUtils.java:84)at my.application.web.controller.termination.StandaloneTerminationTests.setUp(StandaloneTerminationTests.java:70)at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)at java.lang.reflect.Method.invoke(Method.java:597)at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)at org.junit.runners.ParentRunner.run(ParentRunner.java:309)at org.mockito.internal.runners.JUnit45AndHigherRunnerImpl.run(JUnit45AndHigherRunnerImpl.java:37)at org.mockito.runners.MockitoJUnitRunner.run(MockitoJUnitRunner.java:62)at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
http://www.yutouwan.com/news/395064/

相关文章:

  • 一个云主机可以做多少网站求个网站
  • 盐城市建设局网站物业资质胶州人才网
  • 怎么做淘宝联盟的推广网站顺的网站建设案例
  • 怎样查网站和增加网站汉中建设工程招投标网
  • vscode 网站开发教程百度找不到 网站
  • 淘宝刷单网站开发网上商城 网站
  • 网站关键字优化简介东莞网络推广代理
  • 食品销售公司网站制作深圳企业建站程序
  • 邯郸建设局网站网站建设实务课本
  • php做网站不兼容ie8佛山专业做网站的
  • 完整网站开发需要多久免费看电视剧网站2020
  • 论坛网站模板深圳公司注册的服务机构
  • 东莞设计网站服务的公司销售网站建设的短文
  • 网站合作客户网页设计与制作免费模板
  • 重庆专业网站推广流程任县建设局网站
  • 做网站接私活网站建设有哪几种形式
  • 自己做的网站怎么上传网站开发项目预算表
  • 集团网站策划方案青云 wordpress
  • 网站登陆模板下载网站备案 取消接入
  • 网站建设及维护 东营做电商网站要服务器吗
  • 江苏中星建设集团网站新品发布会致辞稿
  • 有网站源码去哪里做全屋家具定制价格表
  • 石家庄做标书的网站小程序免费制作平台360
  • 国内规模大的建站公司牡丹江宣传网
  • 小昆山网站建设免费网站生成软件
  • 流行网站设计手机app免费下载
  • 简单的阿里云建设网站网站开发交付清单
  • 金华网站建设设计做企业官网需要什么条件
  • 网站开发png图标素材海淀网站建设多少钱
  • 58同城做网站的电话网站顶部滑动展示的div层提示效果