Source:
public void listQueriesWillNotIncludeQueriesFromOtherServersInCluster() throws Exception { String CORE_QUERY = "MATCH (n) SET n.number = n.number - 1"; String REPLICA_QUERY = "MATCH (n) RETURN n"; CountDownLatch resourceLocked = new CountDownLatch(1); CountDownLatch listQueriesLatchOnCore = new CountDownLatch(1); CountDownLatch executedCoreQueryLatch = new CountDownLatch(1); ReadReplicaGraphDatabase replicaDb = cluster.findAnyReadReplica().database(); final Node[] node = new Node[1]; CoreClusterMember leader = cluster.coreTx((CoreGraphDatabase leaderDb, Transaction tx) -> { node[0] = leaderDb.createNode(); tx.success(); tx.close(); }); CoreGraphDatabase leaderDb = leader.database(); Result matchAllResult = leaderDb.execute("MATCH (n) RETURN n"); assertTrue(matchAllResult.hasNext()); try { acquireLocksAndSetupCountdownLatch(resourceLocked, listQueriesLatchOnCore, node[0]); resourceLocked.await(); executeQueryOnReplicaAndLeader(leaderDb, CORE_QUERY, replicaDb, REPLICA_QUERY, executedCoreQueryLatch); try { Map<String, Object> coreQueryListing = getQueryListing(CORE_QUERY, leaderDb).get(); Optional<Map<String, Object>> replicaQueryListing = getQueryListing(REPLICA_QUERY, replicaDb); assertNotNull(coreQueryListing); assertThat(coreQueryListing.get("activeLockCount"), is(1l)); assertFalse(replicaQueryListing.isPresent()); listQueriesLatchOnCore.countDown(); executedCoreQueryLatch.await(); assertFalse(getQueryListing(CORE_QUERY, leaderDb).isPresent()); } catch (Exception e) { e.printStackTrace(); fail("Couldn't countdown listqueries latch"); } } catch (InterruptedException e) { e.printStackTrace(); fail("Should create node and list queries"); } }

Target:
public void listQueriesWillNotIncludeQueriesFromOtherServersInCluster() throws Exception { String CORE_QUERY = "MATCH (n) SET n.number = n.number - 1"; String REPLICA_QUERY = "MATCH (n) RETURN n"; CountDownLatch resourceLocked = new CountDownLatch( 1 ); CountDownLatch listQueriesLatchOnCore = new CountDownLatch( 1 ); CountDownLatch executedCoreQueryLatch = new CountDownLatch( 1 ); ReadReplicaGraphDatabase replicaDb = cluster.findAnyReadReplica().database(); final Node[] node = new Node[1]; CoreClusterMember leader = cluster.coreTx( ( CoreGraphDatabase leaderDb, Transaction tx ) -> { node[0] = leaderDb.createNode(); tx.success(); tx.close(); } ); CoreGraphDatabase leaderDb = leader.database(); Result matchAllResult = leaderDb.execute( "MATCH (n) RETURN n" ); assertTrue( matchAllResult.hasNext() ); matchAllResult.close(); try { acquireLocksAndSetupCountdownLatch( resourceLocked, listQueriesLatchOnCore, node[0] ); resourceLocked.await(); executeQueryOnReplicaAndLeader( leaderDb, CORE_QUERY, replicaDb, REPLICA_QUERY, executedCoreQueryLatch ); try { Map<String,Object> coreQueryListing = getQueryListing( CORE_QUERY, leaderDb ).get(); Optional<Map<String,Object>> replicaQueryListing = getQueryListing( REPLICA_QUERY, replicaDb ); assertNotNull( coreQueryListing ); assertThat( coreQueryListing.get( "activeLockCount" ), is( 1L ) ); assertFalse( replicaQueryListing.isPresent() ); listQueriesLatchOnCore.countDown(); executedCoreQueryLatch.await(); assertFalse( getQueryListing( CORE_QUERY, leaderDb ).isPresent() ); } catch ( Exception e ) { e.printStackTrace(); fail( "Couldn't countdown listqueries latch" ); } } catch ( InterruptedException e ) { e.printStackTrace(); fail( "Should create node and list queries" ); } }