// allow connections to slave2:
UnreliableSocketFactory.dontDownHost("slave2");
// force next re-balance to slave2:
ForcedLoadBalanceStrategy.forceFutureServer("slave2:" + portNumber, -1);
// re-balance:
conn2.commit();
// down slave1 (active but not selected slave connection):
UnreliableSocketFactory.downHost("slave1");
// should succeed, as slave2 is currently selected:
conn2.createStatement().execute("/* ping */ SELECT 1");