@SuppressWarnings("unchecked")
private void connect(String url, String id) throws Exception
{
DatabaseCluster<java.sql.Driver, DriverDatabase> cluster = mock(DatabaseCluster.class);
Balancer<java.sql.Driver, DriverDatabase> balancer = mock(Balancer.class);
LockManager lockManager = mock(LockManager.class);
DriverDatabase database = new DriverDatabase();
database.setId("db1");
database.setLocation("jdbc:mock:test");
Driver driver = new Driver();
Driver.setConfigurationFactory(id, this.configurationFactory);
when(this.factory.createDatabaseCluster(eq(id), same(this.configurationFactory))).thenReturn(cluster);
when(cluster.isActive()).thenReturn(true);
when(cluster.getBalancer()).thenReturn(balancer);
when(balancer.iterator()).thenReturn(Collections.singleton(database).iterator());
when(cluster.getBalancer()).thenReturn(balancer);
when(balancer.contains(database)).thenReturn(true);
when(balancer.isEmpty()).thenReturn(false);
when(balancer.size()).thenReturn(1);
when(balancer.iterator()).thenReturn(Collections.singleton(database).iterator());
when(balancer.next()).thenReturn(database);
when(cluster.getExecutor()).thenReturn(Executors.newCachedThreadPool());
when(cluster.getLockManager()).thenReturn(lockManager);
when(lockManager.readLock(null)).thenReturn(mock(Lock.class));
when(cluster.getDurability()).thenReturn(mock(Durability.class));
when(cluster.getTransactionIdentifierFactory()).thenReturn(mock(TransactionIdentifierFactory.class));
try
{