Skip to content

Commit b48d6c7

Browse files
author
Zhen
committed
Fix the failing build due to missing boltkit on CI machines and failing on wrong exception place
1 parent 6b5bcc3 commit b48d6c7

File tree

1 file changed

+41
-29
lines changed

1 file changed

+41
-29
lines changed

driver/src/test/java/org/neo4j/driver/internal/RoutingDriverBoltKitTest.java

Lines changed: 41 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -187,96 +187,108 @@ public String apply( Record record )
187187
public void shouldThrowSessionExpiredIfReadServerDisappears()
188188
throws IOException, InterruptedException, StubServer.ForceKilled
189189
{
190-
//Expect
191-
exception.expect( SessionExpiredException.class );
192-
exception.expectMessage( "Server at 127.0.0.1:9005 is no longer available" );
193190

194191
// Given
195192
StubServer server = StubServer.start( "acquire_endpoints.script", 9001 );
196193

197194
//START a read server
198195
StubServer.start( "dead_server.script", 9005 );
199196
URI uri = URI.create( "bolt+routing://127.0.0.1:9001" );
197+
198+
//Expect
199+
exception.expect( SessionExpiredException.class );
200+
exception.expectMessage( "Server at 127.0.0.1:9005 is no longer available" );
201+
200202
try ( RoutingDriver driver = (RoutingDriver) GraphDatabase.driver( uri, config );
201203
Session session = driver.session( AccessMode.READ ) )
202204
{
203205
session.run( "MATCH (n) RETURN n.name" );
204206
}
205-
// Finally
206-
assertThat( server.exitStatus(), equalTo( 0 ) );
207+
finally
208+
{
209+
assertThat( server.exitStatus(), equalTo( 0 ) );
210+
}
207211
}
208212

209213
@Test
210214
public void shouldThrowSessionExpiredIfReadServerDisappearsWhenUsingTransaction()
211215
throws IOException, InterruptedException, StubServer.ForceKilled
212216
{
213-
//Expect
214-
exception.expect( SessionExpiredException.class );
215-
exception.expectMessage( "Server at 127.0.0.1:9005 is no longer available" );
216-
217217
// Given
218218
StubServer server = StubServer.start( "acquire_endpoints.script", 9001 );
219219

220220
//START a read server
221221
StubServer.start( "dead_server.script", 9005 );
222222
URI uri = URI.create( "bolt+routing://127.0.0.1:9001" );
223+
224+
//Expect
225+
exception.expect( SessionExpiredException.class );
226+
exception.expectMessage( "Server at 127.0.0.1:9005 is no longer available" );
227+
223228
try ( RoutingDriver driver = (RoutingDriver) GraphDatabase.driver( uri, config );
224229
Session session = driver.session( AccessMode.READ );
225230
Transaction tx = session.beginTransaction() )
226231
{
227232
tx.run( "MATCH (n) RETURN n.name" );
228233
tx.success();
229234
}
230-
// Finally
231-
assertThat( server.exitStatus(), equalTo( 0 ) );
235+
finally
236+
{
237+
assertThat( server.exitStatus(), equalTo( 0 ) );
238+
}
232239
}
233240

234241
@Test
235242
public void shouldThrowSessionExpiredIfWriteServerDisappears()
236243
throws IOException, InterruptedException, StubServer.ForceKilled
237244
{
238-
//Expect
239-
exception.expect( SessionExpiredException.class );
240-
//exception.expectMessage( "Server at 127.0.0.1:9006 is no longer available" );
241-
242245
// Given
243246
StubServer server = StubServer.start( "acquire_endpoints.script", 9001 );
244247

245248
//START a dead write servers
246249
StubServer.start( "dead_server.script", 9007 );
247250
URI uri = URI.create( "bolt+routing://127.0.0.1:9001" );
251+
252+
//Expect
253+
exception.expect( SessionExpiredException.class );
254+
//exception.expectMessage( "Server at 127.0.0.1:9006 is no longer available" );
255+
248256
try ( RoutingDriver driver = (RoutingDriver) GraphDatabase.driver( uri, config );
249257
Session session = driver.session( AccessMode.WRITE ) )
250258
{
251259
session.run( "MATCH (n) RETURN n.name" ).consume();
252260
}
253-
// Finally
254-
assertThat( server.exitStatus(), equalTo( 0 ) );
261+
finally
262+
{
263+
assertThat( server.exitStatus(), equalTo( 0 ) );
264+
}
255265
}
256266

257267
@Test
258268
public void shouldThrowSessionExpiredIfWriteServerDisappearsWhenUsingTransaction()
259269
throws IOException, InterruptedException, StubServer.ForceKilled
260270
{
261-
//Expect
262-
exception.expect( SessionExpiredException.class );
263-
//exception.expectMessage( "Server at 127.0.0.1:9006 is no longer available" );
264-
265271
// Given
266272
StubServer server = StubServer.start( "acquire_endpoints.script", 9001 );
267273

268274
//START a dead write servers
269275
StubServer.start( "dead_server.script", 9007 );
276+
270277
URI uri = URI.create( "bolt+routing://127.0.0.1:9001" );
278+
//Expect
279+
exception.expect( SessionExpiredException.class );
280+
271281
try ( RoutingDriver driver = (RoutingDriver) GraphDatabase.driver( uri, config );
272282
Session session = driver.session( AccessMode.WRITE );
273283
Transaction tx = session.beginTransaction() )
274284
{
275285
tx.run( "MATCH (n) RETURN n.name" ).consume();
276286
tx.success();
277287
}
278-
// Finally
279-
assertThat( server.exitStatus(), equalTo( 0 ) );
288+
finally
289+
{
290+
assertThat( server.exitStatus(), equalTo( 0 ) );
291+
}
280292
}
281293

282294
@Test
@@ -377,27 +389,27 @@ public void shouldRoundRobinWriteSessionsInTransaction() throws IOException, Int
377389
@Test
378390
public void shouldFailOnNonDiscoverableServer() throws IOException, InterruptedException, StubServer.ForceKilled
379391
{
380-
//Expect
381-
exception.expect( ServiceUnavailableException.class );
382-
383392
// Given
384393
StubServer.start( "non_discovery_server.script", 9001 );
385394
URI uri = URI.create( "bolt+routing://127.0.0.1:9001" );
386395

396+
//Expect
397+
exception.expect( ServiceUnavailableException.class );
398+
387399
// When
388400
GraphDatabase.driver( uri, config );
389401
}
390402

391403
@Test
392404
public void shouldFailRandomFailureInGetServers() throws IOException, InterruptedException, StubServer.ForceKilled
393405
{
394-
//Expect
395-
exception.expect( ServiceUnavailableException.class );
396-
397406
// Given
398407
StubServer.start( "failed_discovery.script", 9001 );
399408
URI uri = URI.create( "bolt+routing://127.0.0.1:9001" );
400409

410+
//Expect
411+
exception.expect( ServiceUnavailableException.class );
412+
401413
// When
402414
GraphDatabase.driver( uri, config );
403415
}

0 commit comments

Comments
 (0)