ICode9

精准搜索请尝试: 精确搜索
  • java – 为什么我的Spring Controller的请求映射不能在模拟WebApplicationContext中工作?2019-08-29 19:28:46

    我正在使用Spring文档here.我的目标是使用“webAppContextSetup”选项来测试我的spring配置以及我的控制器,但是我无法将控制器的方法映射到TestDispatcherServlet中.到目前为止,我有以下设置: 数据配置 <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springfra

  • 使用MockMVC测试Spring 4.0.3控制器(MVC)2019-07-28 15:19:08

    我正在尝试为RestController创建测试用例.这是一个简单的RestContorller @RestController @RequestMapping("/media") public class MediaListController { @RequestMapping(method = RequestMethod.GET) public String getAllMedia(){ return "TEST COMPLETE&qu

  • Spring Test Service自动装配导致null2019-07-27 13:18:29

    我能够运行一个Rest Controller PUT方法,该方法通过Spring Boot Application按预期使用Autowired @Service.尝试执行Spring JUnit测试时,相同的自动装配失败.我试过阅读具有类似问题的多个线程.我确定我没有通过“new”关键字创建@Service,我尝试了Context Configuration和其他方法

  • Spring MockMvc验证体是空的2019-07-17 08:29:29

    我有一个简单的Spring测试 @Test public void getAllUsers_AsPublic() throws Exception { doGet("/api/users").andExpect(status().isForbidden()); } public ResultActions doGet(String url) throws Exception { return mockMvc.perform(get(url).header(heade

  • 使用spring-test-mvc jsonpath进行测试返回null2019-07-12 08:20:14

    我正在使用Spring的“spring-test-mvc”库来测试Web控制器.我有一个非常简单的控制器,它返回一个JSON数组.然后在我的测试中我有: @Test public void shouldGetAllUsersAsJson() throws Exception { mockMvc.perform(get("/v1/users").accept(MediaType.APPLICATION_JSON))

  • 弹簧负载测试2019-07-06 16:19:30

    我已经使用spring(mock mvc)实现了一个测试单元,我正在寻找一个工具来在许多线程/进程中运行该单元(因此它将作为我的服务器的负载测试).我见过像磨床和jmeter这样的应用程序,但我不想重写整个单元,只是想使用现有的单元.有任何想法吗?解决方法:JMeter能够通过JUnit Request采样器执

  • 使用自定义UserDetails实现测试Spring Security和MvcMock2019-07-03 04:06:13

    我试图按照这篇文章[1]在我的Spring MvcMock测试中模拟安全性. 我想测试的REST服务看起来像这样: @RequestMapping(value = "/something/{id}", method = RequestMethod.DELETE) public ResponseEntity<Void> deleteXXX(@ActiveUser AppUser user, @PathVariable(value = "id") Lon

  • java – 测试时的spring messagesource2019-07-02 23:57:23

    我在我的java配置中定义了消息源: @Bean(name = "messageSource") public MessageSource messageSource() { ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource(); messageSource.setBasenames( "/i18n/ir/kia/industry/w

  • java – @RequestHeader地图映射默认情况?2019-06-29 21:06:34

    在3.2版本中,我们在控制器中使用它: @RequestHeader Map< String,String>头 问题是标题键的映射可以是任何情况,因此我们必须重新构建标题映射,将键强制为小写. 如果spring一直强制在地图中的标题上使用小写或大写,以便更容易进行标题检查,那就太好了. 研究如何改变这种行为很困难,

  • java – Spring MVC测试框架 – 不支持的媒体类型2019-06-12 11:49:29

    我正在使用spring test mvc框架为控制器编写测试.我正在尝试测试一个post请求,它会产生JSON.实际代码正在运行但测试失败. 我得到错误状态预期200但得到415这意味着不支持的媒体类型.我检查网上的所有例子,似乎我的实现是正确的.请帮帮我. MyTestcase TestStringPost()运行成功,但T

  • java – @WithUserDetails和spring boot 1.4 TestEntityManager的问题2019-06-11 14:49:46

    我对Spring Boot的TestEntityManager和@WithUserDetails注释有一个问题. 这是我的测试套件: public class AdvertisementAuthorizationTest extends AbstractIntegrationTest { private static final String IMPERSONATOR_EMAIL = "joe.hacker@gmail.com"; private final

  • java – Spring MockMvc – 如何测试REST控制器的删除请求?2019-06-07 17:58:08

    我需要测试我的控制器方法,包括删除方法.这是部分控制器代码: @RestController @RequestMapping("/api/foo") public class FooController { @Autowired private FooService fooService; // other methods which works fine in tests @RequestMapping(path="/{i

  • Spring Boot – Test – Validator:Validator的目标无效2019-05-27 17:08:26

    我在尝试运行测试时遇到以下错误: org.springframework.web.util.NestedServletException:请求处理失败;嵌套异常是java.lang.IllegalStateException:Validator [userCreateFormValidator bean]的目标无效:com.ar.empresa.forms.UserCreateForm@15c3585 引起:java.lang.IllegalStateExce

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有