mockserver

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

為{幸葍}努か 提交于 2019-12-31 04:02:57
问题 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

How to test a RestClientException with MockRestServiceServer

浪子不回头ぞ 提交于 2019-12-21 07:23:36
问题 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

How to use MockRestServiceServer with multiple URLs?

那年仲夏 提交于 2019-12-11 03:25:08
问题 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

使用Spring MVC开发RESTful API(续)

陌路散爱 提交于 2019-12-10 04:06:06
使用多线程提高REST服务性能 异步处理REST服务,提高服务器吞吐量 使用Runnable异步处理Rest服务 AsyncController.java @RestController @GetMapping("/async") public class AsyncController { private Logger logger = LoggerFactory.getLogger(getClass()); @RequestMapping("/order") public Callable<String> order() throws Exception { logger.info("主线程开始"); Callable<String> result = new Callable<String>() { @Override public String call() throws Exception { logger.info("副线程开始"); Thread.sleep(2000); // 模拟处理下单消耗的时间 logger.info("副线程结束"); return "success"; } }; logger.info("主线程结束"); return result; } } 使用DeferredResult异步处理Rest服务 应用1/线程1:接收下单请求,放到消息队列

Spring MockRestServiceServer handling multiple Async requests

可紊 提交于 2019-12-07 08:39:08
问题 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

How to test a RestClientException with MockRestServiceServer

瘦欲@ 提交于 2019-12-04 00:57:41
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

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

微笑、不失礼 提交于 2019-12-02 08:21:54
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

Mock测试,何去何从

霸气de小男生 提交于 2019-11-29 10:56:52
2016-10-24 出处: Qtest之道 作/译者:闫耀珍 上面的情景是不是似曾相识呢?现今的业务系统已经很少是孤立存在的了,尤其对于一个大公司而言,各个部门之间的配合非常密切,我们或多或少都需要使用兄弟团队或是其他公司提供的接口服务,当然,我们也会给其他兄弟部门提供接口。这样的话,就对我们的联调和测试造成了很大的麻烦。假如各个兄弟部门的步伐完全一致,那么问题就会少很多,但愿望是美好的,现实是残酷的,要做到步伐一致基本是不可能的。所以,对于这种情况,我们的解决方案通常是搭建一个临时的mock server来模拟那些兄弟部门未开发完成的接口,以达到单方面联调测试的效果,我们下面会介绍一些mock小工具。一般来说,搭建这种临时的mock server比较简单,但是往往也意味着功能简单,有时候可能我们得需要为不同的接口进行重复开发以实现特定功能。这样的话问题就来了,随写随仍不是我们互联网人一贯的作风,我们需要将这种基础服务传承下去,要服务于众多的其他互联网人,我们称之为share。那么能不能构建一个通用的mock server呢?自己动手丰衣足食,萌生了自己开发一套mock系统,就有了现在的雏形——xMock,且听我慢慢道来关于mock的二三事。 一、什么是mock? mock这个单词解释起来,本意就是模拟或者效仿。我们可以把mock理解为一个替身,在软件开发领域,通常就是指模拟对象