久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

      <tfoot id='jewCM'></tfoot>
    1. <i id='jewCM'><tr id='jewCM'><dt id='jewCM'><q id='jewCM'><span id='jewCM'><b id='jewCM'><form id='jewCM'><ins id='jewCM'></ins><ul id='jewCM'></ul><sub id='jewCM'></sub></form><legend id='jewCM'></legend><bdo id='jewCM'><pre id='jewCM'><center id='jewCM'></center></pre></bdo></b><th id='jewCM'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='jewCM'><tfoot id='jewCM'></tfoot><dl id='jewCM'><fieldset id='jewCM'></fieldset></dl></div>

        <small id='jewCM'></small><noframes id='jewCM'>

      1. <legend id='jewCM'><style id='jewCM'><dir id='jewCM'><q id='jewCM'></q></dir></style></legend>
          <bdo id='jewCM'></bdo><ul id='jewCM'></ul>
      2. MockRestServiceServer 在集成測試中模擬后端超時

        MockRestServiceServer simulate backend timeout in integration test(MockRestServiceServer 在集成測試中模擬后端超時)

            <tfoot id='zJOic'></tfoot>
            <legend id='zJOic'><style id='zJOic'><dir id='zJOic'><q id='zJOic'></q></dir></style></legend>
              <i id='zJOic'><tr id='zJOic'><dt id='zJOic'><q id='zJOic'><span id='zJOic'><b id='zJOic'><form id='zJOic'><ins id='zJOic'></ins><ul id='zJOic'></ul><sub id='zJOic'></sub></form><legend id='zJOic'></legend><bdo id='zJOic'><pre id='zJOic'><center id='zJOic'></center></pre></bdo></b><th id='zJOic'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='zJOic'><tfoot id='zJOic'></tfoot><dl id='zJOic'><fieldset id='zJOic'></fieldset></dl></div>

                <small id='zJOic'></small><noframes id='zJOic'>

                  <tbody id='zJOic'></tbody>
                  <bdo id='zJOic'></bdo><ul id='zJOic'></ul>

                • 本文介紹了MockRestServiceServer 在集成測試中模擬后端超時的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我正在使用 MockRestServiceServer 在我的 REST 控制器上編寫某種集成測試來模擬后端行為.我現在想要實現的是模擬來自后端的非常慢的響應,這最終會導致我的應用程序超時.似乎可以使用 WireMock 實現,但目前我想堅持使用 MockRestServiceServer.

                  I am writing some kind of integration test on my REST controller using MockRestServiceServer to mock backend behaviour. What I am trying to achieve now is to simulate very slow response from backend which would finally lead to timeout in my application. It seems that it can be implemented with WireMock but at the moment I would like to stick to MockRestServiceServer.

                  我正在創建這樣的服務器:

                  I am creating server like this:

                  myMock = MockRestServiceServer.createServer(asyncRestTemplate);
                  

                  然后我在嘲笑我的后端行為:

                  And then I'm mocking my backend behaviour like:

                  myMock.expect(requestTo("http://myfakeurl.blabla"))
                              .andExpect(method(HttpMethod.GET))
                              .andRespond(withSuccess(myJsonResponse, MediaType.APPLICATION_JSON));
                  

                  是否可以為響應添加某種延遲或超時或其他類型的延遲(或者可能是整個模擬服務器,甚至是我的 asyncRestTemplate)?或者我應該切換到 WireMock 還是 Restito?

                  Is it possible to add some kind of a delay or timeout or other kind of latency to the response (or maybe whole mocked server or even my asyncRestTemplate)? Or should I just switch to WireMock or maybe Restito?

                  推薦答案

                  你可以這樣實現這個測試功能(Java 8):

                  You can implement this test functionality this way (Java 8):

                  myMock
                      .expect(requestTo("http://myfakeurl.blabla"))
                      .andExpect(method(HttpMethod.GET))
                      .andRespond(request -> {
                          try {
                              Thread.sleep(TimeUnit.SECONDS.toMillis(1));
                          } catch (InterruptedException ignored) {}
                          return new MockClientHttpResponse(myJsonResponse, HttpStatus.OK);
                      });
                  

                  但是,我應該警告您,由于 MockRestServiceServer 只是替換了 RestTemplate requestFactory,因此您所做的任何 requestFactory 設置都將在測試環境中丟失.

                  But, I should warn you, that since MockRestServiceServer simply replaces RestTemplate requestFactory any requestFactory settings you'd make will be lost in test environment.

                  這篇關于MockRestServiceServer 在集成測試中模擬后端超時的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  How can I detect integer overflow on 32 bits int?(如何檢測 32 位 int 上的整數溢出?)
                  Local variables before return statements, does it matter?(return 語句之前的局部變量,這有關系嗎?)
                  How to convert Integer to int?(如何將整數轉換為整數?)
                  How do I create an int array with randomly shuffled numbers in a given range(如何在給定范圍內創建一個隨機打亂數字的 int 數組)
                  Inconsistent behavior on java#39;s ==(java的行為不一致==)
                  Why is Java able to store 0xff000000 as an int?(為什么 Java 能夠將 0xff000000 存儲為 int?)
                • <small id='2QyyK'></small><noframes id='2QyyK'>

                  • <bdo id='2QyyK'></bdo><ul id='2QyyK'></ul>
                      <tbody id='2QyyK'></tbody>
                  • <tfoot id='2QyyK'></tfoot>
                    <i id='2QyyK'><tr id='2QyyK'><dt id='2QyyK'><q id='2QyyK'><span id='2QyyK'><b id='2QyyK'><form id='2QyyK'><ins id='2QyyK'></ins><ul id='2QyyK'></ul><sub id='2QyyK'></sub></form><legend id='2QyyK'></legend><bdo id='2QyyK'><pre id='2QyyK'><center id='2QyyK'></center></pre></bdo></b><th id='2QyyK'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='2QyyK'><tfoot id='2QyyK'></tfoot><dl id='2QyyK'><fieldset id='2QyyK'></fieldset></dl></div>

                    <legend id='2QyyK'><style id='2QyyK'><dir id='2QyyK'><q id='2QyyK'></q></dir></style></legend>

                            主站蜘蛛池模板: 99视频在线看| 国内精品久久精品 | 国产精品久久久乱弄 | 毛片一区二区三区 | 天堂在线中文 | 国产精品欧美一区二区三区不卡 | 精品一区二区免费视频 | 成年男女免费视频网站 | 久久久久免费精品国产小说色大师 | 欧美一卡二卡在线 | 亚洲成人精品在线 | 在线观看av免费 | 成人在线精品视频 | 日本网站免费观看 | 成人小视频在线免费观看 | 天天玩天天干天天操 | 日韩一级免费大片 | 日韩羞羞 | 精品国产精品 | 99热国产免费 | 午夜精品在线 | 国产aaaaav久久久一区二区 | 国产精品极品美女在线观看免费 | 色综合久久88色综合天天 | 一区二区国产精品 | 国产精品免费福利 | 精品国产乱码久久久久久88av | 久久精品国产久精国产 | av一级久久| 中文在线一区二区 | 国产精品黄色 | www国产成人免费观看视频,深夜成人网 | 国产九一精品 | 亚洲精品日韩一区二区电影 | 久久91av| 婷婷99 | 精品国产成人 | 久久久久久国产免费视网址 | 亚洲视频区| 中文字幕在线观看视频一区 | 日韩免费网站 |