2020
2121import org .junit .Rule ;
2222import org .junit .Test ;
23+ import org .junit .runner .RunWith ;
24+ import org .junit .runners .Parameterized ;
25+ import org .junit .runners .Parameterized .Parameters ;
2326
27+ import java .util .Arrays ;
28+ import java .util .Collection ;
2429import java .util .List ;
2530import java .util .concurrent .TimeUnit ;
2631
4348 * Mainly concerned about the connection pool - we want to make sure that bad connections are evacuated from the
4449 * pool properly if the server dies, or all connections are lost for some other reason.
4550 */
51+ @ RunWith (Parameterized .class )
4652public class ServerKilledIT
4753{
4854 @ Rule
4955 public TestNeo4j neo4j = new TestNeo4j ();
5056
57+ @ Parameters (name = "{0} connections" )
58+ public static Collection <Object []> data () {
59+ return Arrays .asList (new Object [][] {
60+ { "plaintext" , Config .EncryptionLevel .NONE },
61+ { "tls encrypted" , Config .EncryptionLevel .REQUIRED }
62+ });
63+ }
64+
65+ private Config .EncryptionLevel encryptionLevel ;
66+
67+ public ServerKilledIT ( String testName , Config .EncryptionLevel encryptionLevel )
68+ {
69+ this .encryptionLevel = encryptionLevel ;
70+ }
71+
5172 @ Test
5273 public void shouldRecoverFromServerRestart () throws Throwable
5374 {
5475 // Given
5576 // config with sessionLivenessCheckTimeout not set, i.e. turned off
56- Config config = Config .build ()
57- .withEncryptionLevel ( Config .EncryptionLevel .NONE )
58- .toConfig ();
77+ Config config = Config .build ().withEncryptionLevel ( encryptionLevel ).toConfig ();
5978
6079 try ( Driver driver = GraphDatabase .driver ( Neo4jRunner .DEFAULT_URI , config ) )
6180 {
@@ -77,8 +96,7 @@ public void shouldRecoverFromServerRestart() throws Throwable
7796 if ( toleratedFailures -- == 0 )
7897 {
7998 fail ( "Expected (for now) at most four failures, one for each old connection, but now I've " +
80- "gotten " +
81- "five: " + e .getMessage () );
99+ "gotten " + "five: " + e .getMessage () );
82100 }
83101 }
84102 }
@@ -95,9 +113,8 @@ public void shouldDropBrokenOldSessions() throws Throwable
95113 {
96114 // config with set liveness check timeout
97115 int livenessCheckTimeoutMinutes = 10 ;
98- Config config = Config .build ()
116+ Config config = Config .build (). withEncryptionLevel ( encryptionLevel )
99117 .withConnectionLivenessCheckTimeout ( livenessCheckTimeoutMinutes , TimeUnit .MINUTES )
100- .withEncryptionLevel ( Config .EncryptionLevel .NONE )
101118 .toConfig ();
102119
103120 FakeClock clock = new FakeClock ();
0 commit comments