天道酬勤,学无止境

mockserver

空手道框架——模拟服务器定义线程池(Karate framework - mock server define thread pool)

问题 我正在使用空手道框架进行负载测试并使用以下带有 -T 选项的命令来破坏模拟服务器以实现更高的 tps 并且它似乎没有受到影响并且它始终运行 8 个线程,这是服务器中的核心数。 java -jar karate-0.9.5.RC5.jar -T 100 -m featurefilename.feature -p 8080 请帮助定义空手道模拟服务器的线程池计数。 回答1 目前不支持此功能。 我也可以确认这不是项目的优先事项。 欢迎你贡献代码,相关部分在这里:FeatureServer.java。

2021-12-23 22:07:50    分类:技术分享    java   karate   mockserver

Karate framework - mock server define thread pool

I'm using karate framework for load testing and ruining mock server using following command with -T option to achive higher tps and it seems it is not effected and its always run 8 threads which is number of cores in the server. java -jar karate-0.9.5.RC5.jar -T 100 -m featurefilename.feature -p 8080 Kindly help to define thread pool count for the karate mock server.

2021-11-26 04:34:54    分类:问答    java   karate   mockserver

Spring MockRestServiceServer 处理多个异步请求(Spring MockRestServiceServer handling multiple Async requests)

问题 我有一个协调器 spring 启动服务,它向外部服务发出几个异步休息请求,我想模拟这些服务的响应。 我的代码是: mockServer.expect(requestTo("http://localhost/retrieveBook/book1")) .andExpect(method(HttpMethod.GET)) .andRespond(MockRestResponseCreators.withStatus(HttpStatus.OK) .body("{\"book\":{\"title\":\"xxx\",\"year\":\"2000\"}}") .contentType(MediaType.APPLICATION_JSON)); mockServer.expect(requestTo("http://localhost/retrieveFilm/film1")) .andExpect(method(HttpMethod.GET)) .andRespond(MockRestResponseCreators.withStatus(HttpStatus.OK) .body("{\"film\":{\"title\":\"yyy\",\"year\":\"1900\"}}") .contentType(MediaType.APPLICATION_JSON))

2021-10-20 19:03:12    分类:技术分享    spring-boot   junit   mockserver

带有本地数据的 UI5 模拟服务器:“rootUri”不工作(UI5 Mock Server with Local Data: “rootUri” Not Working)

问题 我目前正在关注 UI5 教程并停留在第 27 步:模拟服务器配置。 问题是模拟服务器的rootUri配置。 我按照教程使用 Northwind OData 服务,并在manifest.json为发票配置了dataSource 。 现在,为了使用本地模拟数据而不是在线服务,我按照教程中的说明创建了必要的文件。 当我然后运行mockServer.html ,服务器不会将服务请求重定向到本地模拟数据,而是发出请求并由于网络安全问题而失败。 如果我使用以下rootUri ,模拟服务器不会重定向并且服务请求失败: // Snippet from mockserver.js var oMockServer = new MockServer({ rootUri: "/destinations/northwind/V2/Northwind/Northwind.svc/" }); 无法加载 https://services.odata.org/V2/Northwind/Northwind.svc/$metadata?sap-language=DE:对预检请求的响应未通过访问控制检查:No 'Access-Control-Allow-请求的资源上存在 Origin' 标头。 因此,不允许访问来源“https://webidetesting9515320-s0015250556trial

2021-10-19 09:56:13    分类:技术分享    odata   sapui5   mockserver

如何使用 MockRestServiceServer 测试 RestClientException(How to test a RestClientException with MockRestServiceServer)

