gpt4 book ai didi

testing - 是否可以使用 Springs MockMvc 测试 Portlet Controller ?

转载 作者:行者123 更新时间:2023-11-28 20:01:19 24 4
gpt4 key购买 nike

您可以像这样使用 MockMvc 类测试您的“普通”Spring MVC Controller :

    mockMvc
.perform(get("/my/fine/path"))
.andExpect(status().isOk());

来自Spring Reference on Handler Mappings :

Since there is really no such thing as a URL within a Portlet, we must use other mechanisms to control mappings. The two most common are the portlet mode and a request parameter, but anything available to the portlet request can be used in a custom handler mapping.

MockMvc 是否仅适用于“普通” Controller ,或者在测试 Portlet Controller 时是否有使用它的方法?

最佳答案

检查 spring-test-portlet-mvc ( https://github.com/markusf/spring-test-portlet-mvc ),它将 MockMvc 的特性暴露给 Portal 上下文!

关于testing - 是否可以使用 Springs MockMvc 测试 Portlet Controller ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17025501/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com