20
20
21
21
import org .junit .Rule ;
22
22
import org .junit .Test ;
23
+ import org .junit .runner .RunWith ;
24
+ import org .junit .runners .Parameterized ;
25
+ import org .junit .runners .Parameterized .Parameters ;
23
26
27
+ import java .util .Arrays ;
28
+ import java .util .Collection ;
24
29
import java .util .List ;
25
30
import java .util .concurrent .TimeUnit ;
26
31
43
48
* Mainly concerned about the connection pool - we want to make sure that bad connections are evacuated from the
44
49
* pool properly if the server dies, or all connections are lost for some other reason.
45
50
*/
51
+ @ RunWith (Parameterized .class )
46
52
public class ServerKilledIT
47
53
{
48
54
@ Rule
49
55
public TestNeo4j neo4j = new TestNeo4j ();
50
56
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
+
51
72
@ Test
52
73
public void shouldRecoverFromServerRestart () throws Throwable
53
74
{
54
75
// Given
55
76
// 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 ();
59
78
60
79
try ( Driver driver = GraphDatabase .driver ( Neo4jRunner .DEFAULT_URI , config ) )
61
80
{
@@ -77,8 +96,7 @@ public void shouldRecoverFromServerRestart() throws Throwable
77
96
if ( toleratedFailures -- == 0 )
78
97
{
79
98
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 () );
82
100
}
83
101
}
84
102
}
@@ -95,9 +113,8 @@ public void shouldDropBrokenOldSessions() throws Throwable
95
113
{
96
114
// config with set liveness check timeout
97
115
int livenessCheckTimeoutMinutes = 10 ;
98
- Config config = Config .build ()
116
+ Config config = Config .build (). withEncryptionLevel ( encryptionLevel )
99
117
.withConnectionLivenessCheckTimeout ( livenessCheckTimeoutMinutes , TimeUnit .MINUTES )
100
- .withEncryptionLevel ( Config .EncryptionLevel .NONE )
101
118
.toConfig ();
102
119
103
120
FakeClock clock = new FakeClock ();
0 commit comments