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

怎样让百度收取我的网站超链接网站怎么做

怎样让百度收取我的网站,超链接网站怎么做,手机网站制作行业排行,免费建站个人网站spring 消息传递机制在上一篇文章中#xff0c;我们已经开始讨论基于消息的通信中的消费者驱动的合同测试 。 在今天的帖子中#xff0c;我们将在测试工具箱中包含另一个工具#xff0c;但是在此之前#xff0c;让我对显微镜下的系统进行快速回顾。 它有两项服务#xff0… spring 消息传递机制 在上一篇文章中我们已经开始讨论基于消息的通信中的消费者驱动的合同测试 。 在今天的帖子中我们将在测试工具箱中包含另一个工具但是在此之前让我对显微镜下的系统进行快速回顾。 它有两项服务 订单服务和货运服务 。 订单服务将消息/事件发布到消息队列然后运货服务从那里使用它们。 通过寻找合适的测试支架我们发现了Pact框架准确地说是Pact JVM 。 该协议提供了编写消费者和生产者测试的简单明了的方法没有为不进行消费者驱动的合同测试提供任何借口。 但是该领域还有另一个参与者Spring Cloud Contract 这就是我们今天要讨论的内容。 首先 Spring Cloud Contract适合基于最佳的基于JVM的项目该项目建立在出色的Spring产品组合之上尽管您也可以使其在多语言场景中工作。 另外 Spring Cloud Contract采用的协作流程与Pact教给我们的协作流程略有不同这不一定是一件坏事。 让我们直接说清楚。 由于我们只研究消息传递因此Spring Cloud Contract要求我们要做的第一件事就是定义消息传递协议规范该规范是使用便捷的Groovy Contract DSL编写的。 package contracts org.springframework.cloud.contract.spec.Contract.make { name OrderConfirmed Event label order     input { createOrder() triggeredBy( createOrder() ) }     outputMessage { sentTo orders         body([ orderId: $(anyUuid()), paymentId: $(anyUuid()), amount: $(anyDouble()), street: $(anyNonBlankString()), city: $(anyNonBlankString()), state: $(regex( [AZ]{2} )), zip: $(regex( [0-9]{5} )), country: $(anyOf( USA , Mexico )) ])         headers { header( Content-Type , application/json ) } } } 它类似于我们已经熟悉的许多Pact规范如果您不是Groovy的忠实拥护者 则不需要真正学习它即可使用Spring Cloud Contract 。 这里有趣的部分是triggeredBy和sentTo块基本上这些轮廓是如何被生成的消息或触发并且其中它应该分别着陆通道或队列名称。 在这种情况下 createOrder只是方法名称我们必须为其提供实现。 package com.example.order; import java.math.BigDecimal; import java.util.UUID; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.cloud.contract.verifier.messaging.boot.AutoConfigureMessageVerifier; import org.springframework.integration.support.MessageBuilder; import org.springframework.messaging.MessageChannel; import org.springframework.test.context.junit4.SpringRunner; import com.example.order.event.OrderConfirmed; RunWith (SpringRunner. class ) SpringBootTest AutoConfigureMessageVerifier public class OrderBase { Autowired private MessageChannel orders;     public void createOrder() { final OrderConfirmed order new OrderConfirmed(); order.setOrderId(UUID.randomUUID()); order.setPaymentId(UUID.randomUUID()); order.setAmount( new BigDecimal( 102.32 )); order.setStreet( 1203 Westmisnter Blvrd ); order.setCity( Westminster ); order.setCountry( USA ); order.setState( MI ); order.setZip( 92239 ); orders.send( MessageBuilder .withPayload(order) .setHeader( Content-Type , application/json ) .build()); } } 不过这里只剩下一个小细节这些合同是由提供者或更确切地说生产者而不是消费者来管理的。 不仅如此生产者有责任为消费者发布所有存根以便他们能够针对其编写测试。 当然与Pact所采用的路径不同但是从好的方面来说针对生产者的测试套件是由Apache Maven / Gradle插件100生成的。 plugin groupId org.springframework.cloud/ groupId artifactId spring-cloud-contract-maven-plugin/ artifactId version 2.1.4.RELEASE/ version extensions true/ extensions configuration packageWithBaseClasses com.example.order/ packageWithBaseClasses / configuration / plugin 您可能已经注意到该插件将假定基本测试类必须提供createOrder方法实现的那些类位于com.example.order包中即我们放置OrderBase类的确切位置。 要完成设置我们需要向pom.xml文件中添加一些依赖项。 dependencyManagement dependencies dependency groupId org.springframework.cloud/ groupId artifactId spring-cloud-dependencies/ artifactId version Greenwich.SR4/ version type pom/ type scope import/ scope / dependency dependency groupId org.springframework.boot/ groupId artifactId spring-boot-dependencies/ artifactId version 2.1.10.RELEASE/ version type pom/ type scope import/ scope / dependency / dependencies / dependencyManagement dependencies dependency groupId org.springframework.cloud/ groupId artifactId spring-cloud-starter-contract-verifier/ artifactId scope test/ scope / dependency dependency groupId org.springframework.boot/ groupId artifactId spring-boot-starter-test/ artifactId scope test/ scope / dependency / dependencies 而且我们已经完成了生产者方面的工作 如果我们现在运行mvn clean install 将发生两件事。 首先您会注意到已经运行并通过了一些测试尽管我们没有编写任何测试但这些测试都是以我们的名义生成的。 ------------------------------------------------------- TESTS ------------------------------------------------------- Running com.example.order.OrderTest .... Results : Tests run: 1 , Failures: 0 , Errors: 0 , Skipped: 0 其次也将生成发布针对消费者的存根在这种情况下将其捆绑到order-service-messaging-contract-tests-0.0.1-SNAPSHOT-stubs.jar中 。 ... [INFO] [INFO] --- spring-cloud-contract-maven-plugin: 2.1 . 4 .RELEASE:generateStubs ( default -generateStubs) order-service-messaging-contract-tests --- .RELEASE:generateStubs ( [INFO] Files matching this pattern will be excluded from stubs generation [] [INFO] Files matching pattern will be excluded from stubs generation [] [INFO] Building jar: order-service-messaging-contract-tests- 0.0 . 1 -SNAPSHOT-stubs.jar [INFO] .... 太好了因此我们已经发布了消息传递合同规范和存根现在就在消费者的领域即Shipment Service 。 消费者最棘手的部分可能是配置所选的消息传递集成库。 在我们的案例中它将是Spring Cloud Stream但是也可以使用其他集成 。 理解Spring Cloud Contract在消费者方面如何工作的最快方法是从头开始并首先查看完整的示例测试套件。 RunWith (SpringRunner. class ) SpringBootTest AutoConfigureMessageVerifier AutoConfigureStubRunner ( ids com.example:order-service-messaging-contract-tests::stubs , stubsMode StubRunnerProperties.StubsMode.LOCAL ) public class OrderMessagingContractTest { Autowired private MessageVerifierMessage? verifier; Autowired private StubFinder stubFinder; Test public void testOrderConfirmed() throws Exception { stubFinder.trigger( order );         final Message? message verifier.receive( orders ); assertThat(message, notNullValue()); assertThat(message.getPayload(), isJson( allOf(List.of( withJsonPath( $.orderId ), withJsonPath( $.paymentId ), withJsonPath( $.amount ), withJsonPath( $.street ), withJsonPath( $.city ), withJsonPath( $.state ), withJsonPath( $.zip ), withJsonPath( $.country ) )))); } } 在最上方 AutoConfigureStubRunner引用生产者发布的存根有效地来自order-service-messaging-contract-tests-0.0.1-SNAPSHOT-stubs.jar存档中的存根 。 StubFinder通过调用stubFinder.trigger“ order”帮助我们为测试用例选择正确的存根并触发特定的消息传递合同验证流程。 “ order”值不是任意的它应与分配给合同规范的标签匹配在我们的示例中我们将其定义为 package contracts org.springframework.cloud.contract.spec.Contract.make { ... label order ... } 这样测试应该看起来简单而直接触发流程验证消息是否已放入消息传递通道并满足消费者的期望。 从配置的角度来看我们只需要提供此消息传递通道即可运行测试。 SpringBootConfiguration public class OrderMessagingConfiguration { Bean PollableChannel orders() { return MessageChannels.queue().get(); } } 再说一次bean的名称orders不是一个随机选择它必须从合同规范中获取很多目的地 package contracts org.springframework.cloud.contract.spec.Contract.make { ... outputMessage { sentTo orders ... } ... } 最后但并非最不重要的一点让我们枚举使用者方面所需的依赖关系幸运的是无需使用任何其他的Apache Maven或Gradle插件。 dependencyManagement dependencies dependency groupId org.springframework.cloud/ groupId artifactId spring-cloud-dependencies/ artifactId version Greenwich.SR4/ version type pom/ type scope import/ scope / dependency / dependencies / dependencyManagement dependencies dependency groupId org.springframework.cloud/ groupId artifactId spring-cloud-starter-contract-verifier/ artifactId scope test/ scope / dependency dependency groupId org.springframework.cloud/ groupId artifactId spring-cloud-starter-contract-stub-runner/ artifactId scope test/ scope / dependency dependency groupId org.springframework.cloud/ groupId artifactId spring-cloud-stream/ artifactId version 2.2.1.RELEASE/ version type test-jar/ type scope test/ scope classifier test-binder/ classifier / dependency / dependencies 在这里快速说明。 最后一个依赖关系是一个很重要的难题它带来了Spring Cloud Stream与Spring Cloud Contract的集成。 这样消费者就全都准备好了。 ------------------------------------------------------- TESTS ------------------------------------------------------- Running com.example.order.OrderMessagingContractTest ... Results : Tests run: 1 , Failures: 0 , Errors: 0 , Skipped: 0 为了结束循环我们应该回顾消费者驱动的合同测试的核心承诺之一允许生产者在不破坏消费者的情况下发展合同。 实际上这意味着消费者可以将测试归还给生产者尽管这样做的轻率性与Spring Cloud Contract无关 。 原因很简单生产者是那些首先编写消息合同规范的人并且期望从这些规范中生成的测试无法抵御任何重大更改。 尽管如此对于生产者来说了解消费者如何使用他们的消息还是有很多好处的所以请给我一些想法。 满怀希望这是一个有趣的话题。 Spring Cloud Contract带来了将消费者驱动的合约测试应用于消息传递的不同观点。 它是Pact JVM的一个有吸引力的替代方法特别是如果您的应用程序和服务已经依赖Spring项目 。 与往常一样完整的项目资源可在Github上找到 。 翻译自: https://www.javacodegeeks.com/2019/12/spring-covered-again-consumer-driven-contract-testing-messaging-continued.htmlspring 消息传递机制
http://www.pierceye.com/news/321848/