问题 在测试 RestClient-Implementation 时,我想模拟一个 RestClientException ,该异常可能由该实现中的某些 RestTemplate-methods fe delete-method 抛出: @Override public ResponseEntity<MyResponseModel> documentDelete(String id) { template.setErrorHandler(new MyResponseErrorHandler()); ResponseEntity<MyResponseModel> response = null; try { String url = baseUrl + "/document/id/{id}"; response = template.exchange(url, DELETE, null, MyResponseModel.class, id); } catch (RestClientException ex) { return handleException(ex); } return response; } 我怎样才能做到这一点? 我以这种方式定义模拟服务器: @Before public void setUp() { mockServer =

2021-10-09 19:15:07    分类:技术分享    java   spring   mocking   mockserver

如何使用具有多个 URL 的 MockRestServiceServer?(How to use MockRestServiceServer with multiple URLs?)

问题 我需要在 MockRestServiceServer 的实例上配置多个期望。 期望是针对两个不同的 URL: 呼叫 URL #1 调用 URL #1(第二次) 调用 URL #2 同一个 URL 被调用两次,然后第三次调用具有不同请求参数的同一个 URL。 我有一个负载平衡的 RestTemplate 实例可以注入到我的测试中,我将它传递给 MockRestServiceServer.createServer()。 我试图将这 3 个期望值内联到我的 MockRestServiceServer 实例中,但测试失败,声称第 3 个 URL 是预期的,但它看到了第一个。 似乎我要么覆盖了期望,要么在这里共享了一些有状态的东西,使模拟服务器保持在错误的状态。 谁能告诉我如何正确执行此操作的示例? 回答1 如果您在 Mock Server org.springframework.test.web.client.MockRestServiceServer#MockRestServiceServer不使用默认期望管理器,则可以解决您的问题:它接受org.springframework.test.web.client.RequestExpectationManager的参数。 您可以传递这种类型: org.springframework.test.web.client

2021-10-08 18:55:17    分类:技术分享    junit   mocking   spring-test   mockserver

How to use MockRestServiceServer with multiple URLs?

I need to configure multiple expectations on an instance of MockRestServiceServer. The expectations are for two different URLs: Call URL #1 Call URL #1 (for a second time) Call URL #2 The same URL is called twice, then a 3rd call is made to the same URL with different request params. I have one instance of a load-balanced RestTemplate available to inject into my test, and I pass this to MockRestServiceServer.createServer(). I've tried to inline these 3 expectations to my MockRestServiceServer instance but the test fails claiming the 3rd URL was expected but it saw the 1st. It seems like I'm

2021-09-02 23:44:11    分类:问答    junit   mocking   spring-test   mockserver

Spring MockRestServiceServer handling multiple Async requests

I have an orchestrator spring boot service that makes several async rest requests to external services and I would like to mock the responses of those services. My code is: mockServer.expect(requestTo("http://localhost/retrieveBook/book1")) .andExpect(method(HttpMethod.GET)) .andRespond(MockRestResponseCreators.withStatus(HttpStatus.OK) .body("{\"book\":{\"title\":\"xxx\",\"year\":\"2000\"}}") .contentType(MediaType.APPLICATION_JSON)); mockServer.expect(requestTo("http://localhost/retrieveFilm/film1")) .andExpect(method(HttpMethod.GET)) .andRespond(MockRestResponseCreators.withStatus

2021-06-05 16:40:41    分类:问答    spring-boot   junit   mockserver

How to test a RestClientException with MockRestServiceServer

While testing a RestClient-Implementation I want to simulate a RestClientException that may be thrown by some RestTemplate-methods in that implementation f.e. the delete-method: @Override public ResponseEntity<MyResponseModel> documentDelete(String id) { template.setErrorHandler(new MyResponseErrorHandler()); ResponseEntity<MyResponseModel> response = null; try { String url = baseUrl + "/document/id/{id}"; response = template.exchange(url, DELETE, null, MyResponseModel.class, id); } catch (RestClientException ex) { return handleException(ex); } return response; } How can I achieve this? I

2021-06-04 12:54:58    分类:问答    java   spring   mocking   mockserver

UI5 Mock Server with Local Data: “rootUri” Not Working

I'm currently following the UI5 tutorial and am stuck on step 27: Mock Server Configuration. The problem is the rootUri configuration of the mock server. I am using the Northwind OData service as per tutorial and have configured a dataSource for Invoices in the manifest.json. Now, to use the local mock data instead of the online service, I created the necessary files as stated by the tutorial. When I then run the mockServer.html, the server doesn't redirect the service request to the local mock data, but instead makes the request and fails because of web security issues. If I use the following

2021-05-12 11:43:22    分类:问答    odata   sapui5   mockserver