18
18
*/
19
19
package org .neo4j .driver ;
20
20
21
- import static java .util .Arrays .asList ;
22
21
import static java .util .concurrent .TimeUnit .MILLISECONDS ;
23
22
import static org .hamcrest .Matchers .containsString ;
24
23
import static org .hamcrest .junit .MatcherAssert .assertThat ;
25
24
import static org .junit .jupiter .api .Assertions .assertEquals ;
26
25
import static org .junit .jupiter .api .Assertions .assertThrows ;
27
- import static org .mockito .ArgumentMatchers .any ;
28
- import static org .mockito .ArgumentMatchers .eq ;
29
- import static org .mockito .Mockito .doThrow ;
30
- import static org .mockito .Mockito .mock ;
31
- import static org .mockito .Mockito .verify ;
32
- import static org .mockito .Mockito .when ;
33
26
import static org .neo4j .driver .Logging .none ;
34
27
import static org .neo4j .driver .internal .logging .DevNullLogging .DEV_NULL_LOGGING ;
35
28
36
29
import io .netty .util .concurrent .EventExecutorGroup ;
37
30
import java .io .IOException ;
38
31
import java .net .ServerSocket ;
39
32
import java .net .URI ;
40
- import java .util .Arrays ;
41
33
import java .util .Iterator ;
42
34
import java .util .List ;
43
35
import org .junit .jupiter .api .Test ;
@@ -62,49 +54,6 @@ void throwsWhenBoltSchemeUsedWithRoutingParams() {
62
54
IllegalArgumentException .class , () -> GraphDatabase .driver ("bolt://localhost:7687/?policy=my_policy" ));
63
55
}
64
56
65
- @ Test
66
- void shouldLogWhenUnableToCreateRoutingDriver () {
67
- Logging logging = mock (Logging .class );
68
- Logger logger = mock (Logger .class );
69
- when (logging .getLog (any (Class .class ))).thenReturn (logger );
70
- InternalDriver driver = mock (InternalDriver .class );
71
- doThrow (ServiceUnavailableException .class ).when (driver ).verifyConnectivity ();
72
- DriverFactory driverFactory = new MockSupplyingDriverFactory (Arrays .asList (driver , driver ));
73
- Config config = Config .builder ().withLogging (logging ).build ();
74
-
75
- List <URI > routingUris = asList (URI .create ("neo4j://localhost:9001" ), URI .create ("neo4j://localhost:9002" ));
76
-
77
- assertThrows (
78
- ServiceUnavailableException .class ,
79
- () -> GraphDatabase .routingDriver (routingUris , AuthTokens .none (), config , driverFactory ));
80
-
81
- verify (logger )
82
- .warn (eq ("Unable to create routing driver for URI: neo4j://localhost:9001" ), any (Throwable .class ));
83
-
84
- verify (logger )
85
- .warn (eq ("Unable to create routing driver for URI: neo4j://localhost:9002" ), any (Throwable .class ));
86
- }
87
-
88
- @ Test
89
- void shouldNotFailRoutingDriverWhenThereIsWorkingUri () {
90
- Logging logging = mock (Logging .class );
91
- Logger logger = mock (Logger .class );
92
- when (logging .getLog (any (Class .class ))).thenReturn (logger );
93
- InternalDriver failingDriver = mock (InternalDriver .class );
94
- doThrow (ServiceUnavailableException .class ).when (failingDriver ).verifyConnectivity ();
95
- InternalDriver workingDriver = mock (InternalDriver .class );
96
- DriverFactory driverFactory = new MockSupplyingDriverFactory (Arrays .asList (failingDriver , workingDriver ));
97
- Config config = Config .builder ().withLogging (logging ).build ();
98
-
99
- List <URI > routingUris = asList (URI .create ("neo4j://localhost:9001" ), URI .create ("neo4j://localhost:9002" ));
100
-
101
- Driver driver = GraphDatabase .routingDriver (routingUris , AuthTokens .none (), config , driverFactory );
102
-
103
- verify (logger )
104
- .warn (eq ("Unable to create routing driver for URI: neo4j://localhost:9001" ), any (Throwable .class ));
105
- assertEquals (driver , workingDriver );
106
- }
107
-
108
57
@ Test
109
58
void shouldRespondToInterruptsWhenConnectingToUnresponsiveServer () throws Exception {
110
59
try (ServerSocket serverSocket = new ServerSocket (0 )) {
0 commit comments