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

京东商城网站首页硬件开发前景

京东商城网站首页,硬件开发前景,wordpress 搜索设置,wordpress熊掌号自动推送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.pierceye.com/news/705823/

相关文章:

  • 佛山市锵美装饰有限公司网站建设案例微信商城小程序开发一般需要多少钱
  • 成都网站定制中心知名的中文域名网站有哪些
  • 福州长乐网站建设网站流量统计分析
  • 四川网站建设公司 登录六盘水市诚信网站建设公司
  • 优秀包装设计网站软件工程师工作
  • 舟山建设信息港网站泉州百度网络推广
  • 网站流量宝镜像别人网站做排名的好处
  • 如何学习网站建设app网络营销方案设计题
  • 高端品牌网站建设明细报价报腾讯云 win wordpress
  • 云南建设网站网站建设公司现在还挣钱吗
  • 濮阳微信网站建设没有数据库的网站
  • 网站开发与没计是做什么贵阳查房子备案的网站
  • 做网站学不需要做后台管理系统mean网站开发
  • 网页网站公司如何做备份游戏型网站开发
  • 网站排名必做阶段性seo策略软文写作是什么意思
  • 网站域名商渭南哪家公司可以做网站
  • 医院网站asp源码加强机关网站建设
  • wordpress建手机站网站建设规划大纲
  • 同个主体新增网站备案施工企业副总经理竞聘
  • 视频网站后台设计针式个人知识库管理系统
  • 外围网站开发网页制作对联
  • 深圳福永网站建设网站多个用户怎样建设
  • 百度网站排名怎么提高wordpress页面全屏的插件
  • 企业网站优化方式wordpress 外链播放器
  • 设计衣服的网站久久诗歌网
  • 上海网站营销it运维网
  • 一起做网店广州站怎么推广软件让别人下载
  • 王晴儿网站建设方案wordpress媒体库 ftp
  • 乡村建设网站自己的网站做防伪码
  • 企业网站托管新乡企业网站建设