spring-mvc-test相关内容
我有一个 Spring MVC 控制器,它使用 Spring-Data 的分页支持: @Controller公共类模型控制器 {私有静态最终 int DEFAULT_PAGE_SIZE = 50;@RequestMapping(值 = "/models", 方法 = RequestMethod.GET)公共页面showModels(@PageableDefault(size = DEFA
..
我正在尝试测试我的控制器端点和带有 @Valid 注释的请求体.我的 Testclass 如下所示: @RunWith(SpringRunner.class)@WebMvcTest(值 = BalanceInquiryController.class,安全 = 假)公共类 BalanceInquiryControllerTest {@自动连线私有 MockMvc mockMvc;@MockBea
..
我有以下简单的控制器来捕捉任何意外的异常: @ControllerAdvice公共类异常控制器 {@ExceptionHandler(Throwable.class)@ResponseStatus(值 = HttpStatus.INTERNAL_SERVER_ERROR)@ResponseBody公共响应实体句柄异常(可抛出的前){return ResponseEntityFactory.int
..
我有一个 Spring MVC 控制器,它使用 Spring-Data 的分页支持: @Controller公共类模型控制器{私有静态最终 int DEFAULT_PAGE_SIZE = 50;@RequestMapping(value = "/models", method = RequestMethod.GET)公共页面showModels(@PageableDefault(size = D
..
我有一个主要的 @SpringBootApplication,它需要扫描特定的包才能启用 JPA 存储库,所以我使用 @EnableJpaRepositories 来指定它.现在我正在实现单元测试,我只想测试控制器组件,所以我按照官方文档中的教程使用 @WebMvcTest(MyController.class) 来测试控制器服务依赖.问题是这对我不起作用,因为它试图加载我在主 Spring Bo
..
我在 GitHub 上放了一个非常简单的示例项目来重现问题. 主要问题是我有一个 PersonController 有一个 PutMapping 来创建一个新人.为了使用 URL 填充 Location 标头以获取该人,我添加了 UriComponentsBuilder 作为该 PutMapping 的参数,如您所见这里: @PostMapping公共响应实体add(@RequestBo
..
我在web.xml中定义了一个servlet,因此我在Controller中定义了它,仅用于测试MyResource: @Controller public class TestMyServlet { MyResource servlet; @Autowired AutowireCapableBeanFactory beanFac; @Po
..
我在junit5中使用spring-boot 2.0.3.RELEASE.我刚刚尝试用模拟Mvc测试多部分请求. MockMultipartFile file = new MockMultipartFile("file", "contract.pdf", MediaType.APPLICATION_PDF_VALUE, ">".getBytes(StandardChar
..
我试图用Spring Security和Thymeleaf为视图层编写Spring MVC集成测试. 我已经使用Spring Security Integration设置了我的MockMvc对象,就像文档中的所有示例一样. 集成测试设置: import static org.springframework.security.test.web.servlet.setup.Secur
..
我已经以此方式设置了测试 @SpringBootTest @AutoConfigureMockMvc @RunWith( SpringRunner.class ) public class PublicControllerTest { @Autowired private MockMvc mvc; 这是我的控制器签名 @GetMapping( produces =
..
我正在使用Mockito和Junit并针对Spring MVC运行单元测试 我的代码流是: Service Layer-> Model Layer-> Controller Layer 我成功使用以下代码针对模型层对Controller进行了测试: @RunWith(MockitoJUnitRunner.class) public class HashLinkerControll
..
测试spring文件上传表单,controlelr签名如下所示 @RequestMapping(value = "upload", method = RequestMethod.POST) @ResponseBody public void upload(@RequestParam("file") MultipartFile multipartFile) {} 并对此进行测试 fi
..
我正在实现在这里,我的转换方法具有与以前相同的响应签名,但是现在不使用立即响应,而是使用长轮询: private Map>> requests = new ConcurrentHashMap(); @RequestMapping(value = "/{uuid}", method = RequestMet
..
我有一个Spring MVC控制器,该控制器使用Spring-Data的分页支持: @Controller public class ModelController { private static final int DEFAULT_PAGE_SIZE = 50; @RequestMapping(value = "/models", method = RequestMe
..
由于我从1.x迁移到Spring Boot 2.0.5,无意禁用安全性,所以我无法让测试角色在模拟MVC测试中工作: @RunWith(SpringRunner.class) @SpringBootTest @AutoConfigureMockMvc public class ApplicationsControllerShould { ... @Autowired
..
我正在使用Spring 3.2模拟MVC来测试我的控制器.我的代码是 @Autowired private Client client; @RequestMapping(value = "/user", method = RequestMethod.GET) public String initUserSearchForm(ModelMap model
..
我有以下简单的控制器可以捕获任何意外的异常: @ControllerAdvice public class ExceptionController { @ExceptionHandler(Throwable.class) @ResponseStatus(value = HttpStatus.INTERNAL_SERVER_ERROR) @ResponseBody
..
我在我的Spring MVC控制器上做junit - @RequestMapping(value =“index”,method = RequestMethod。 GET) public HashMap handleRequest(){ HashMap model = new HashMap
..
我最近在我的Java / Spring-MVC项目中添加了Cobertura插件。奇怪的是,我的所有单元测试都在通过,当Maven进行初始测试运行时它们仍然通过,但是当Cobertura尝试运行测试时,它们都会失败,并显示相同的错误消息: 在方法xxx.xxxx.xxxx.xxxx中期望分支目标65处的堆栈图帧;)偏移40处的V 我不知道为什么会发生这种情况,甚至不知道如何
..
我有下面的课程,我正在尝试使用JPA来获得onetomany关系。当xml消息发送到restcontroller时,消息将同时存储父表和子表,但外键始终为空。请让我知道是否有任何问题。 休息服务,我用来坚持数据,下面是我发布到这个休息方法的示例XML。 / p> @RequestMapping(value =“/ team /”,method = RequestMethod.POST
..