@@ -318,4 +318,95 @@ public void testMultiplexedSessionMaintenanceDuration() {
318
318
.build ()
319
319
.getMultiplexedSessionMaintenanceDuration ());
320
320
}
321
+
322
+ @ Test
323
+ public void testToBuilder () {
324
+ assertToBuilderRoundtrip (SessionPoolOptions .newBuilder ().build ());
325
+ assertToBuilderRoundtrip (
326
+ SessionPoolOptions .newBuilder ()
327
+ .setUseMultiplexedSession (ThreadLocalRandom .current ().nextBoolean ())
328
+ .build ());
329
+ assertToBuilderRoundtrip (
330
+ SessionPoolOptions .newBuilder ()
331
+ .setMinSessions (ThreadLocalRandom .current ().nextInt (400 ))
332
+ .build ());
333
+ assertToBuilderRoundtrip (
334
+ SessionPoolOptions .newBuilder ()
335
+ .setMaxSessions (ThreadLocalRandom .current ().nextInt (1000 ))
336
+ .build ());
337
+ assertToBuilderRoundtrip (
338
+ SessionPoolOptions .newBuilder ()
339
+ .setIncStep (ThreadLocalRandom .current ().nextInt (1000 ))
340
+ .build ());
341
+ assertToBuilderRoundtrip (
342
+ SessionPoolOptions .newBuilder ()
343
+ .setMaxIdleSessions (ThreadLocalRandom .current ().nextInt (1000 ))
344
+ .build ());
345
+ assertToBuilderRoundtrip (
346
+ SessionPoolOptions .newBuilder ()
347
+ .setWriteSessionsFraction (ThreadLocalRandom .current ().nextFloat ())
348
+ .build ());
349
+ assertToBuilderRoundtrip (
350
+ SessionPoolOptions .newBuilder ()
351
+ .setInactiveTransactionRemovalOptions (
352
+ InactiveTransactionRemovalOptions .newBuilder ()
353
+ .setUsedSessionsRatioThreshold (ThreadLocalRandom .current ().nextDouble ())
354
+ .build ())
355
+ .build ());
356
+ assertToBuilderRoundtrip (
357
+ SessionPoolOptions .newBuilder ()
358
+ .setLoopFrequency (ThreadLocalRandom .current ().nextInt (1000 ))
359
+ .build ());
360
+ assertToBuilderRoundtrip (
361
+ SessionPoolOptions .newBuilder ()
362
+ .setMultiplexedSessionMaintenanceLoopFrequency (
363
+ java .time .Duration .ofMillis (ThreadLocalRandom .current ().nextInt (1000 )))
364
+ .build ());
365
+ assertToBuilderRoundtrip (
366
+ SessionPoolOptions .newBuilder ()
367
+ .setKeepAliveIntervalMinutes (ThreadLocalRandom .current ().nextInt (60 ))
368
+ .build ());
369
+ assertToBuilderRoundtrip (
370
+ SessionPoolOptions .newBuilder ()
371
+ .setRemoveInactiveSessionAfter (
372
+ Duration .ofMillis (ThreadLocalRandom .current ().nextLong (10000 )))
373
+ .build ());
374
+ assertToBuilderRoundtrip (
375
+ SessionPoolOptions .newBuilder ().setCloseIfInactiveTransactions ().build ());
376
+ assertToBuilderRoundtrip (SessionPoolOptions .newBuilder ().setFailOnSessionLeak ().build ());
377
+ assertToBuilderRoundtrip (
378
+ SessionPoolOptions .newBuilder ()
379
+ .setTrackStackTraceOfSessionCheckout (ThreadLocalRandom .current ().nextBoolean ())
380
+ .build ());
381
+ assertToBuilderRoundtrip (
382
+ SessionPoolOptions .newBuilder ()
383
+ .setInitialWaitForSessionTimeoutMillis (ThreadLocalRandom .current ().nextLong (1000 ))
384
+ .build ());
385
+ assertToBuilderRoundtrip (
386
+ SessionPoolOptions .newBuilder ()
387
+ .setAutoDetectDialect (ThreadLocalRandom .current ().nextBoolean ())
388
+ .build ());
389
+ assertToBuilderRoundtrip (
390
+ SessionPoolOptions .newBuilder ()
391
+ .setWaitForMinSessions (Duration .ofMillis (ThreadLocalRandom .current ().nextLong (10000 )))
392
+ .build ());
393
+ assertToBuilderRoundtrip (
394
+ SessionPoolOptions .newBuilder ()
395
+ .setAcquireSessionTimeout (
396
+ Duration .ofMillis (ThreadLocalRandom .current ().nextLong (10000 )))
397
+ .build ());
398
+ assertToBuilderRoundtrip (
399
+ SessionPoolOptions .newBuilder ()
400
+ .setRandomizePositionQPSThreshold (ThreadLocalRandom .current ().nextLong (10000 ))
401
+ .build ());
402
+ assertToBuilderRoundtrip (
403
+ SessionPoolOptions .newBuilder ()
404
+ .setMultiplexedSessionMaintenanceDuration (
405
+ Duration .ofMillis (ThreadLocalRandom .current ().nextLong (10000 )))
406
+ .build ());
407
+ }
408
+
409
+ static void assertToBuilderRoundtrip (SessionPoolOptions options ) {
410
+ assertEquals (options , options .toBuilder ().build ());
411
+ }
321
412
}
0 commit comments