| 370 | } |
| 371 | |
| 372 | public static class FormatCharacterTest extends LoggerTest { |
| 373 | |
| 374 | private Level logLevel; |
| 375 | |
| 376 | public void initFormatCharacterTest(Level logLevel, List<String> expectedMessages) { |
| 377 | this.logLevel = logLevel; |
| 378 | logger.expectMessages(expectedMessages); |
| 379 | } |
| 380 | |
| 381 | public static Iterable<Object[]> data() { |
| 382 | return Arrays.asList( |
| 383 | new Object[][] { |
| 384 | {Level.NONE, Collections.emptyList()}, |
| 385 | { |
| 386 | Level.BASIC, |
| 387 | Arrays.asList( |
| 388 | "\\[SendsStuff#login\\] ---> POST http://non-exist.invalid/ HTTP/1.1", |
| 389 | "\\[SendsStuff#login\\] <--- ERROR UnknownHostException: non-exist.invalid" |
| 390 | + " \\([0-9]+ms\\)") |
| 391 | }, |
| 392 | { |
| 393 | Level.HEADERS, |
| 394 | Arrays.asList( |
| 395 | "\\[SendsStuff#login\\] ---> POST http://non-exist.invalid/ HTTP/1.1", |
| 396 | "\\[SendsStuff#login\\] Content-Length: 80", |
| 397 | "\\[SendsStuff#login\\] Content-Type: application/json", |
| 398 | "\\[SendsStuff#login\\] ---> END HTTP \\(80-byte body\\)", |
| 399 | "\\[SendsStuff#login\\] <--- ERROR UnknownHostException: non-exist.invalid" |
| 400 | + " \\([0-9]+ms\\)") |
| 401 | }, |
| 402 | { |
| 403 | Level.FULL, |
| 404 | Arrays.asList( |
| 405 | "\\[SendsStuff#login\\] ---> POST http://non-exist.invalid/ HTTP/1.1", |
| 406 | "\\[SendsStuff#login\\] Content-Length: 80", |
| 407 | "\\[SendsStuff#login\\] Content-Type: application/json", |
| 408 | "\\[SendsStuff#login\\] ", |
| 409 | "\\[SendsStuff#login\\] \\{\"customer_name\": \"netflix\", \"user_name\":" |
| 410 | + " \"denominator\", \"password\": \"password\"\\}", |
| 411 | "\\[SendsStuff#login\\] ---> END HTTP \\(80-byte body\\)", |
| 412 | "\\[SendsStuff#login\\] <--- ERROR UnknownHostException: non-exist.invalid" |
| 413 | + " \\([0-9]+ms\\)", |
| 414 | "(?s)\\[SendsStuff#login\\] java.net.UnknownHostException: non-exist.invalid.*", |
| 415 | "\\[SendsStuff#login\\] <--- END ERROR") |
| 416 | } |
| 417 | }); |
| 418 | } |
| 419 | |
| 420 | @MethodSource("data") |
| 421 | @ParameterizedTest |
| 422 | void formatCharacterEmits(Level logLevel, List<String> expectedMessages) { |
| 423 | initFormatCharacterTest(logLevel, expectedMessages); |
| 424 | SendsStuff api = |
| 425 | Feign.builder() |
| 426 | .logger(logger) |
| 427 | .logLevel(logLevel) |
| 428 | .retryer( |
| 429 | new Retryer() { |
nothing calls this directly
no outgoing calls
no test coverage detected