相关文章:

  • 励志网站织梦源码做电子杂志用什么网站
  • 电子设计网站wordpress数据清除
  • 义乌网站推广中国住房和城乡建设厅网站
  • 濮阳seo网站建设商贸公司寮步网站建设
  • 百姓网网站建设如何在社交网站做销售
  • 网站微信认证费用介绍网络营销的短文
  • 北京微网站修改wordpress后台登陆
  • 网站建设管理工作情况报告企业在线
  • ps临摹网站营销型网站传统网站
  • 对电子商务网站建设和管理的理解学网站开发应该学什么软件
  • 建设网站的app英文成品网站模板下载
  • 破解版软件下载网站网站图片处理方案
  • 安徽网站建设方案服务汉中建设工程招标网
  • 网站建设公司企业模板下载阿里巴巴官网国际站
  • icp备案网站信息修改百度小说排行榜总榜
  • 崇明专业网站建设做网站后台要学什么
  • 专门做搜索种子的网站有哪些吉林平台网站建设多少钱
  • seo网站优化案例高端品牌裙子
  • 合肥需要做网站的公司无锡工程建设信息网站
  • 网站服务器有哪几种做招聘网站没有数据
  • 合肥手机网站制作建设自己做视频的网站
  • 公司网站备案名称广东建设项目备案公示网站
  • 网站建设设计维片长治网站建设公司
  • 商务网站建设兴田德润电话多少世界著名网站开发语言
  • 湖北网站建设公司微信手机网站设计
  • 徐州网站制作需要多少钱网站规划设计方案
  • 设计师常用网站门户重庆注册公司流程和费用标准
  • 网站图片太多怎么优化全民推广
  • 湖南做网站 e磐石网络做网站网站盈利会怎么样
  • 网站关闭流程保定风泉网络科技有限公司