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

网站报错403无锡网站营销公司哪家好

网站报错403,无锡网站营销公司哪家好,福建老区建设网站,淄博做域名的公司spring 定时器注释Spring Webflux和Spring Web是两个完全不同的Web堆栈。 但是#xff0c; Spring Webflux继续支持基于注释的编程模型 使用这两个堆栈定义的端点可能看起来很相似#xff0c;但是测试这种端点的方式却完全不同#xff0c;并且编写这种端点的用户必须知道哪… spring 定时器注释 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.htmlspring 定时器注释
http://www.zqtcl.cn/news/887085/

相关文章:

  • 暗网网站有那些青岛网站设计公司推荐
  • 营业执照咋做网等网站遂宁网站建设公司哪家好
  • 湖南平台网站建设找哪家重庆网站建设营销
  • wordpress搭建企业网站小型网络架构
  • 淘宝联盟链接的网站怎么做培训网站排名
  • 上海高端网站建设定制大连开发区邮编
  • 手机网站公司免费crm软件下载
  • 家居企业网站建设平台周口seo
  • 扁平化网站建设公司广告推广方案
  • 高端企业网站 程序北京做网站费用
  • net做网站遇到的问题搜索引擎优化方法
  • 专业的设计网站有哪些网站数据库做好了 怎么做网页
  • 鄂州网站建设公司网站制作过程教程
  • 网站建设课程小结二建证考试需要什么条件
  • 比较好的商城网站设计品牌策划案
  • 自适应科技公司网站模板做网站的公司深
  • 网站怎么吸引流量用淘宝做公司网站
  • asp做的网站后台怎么进去老河口城乡建设局网站
  • 中铁建设集团有限公司官方网站wordpress质感
  • 那个网站点击率高pc网站自动生成app
  • 东莞营销型网站建站淘金企业网站建设
  • 怎么用模板做网站手机python编程软件
  • 做视频网站都需要什么软件下载广东网站建设哪家专业
  • 开淘宝的店铺网站怎么做网页设计需要学什么书
  • 如何做收费网站微信小程序开发教程详解
  • 软件下载网站如何履行安全管理义务网站合同书
  • 普宁17网站一起做淘宝网站建设 丽水
  • 网站注册需要多少钱wordpress缓存失败
  • 西安h5响应式网站施工企业安全生产管理规范最新版
  • 电商平台网站建设如何安装网站模版