Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

i wrote a test for Handler (spring weblux)

test:

@Test
    public void checkServicesHandlerTest(){
      Request request = new Request();
        request.setMsisdn("ffdfdfd");

        this.testClient.post().uri("/check")
                .body(Mono.just(request), Request.class).exchange().expectStatus().isOk();       
    }

But in result i have an error.

Timeout on blocking read for 5000 MILLISECONDS

the handler is simple

 public Mono<ServerResponse> check(ServerRequest request){

       Request request = request.bodyToMono(Request.class).block();

Where is the problem ? but if i send a direct request to server all is ok.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
881 views
Welcome To Ask or Share your Answers For Others

1 Answer

I was seeing similar issue and Exception when running Integration tests some of them aggregates responses from multiple other services which has database access and stuff. So we were seeing this issue intermittently when running Integration tests. We are using Spring Boot 2.0.0.RC1 and Junit 5 with Gradle. I did this to resolve the issue. The key is mutating the webclient with a response timeout of 30 seconds the worst case.

    @Autowired
    private WebTestClient webTestClient;

        @BeforeEach
        public void setUp() {
         webTestClient = webTestClient
                            .mutate()
                            .responseTimeout(Duration.ofMillis(30000))
                            .build();
        }

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...