@@ -496,38 +496,59 @@ public void customTomcatAcceptCount() {
496
496
Map <String , String > map = new HashMap <String , String >();
497
497
map .put ("server.tomcat.accept-count" , "10" );
498
498
bindProperties (map );
499
- TomcatEmbeddedServletContainerFactory container = new TomcatEmbeddedServletContainerFactory ();
499
+ TomcatEmbeddedServletContainerFactory container = new TomcatEmbeddedServletContainerFactory (
500
+ 0 );
500
501
this .properties .customize (container );
501
502
TomcatEmbeddedServletContainer embeddedContainer = (TomcatEmbeddedServletContainer ) container
502
503
.getEmbeddedServletContainer ();
503
- assertThat (((AbstractProtocol <?>) embeddedContainer .getTomcat ().getConnector ()
504
- .getProtocolHandler ()).getBacklog ()).isEqualTo (10 );
504
+ embeddedContainer .start ();
505
+ try {
506
+ assertThat (((AbstractProtocol <?>) embeddedContainer .getTomcat ().getConnector ()
507
+ .getProtocolHandler ()).getBacklog ()).isEqualTo (10 );
508
+ }
509
+ finally {
510
+ embeddedContainer .stop ();
511
+ }
505
512
}
506
513
507
514
@ Test
508
515
public void customTomcatMaxConnections () {
509
516
Map <String , String > map = new HashMap <String , String >();
510
517
map .put ("server.tomcat.max-connections" , "5" );
511
518
bindProperties (map );
512
- TomcatEmbeddedServletContainerFactory container = new TomcatEmbeddedServletContainerFactory ();
519
+ TomcatEmbeddedServletContainerFactory container = new TomcatEmbeddedServletContainerFactory (
520
+ 0 );
513
521
this .properties .customize (container );
514
522
TomcatEmbeddedServletContainer embeddedContainer = (TomcatEmbeddedServletContainer ) container
515
523
.getEmbeddedServletContainer ();
516
- assertThat (((AbstractProtocol <?>) embeddedContainer .getTomcat ().getConnector ()
517
- .getProtocolHandler ()).getMaxConnections ()).isEqualTo (5 );
524
+ embeddedContainer .start ();
525
+ try {
526
+ assertThat (((AbstractProtocol <?>) embeddedContainer .getTomcat ().getConnector ()
527
+ .getProtocolHandler ()).getMaxConnections ()).isEqualTo (5 );
528
+ }
529
+ finally {
530
+ embeddedContainer .stop ();
531
+ }
518
532
}
519
533
520
534
@ Test
521
535
public void customTomcatMaxHttpPostSize () {
522
536
Map <String , String > map = new HashMap <String , String >();
523
537
map .put ("server.tomcat.max-http-post-size" , "10000" );
524
538
bindProperties (map );
525
- TomcatEmbeddedServletContainerFactory container = new TomcatEmbeddedServletContainerFactory ();
539
+ TomcatEmbeddedServletContainerFactory container = new TomcatEmbeddedServletContainerFactory (
540
+ 0 );
526
541
this .properties .customize (container );
527
542
TomcatEmbeddedServletContainer embeddedContainer = (TomcatEmbeddedServletContainer ) container
528
543
.getEmbeddedServletContainer ();
529
- assertThat (embeddedContainer .getTomcat ().getConnector ().getMaxPostSize ())
530
- .isEqualTo (10000 );
544
+ embeddedContainer .start ();
545
+ try {
546
+ assertThat (embeddedContainer .getTomcat ().getConnector ().getMaxPostSize ())
547
+ .isEqualTo (10000 );
548
+ }
549
+ finally {
550
+ embeddedContainer .stop ();
551
+ }
531
552
}
532
553
533
554
@ Test
@@ -536,12 +557,19 @@ public void customTomcatMaxHttpPostSizeWithDeprecatedProperty() {
536
557
Map <String , String > map = new HashMap <String , String >();
537
558
map .put ("server.max-http-post-size" , "2000" );
538
559
bindProperties (map );
539
- TomcatEmbeddedServletContainerFactory container = new TomcatEmbeddedServletContainerFactory ();
560
+ TomcatEmbeddedServletContainerFactory container = new TomcatEmbeddedServletContainerFactory (
561
+ 0 );
540
562
this .properties .customize (container );
541
563
TomcatEmbeddedServletContainer embeddedContainer = (TomcatEmbeddedServletContainer ) container
542
564
.getEmbeddedServletContainer ();
543
- assertThat (embeddedContainer .getTomcat ().getConnector ().getMaxPostSize ())
544
- .isEqualTo (2000 );
565
+ embeddedContainer .start ();
566
+ try {
567
+ assertThat (embeddedContainer .getTomcat ().getConnector ().getMaxPostSize ())
568
+ .isEqualTo (2000 );
569
+ }
570
+ finally {
571
+ embeddedContainer .stop ();
572
+ }
545
573
}
546
574
547
575
@ Test
0 commit comments