| 217 | } |
| 218 | |
| 219 | public static class ReadTimeoutEmitsTest extends LoggerTest { |
| 220 | |
| 221 | private Level logLevel; |
| 222 | |
| 223 | public void initReadTimeoutEmitsTest(Level logLevel, List<String> expectedMessages) { |
| 224 | this.logLevel = logLevel; |
| 225 | logger.expectMessages(expectedMessages); |
| 226 | } |
| 227 | |
| 228 | public static Iterable<Object[]> data() { |
| 229 | return Arrays.asList( |
| 230 | new Object[][] { |
| 231 | {Level.NONE, Collections.emptyList()}, |
| 232 | { |
| 233 | Level.BASIC, |
| 234 | Arrays.asList( |
| 235 | "\\[SendsStuff#login\\] ---> POST http://localhost:[0-9]+/ HTTP/1.1", |
| 236 | "\\[SendsStuff#login\\] <--- ERROR SocketTimeoutException: Read timed out" |
| 237 | + " \\([0-9]+ms\\)") |
| 238 | }, |
| 239 | { |
| 240 | Level.HEADERS, |
| 241 | Arrays.asList( |
| 242 | "\\[SendsStuff#login\\] ---> POST http://localhost:[0-9]+/ HTTP/1.1", |
| 243 | "\\[SendsStuff#login\\] Content-Length: 80", |
| 244 | "\\[SendsStuff#login\\] Content-Type: application/json", |
| 245 | "\\[SendsStuff#login\\] ---> END HTTP \\(80-byte body\\)", |
| 246 | "\\[SendsStuff#login\\] <--- ERROR SocketTimeoutException: Read timed out" |
| 247 | + " \\([0-9]+ms\\)") |
| 248 | }, |
| 249 | { |
| 250 | Level.FULL, |
| 251 | Arrays.asList( |
| 252 | "\\[SendsStuff#login\\] ---> POST http://localhost:[0-9]+/ HTTP/1.1", |
| 253 | "\\[SendsStuff#login\\] Content-Length: 80", |
| 254 | "\\[SendsStuff#login\\] Content-Type: application/json", |
| 255 | "\\[SendsStuff#login\\] ", |
| 256 | "\\[SendsStuff#login\\] \\{\"customer_name\": \"netflix\", \"user_name\":" |
| 257 | + " \"denominator\", \"password\": \"password\"\\}", |
| 258 | "\\[SendsStuff#login\\] ---> END HTTP \\(80-byte body\\)", |
| 259 | "\\[SendsStuff#login\\] <--- ERROR SocketTimeoutException: Read timed out" |
| 260 | + " \\([0-9]+ms\\)", |
| 261 | "(?s)\\[SendsStuff#login\\] java.net.SocketTimeoutException: Read timed out.*", |
| 262 | "\\[SendsStuff#login\\] <--- END ERROR") |
| 263 | } |
| 264 | }); |
| 265 | } |
| 266 | |
| 267 | @MethodSource("data") |
| 268 | @ParameterizedTest |
| 269 | void levelEmitsOnReadTimeout(Level logLevel, List<String> expectedMessages) { |
| 270 | initReadTimeoutEmitsTest(logLevel, expectedMessages); |
| 271 | server.enqueue(new MockResponse().throttleBody(1, 1, TimeUnit.SECONDS).setBody("foo")); |
| 272 | |
| 273 | SendsStuff api = |
| 274 | Feign.builder() |
| 275 | .logger(logger) |
| 276 | .logLevel(logLevel) |
nothing calls this directly
no outgoing calls
no test coverage detected