当前位置: 首页 > 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://wiki.neutronadmin.com/news/395064/

相关文章:

  • 网站模板无忧网站优化网络
  • 延吉有没有做网站的如何搭建网上商城
  • 如何写网站代码是什么原因wordpress文件存放不同目录
  • 建网站的网站有哪些上海高端品牌网站建设
  • 网站手机版怎么弄软文发稿
  • 深圳设计公司企业网站上海市电话黄页本
  • 2019网站怎么做如何在手机上做广告
  • 多个网站 备案吗wordpress5.0.2图集怎么发布
  • 东莞网站排名推广企业网站建设如何选择网络公司
  • 焦作建网站wordpress实时刷新模块
  • 个人 可以做网站备案吗WordPress免插件实现QQ咨询
  • 宁夏建设监理协会网站用付费网站做推广
  • 现在做什么个人网站好linux 国外网站
  • 凤岗网站建设微信运营商电话
  • 如何判断网站做没做404北京 做网站
  • asp.net 网站图标做二手车网站怎么做的
  • 打电话来说做网站 然后答应了怎么建设游网站主页
  • 重庆网站仿站手机建站系统
  • 昆山网站制作哪家好中信建设有限责任公司刚果金
  • 免费建站的方法流程怎么让别人做网站
  • 在国外服务器上做网站项目如何赚钱好用的代码网站
  • 网站设计可以在手机上做吗wordpress 500 - 内部服务器错误
  • 完成网站开发需要什么样技术vs2010网站设计用整张图片做背景
  • 建设外贸网站费用智慧团建手机登录端口
  • 网站seo收录工具wordpress 占用cpu
  • 许昌建设局网站google推广方式和手段有哪些
  • 网站取消备案免费的宣传方式
  • 先用ps后用dw做网站wordpress 主题 主机
  • 做企业网站需要资质吗用nas做网站
  • .net 网站 源代码长春的网站建设