Esempio n. 1
0
 @Test
 public void testMultithreadMultiPartition() throws InterruptedException, SQLException {
   CommonTestUtils.logTestInfo("Test multiple threads hitting a multiple partitions concurrently");
   config.setAcquireIncrement(5);
   config.setMinConnectionsPerPartition(10);
   config.setMaxConnectionsPerPartition(25);
   config.setPartitionCount(5);
   config.setReleaseHelperThreads(0);
   BoneCPDataSource dsb = new BoneCPDataSource(config);
   dsb.setDriverClass("com.jolbox.bonecp.MockJDBCDriver");
   CommonTestUtils.startThreadTest(100, 1000, dsb, 0, false);
   assertEquals(0, dsb.getTotalLeased());
   dsb.close();
   CommonTestUtils.logPass();
 }
Esempio n. 2
0
  @Test
  public void testMultithreadSinglePartition() throws InterruptedException, SQLException {
    CommonTestUtils.logTestInfo("Test multiple threads hitting a single partition concurrently");
    config.setAcquireIncrement(5);
    config.setMinConnectionsPerPartition(30);
    config.setMaxConnectionsPerPartition(100);
    config.setPartitionCount(1);

    BoneCPDataSource dsb = new BoneCPDataSource(config);
    dsb.setDriverClass("org.hsqldb.jdbcDriver");

    CommonTestUtils.startThreadTest(100, 100, dsb, 0, false);
    assertEquals(0, dsb.getTotalLeased());
    dsb.close();
    CommonTestUtils.logPass();
  }
Esempio n. 3
0
  @Test
  public void testMultithreadMultiPartitionWithRandomWorkDelay()
      throws InterruptedException, SQLException {
    CommonTestUtils.logTestInfo(
        "Test multiple threads hitting a partition and doing some work of random duration on each connection");
    config.setAcquireIncrement(5);
    config.setMinConnectionsPerPartition(10);
    config.setMaxConnectionsPerPartition(25);
    config.setPartitionCount(5);

    BoneCPDataSource dsb = new BoneCPDataSource(config);
    dsb.setDriverClass("com.jolbox.bonecp.MockJDBCDriver");

    CommonTestUtils.startThreadTest(100, 10, dsb, -50, false);
    assertEquals(0, dsb.getTotalLeased());
    dsb.close();
    CommonTestUtils.logPass();
  }
Esempio n. 4
0
  @Test
  public void testMultithreadMultiPartitionWithConstantWorkDelay()
      throws InterruptedException, SQLException {
    CommonTestUtils.logTestInfo(
        "Test multiple threads hitting a partition and doing some work on each connection");
    config.setAcquireIncrement(1);
    config.setMinConnectionsPerPartition(10);
    config.setMaxConnectionsPerPartition(10);
    config.setPartitionCount(1);

    BoneCPDataSource dsb = new BoneCPDataSource(config);
    dsb.setDriverClass("org.hsqldb.jdbcDriver");

    CommonTestUtils.startThreadTest(15, 10, dsb, 50, false);
    assertEquals(0, dsb.getTotalLeased());
    dsb.close();
    CommonTestUtils.logPass();
  }