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

网站网页的像素尺济宁嘉祥网站建设

网站网页的像素尺,济宁嘉祥网站建设,该网站为悬挂备案号,知名品牌vi设计Spring Webflux和Spring Web是两个完全不同的Web堆栈。 但是#xff0c; Spring Webflux继续支持基于注释的编程模型 使用这两个堆栈定义的端点可能看起来相似#xff0c;但是测试该端点的方式却大不相同#xff0c;并且编写此端点的用户必须知道哪个堆栈处于活动状态并相应… Spring Webflux和Spring Web是两个完全不同的Web堆栈。 但是 Spring Webflux继续支持基于注释的编程模型 使用这两个堆栈定义的端点可能看起来相似但是测试该端点的方式却大不相同并且编写此端点的用户必须知道哪个堆栈处于活动状态并相应地制定测试。 样本端点 考虑一个基于示例注释的端点 import org.springframework.web.bind.annotation.PostMapping import org.springframework.web.bind.annotation.RequestBody import org.springframework.web.bind.annotation.RequestMapping import org.springframework.web.bind.annotation.RestControllerdata class Greeting(val message: String)RestController RequestMapping(/web) class GreetingController {PostMapping(/greet)fun handleGreeting(RequestBody greeting: Greeting): Greeting {return Greeting(Thanks: ${greeting.message})}}使用Spring Web进行测试 如果使用Spring Boot 2启动程序以Spring Web作为启动程序来创建此应用程序请通过以下方式使用Gradle构建文件进行指定 compile(org.springframework.boot:spring-boot-starter-web) 那么将使用Mock Web运行时称为Mock MVC对这种端点进行测试 import org.junit.Test import org.junit.runner.RunWith import org.springframework.beans.factory.annotation.Autowired import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest import org.springframework.test.context.junit4.SpringRunner import org.springframework.test.web.servlet.MockMvc import org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post import org.springframework.test.web.servlet.result.MockMvcResultMatchers.contentRunWith(SpringRunner::class) WebMvcTest(GreetingController::class) class GreetingControllerMockMvcTest {Autowiredlateinit var mockMvc: MockMvcTestfun testHandleGreetings() {mockMvc.perform(post(/web/greet).content( |{|message: Hello Web|}.trimMargin())).andExpect(content().json(|{|message: Thanks: Hello Web|}.trimMargin()))} }使用Spring Web-Flux进行测试 另一方面如果引入了Spring-Webflux入门者请使用以下Gradle依赖项进行说明 compile(org.springframework.boot:spring-boot-starter-webflux) 那么此端点的测试将使用出色的WebTestClient类如下所示 import org.junit.Test import org.junit.runner.RunWith import org.springframework.beans.factory.annotation.Autowired import org.springframework.boot.test.autoconfigure.web.reactive.WebFluxTest import org.springframework.http.HttpHeaders import org.springframework.test.context.junit4.SpringRunner import org.springframework.test.web.reactive.server.WebTestClient import org.springframework.web.reactive.function.BodyInsertersRunWith(SpringRunner::class) WebFluxTest(GreetingController::class) class GreetingControllerTest {Autowiredlateinit var webTestClient: WebTestClientTestfun testHandleGreetings() {webTestClient.post().uri(/web/greet).header(HttpHeaders.CONTENT_TYPE, application/json).body(BodyInserters.fromObject( |{| message: Hello Web|}.trimMargin())).exchange().expectStatus().isOk.expectBody().json(|{| message: Thanks: Hello Web|}.trimMargin())} }结论 可以很容易地假设由于使用Spring Web和Spring Webflux堆栈的编程模型看起来非常相似因此使用Spring Web进行的这种遗留测试的测试将继续到Spring Webflux但是事实并非如此作为我们的开发人员注意所使用的基础堆栈并相应地制定测试。 我希望这篇文章阐明应该如何设计这样的测试。 翻译自: https://www.javacodegeeks.com/2017/12/annotated-controllers-spring-web-webflux-testing.html
http://www.yutouwan.com/news/454176/

相关文章:

  • 网站建设工作人员有哪些职责网络推广加盟
  • 企业网站怎么搜索优化邯郸住宅与房地产信息网
  • 手机如何制作一个网站建设摩托车型号大全
  • 手机网站淘宝客网站前后台模板
  • 自己做网站的成本要哪些东西梅州网站建设求职简历
  • 个人博客网站域名注册网络推广网站公司推荐
  • 网站建设推广关键词百度搜不到公司网站
  • acfun网站设计改进在线ps网站
  • 广西建设厅网站地址wordpress取消主题
  • 建站容易吗找个做游戏的视频网站
  • 规划和布局营销型网站的四大重点企业型网站建设
  • 免费个人网站怎么建立替代wordpress
  • 一流高职院校建设网站软件工程师工资高吗
  • 上杭网站制作新型网络营销方式
  • 广州网站制作联系方式杨凌企业网站建设
  • 用rp怎么做网站原型哈尔滨网站建设价格
  • 建设一个企业网站荥阳网
  • wordpress迁站到阿里云h5做招聘网站可以吗
  • 阜阳网站建设专业机构自适应网站做推广
  • 视频作品投票网站如何做考研比较厉害的培训机构
  • 建设网站 目标现在互联网创业可以做哪些项目
  • 绿色网站模版废旧物品手工制作图片
  • 手机网站首页经典案例中国建筑人才网是什么网站
  • 中国新农村建设网站投稿北京网页设计好的公司
  • 陶瓷刀具网站策划书手机电视直播网站大全
  • 外国网站开放的浏览器wordpress 百万
  • 襄阳微网站建设做网站用什么样的电脑
  • 虚拟机主机网站建设的几个步骤网站制作哪里做得好
  • php模板建站私家网站ip地址大全
  • 广州加盟网站建设上海网站开发团队