|
35 | 35 | import javax.net.ssl.HostnameVerifier; |
36 | 36 | import javax.net.ssl.SSLSession; |
37 | 37 | import java.io.UnsupportedEncodingException; |
| 38 | +import java.lang.reflect.Method; |
| 39 | +import java.lang.reflect.Modifier; |
38 | 40 | import java.net.URLEncoder; |
39 | 41 | import java.time.Duration; |
40 | 42 | import java.time.ZoneId; |
|
44 | 46 | import java.util.Set; |
45 | 47 | import java.util.function.Function; |
46 | 48 | import java.util.function.Predicate; |
| 49 | +import java.util.stream.Collectors; |
47 | 50 | import java.util.stream.Stream; |
48 | 51 |
|
49 | 52 | import static io.asyncer.r2dbc.mysql.MySqlConnectionFactoryProvider.PASSWORD_PUBLISHER; |
@@ -450,6 +453,43 @@ void validPasswordSupplier() { |
450 | 453 | assertThat(ConnectionFactories.get(options)).isExactlyInstanceOf(MySqlConnectionFactory.class); |
451 | 454 | } |
452 | 455 |
|
| 456 | + @Test |
| 457 | + void allConfigurationOptions() { |
| 458 | + List<String> exceptConfigs = Arrays.asList( |
| 459 | + "extendWith", |
| 460 | + "username", |
| 461 | + "zeroDateOption"); |
| 462 | + List<String> exceptOptions = Arrays.asList( |
| 463 | + "driver", |
| 464 | + "ssl", |
| 465 | + "protocol", |
| 466 | + "zeroDate", |
| 467 | + "lockWaitTimeout", |
| 468 | + "statementTimeout"); |
| 469 | + Set<String> allOptions = Stream.concat( |
| 470 | + Arrays.stream(ConnectionFactoryOptions.class.getFields()), |
| 471 | + Arrays.stream(MySqlConnectionFactoryProvider.class.getFields()) |
| 472 | + ) |
| 473 | + .filter(field -> Modifier.isStatic(field.getModifiers()) && field.getType() == Option.class) |
| 474 | + .map(field -> { |
| 475 | + try { |
| 476 | + return ((Option<?>) field.get(null)).name(); |
| 477 | + } catch (IllegalAccessException e) { |
| 478 | + throw new RuntimeException(e); |
| 479 | + } |
| 480 | + }) |
| 481 | + .filter(name -> !exceptOptions.contains(name)) |
| 482 | + .collect(Collectors.toSet()); |
| 483 | + Set<String> allBuilderOptions = Arrays.stream(MySqlConnectionConfiguration.Builder.class.getMethods()) |
| 484 | + .filter(method -> method.getParameterCount() >= 1 && |
| 485 | + method.getReturnType() == MySqlConnectionConfiguration.Builder.class && |
| 486 | + !exceptConfigs.contains(method.getName())) |
| 487 | + .map(Method::getName) |
| 488 | + .collect(Collectors.toSet()); |
| 489 | + |
| 490 | + assertThat(allBuilderOptions).containsExactlyInAnyOrderElementsOf(allOptions); |
| 491 | + } |
| 492 | + |
453 | 493 | @ParameterizedTest |
454 | 494 | @MethodSource |
455 | 495 | void sessionVariables(String input, List<String> expected) { |
|
0 commit comments