Skip to content

Commit

Permalink
feat: WebReactiveIntegrationTest增强
Browse files Browse the repository at this point in the history
  • Loading branch information
luckyQing committed Apr 24, 2024
1 parent b39f476 commit 555e75d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ public void initMock() {
filters[i++] = entry.getValue();
}

mockMvc = MockMvcBuilders.webAppContextSetup((WebApplicationContext) applicationContext).addFilters(filters).build();
mockMvc = MockMvcBuilders.webAppContextSetup((WebApplicationContext) applicationContext)
.addFilters(filters)
.build();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.springframework.test.web.reactive.server.WebTestClient;

import java.nio.charset.StandardCharsets;
import java.time.Duration;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;
Expand All @@ -43,7 +44,10 @@ public class WebReactiveIntegrationTest extends AbstractIntegrationTest implemen

@BeforeEach
public void initMock() {
webTestClient = WebTestClient.bindToApplicationContext(applicationContext).build();
webTestClient = WebTestClient.bindToApplicationContext(applicationContext)
.configureClient()
.responseTimeout(Duration.ofSeconds(60))
.build();
}

@Override
Expand Down Expand Up @@ -104,7 +108,7 @@ public <T> T get(String url, Map<String, String> headers, Object req, TypeRefere
}
}

WebTestClient.RequestHeadersSpec requestHeadersSpec = webTestClient.get().uri(url, params);
WebTestClient.RequestHeadersSpec requestHeadersSpec = params == null ? webTestClient.get().uri(url) : webTestClient.get().uri(url, params);
if (MapUtils.isNotEmpty(headers)) {
headers.forEach(requestHeadersSpec::header);
}
Expand Down

0 comments on commit 555e75d

Please sign in to comment.