public void test_setConnectionInitSqls() throws Exception {
    DruidPooledConnection conn = dataSource.getConnection().unwrap(DruidPooledConnection.class);

    conn.close();

    dataSource.setConnectionInitSqls(null);
  }
  public void test_change_connectProperties_2() throws Exception {
    DruidPooledConnection conn = dataSource.getConnection().unwrap(DruidPooledConnection.class);

    conn.close();

    dataSource.setConnectionProperties("x=12;;");
  }
  public void test_getValidConnectionCheckerClassName() throws Exception {
    DruidPooledConnection conn = dataSource.getConnection().unwrap(DruidPooledConnection.class);

    conn.close();

    dataSource.getValidConnectionCheckerClassName();
  }
  public void test_error_6() throws Exception {
    DruidPooledConnection conn = dataSource.getConnection().unwrap(DruidPooledConnection.class);

    conn.close();

    dataSource.setMaxActive(1);
  }
예제 #5
0
  public void test_prepCall() throws Exception {
    DruidPooledConnection conn = dataSource.getConnection().unwrap(DruidPooledConnection.class);

    MockPreparedStatement raw = null;
    {
      PreparedStatement stmt =
          conn.prepareCall(
              "SELECT 1",
              ResultSet.TYPE_FORWARD_ONLY,
              ResultSet.CONCUR_READ_ONLY,
              ResultSet.HOLD_CURSORS_OVER_COMMIT);
      raw = stmt.unwrap(MockPreparedStatement.class);
      stmt.close();
    }
    {
      PreparedStatement stmt =
          conn.prepareCall(
              "SELECT 1",
              ResultSet.TYPE_FORWARD_ONLY,
              ResultSet.CONCUR_READ_ONLY,
              ResultSet.HOLD_CURSORS_OVER_COMMIT);
      Assert.assertEquals(raw, stmt.unwrap(MockPreparedStatement.class));
      stmt.close();
    }

    conn.close();
  }
  public void test_error_1() throws Exception {
    DruidPooledConnection conn = dataSource.getConnection().unwrap(DruidPooledConnection.class);

    conn.close();

    dataSource.setPoolPreparedStatements(false);
  }
  public void test_change_minIdle() throws Exception {
    DruidPooledConnection conn = dataSource.getConnection().unwrap(DruidPooledConnection.class);

    conn.close();

    dataSource.setMinIdle(1);
  }
  @SuppressWarnings("deprecation")
  public void test_error_4() throws Exception {
    DruidPooledConnection conn = dataSource.getConnection().unwrap(DruidPooledConnection.class);

    conn.close();

    dataSource.setMaxIdle(1);
  }
  public void test_error_7() throws Exception {
    DruidPooledConnection conn = dataSource.getConnection().unwrap(DruidPooledConnection.class);

    conn.close();

    dataSource.setPassword(dataSource.getPassword());
    dataSource.setPassword("xx");
  }
  public void test_0() throws Exception {
    DruidPooledConnection conn1 = this.dataSource.tryGetConnection();
    Assert.assertNotNull(conn1);

    DruidPooledConnection conn2 = this.dataSource.tryGetConnection();
    Assert.assertNull(conn2);

    conn1.close();
  }
예제 #11
0
  public void test_setConnectionProperties() throws Exception {
    dataSource.setConnectionProperties(null);
    dataSource.setLogWriter(null);
    dataSource.getLogWriter();

    DruidPooledConnection conn = dataSource.getConnection().unwrap(DruidPooledConnection.class);

    conn.close();
  }
예제 #12
0
  public void test_handleException() throws Exception {
    DruidPooledConnection conn = (DruidPooledConnection) dataSource.getConnection();
    conn.close();

    SQLException error = new SQLException();
    try {
      conn.handleException(error);
    } catch (SQLException ex) {
      Assert.assertEquals(error, ex);
    }
  }
예제 #13
0
  public void test_setClientInfo_1() throws Exception {
    DruidPooledConnection conn = dataSource.getConnection().unwrap(DruidPooledConnection.class);
    conn.close();

    {
      SQLException error = null;
      try {
        conn.setClientInfo(new Properties());
      } catch (SQLException ex) {
        error = ex;
      }
      Assert.assertNotNull(error);
    }
  }
예제 #14
0
  public void test_checkOpen_error() throws Exception {
    DruidPooledConnection conn = dataSource.getConnection().unwrap(DruidPooledConnection.class);

    conn.close();
    {
      Exception error = null;
      try {
        conn.checkState();
      } catch (SQLException ex) {
        error = ex;
      }
      Assert.assertNotNull(error);
    }
  }
예제 #15
0
  public void test_removeStatementEventListener() throws Exception {
    DruidPooledConnection conn = dataSource.getConnection().unwrap(DruidPooledConnection.class);

    conn.close();
    {
      Exception error = null;
      try {
        conn.removeStatementEventListener(null);
      } catch (IllegalStateException ex) {
        error = ex;
      }
      Assert.assertNotNull(error);
    }
  }
예제 #16
0
  public void test_prepareStatement_error5() throws Exception {
    DruidPooledConnection conn = dataSource.getConnection().unwrap(DruidPooledConnection.class);

    {
      SQLException error = null;
      try {
        conn.prepareStatement(null, new int[0]);
      } catch (SQLException ex) {
        error = ex;
      }
      Assert.assertNotNull(error);
    }

    conn.close();
  }
예제 #17
0
  public void test_error_10() throws Exception {
    DruidPooledConnection conn = dataSource.getConnection().unwrap(DruidPooledConnection.class);

    conn.close();

    {
      Exception error = null;
      try {
        dataSource.addConnectionProperty("x", "11");
      } catch (Exception ex) {
        error = ex;
      }
      Assert.assertNotNull(error);
    }
  }
예제 #18
0
  public void test_error_12() throws Exception {
    DruidPooledConnection conn = dataSource.getConnection().unwrap(DruidPooledConnection.class);

    conn.close();

    {
      Exception error = null;
      try {
        dataSource.setDriverClassName("");
      } catch (Exception ex) {
        error = ex;
      }
      Assert.assertNotNull(error);
    }
  }
예제 #19
0
  public void test_basic() throws Exception {
    DruidPooledConnection conn = (DruidPooledConnection) dataSource.getConnection();
    conn.close();

    Assert.assertEquals(true, dataSource.isResetStatEnable());
    dataSource.setResetStatEnable(false);
    Assert.assertEquals(false, dataSource.isResetStatEnable());
    Assert.assertEquals(1, dataSource.getConnectCount());
    dataSource.resetStat();
    Assert.assertEquals(1, dataSource.getConnectCount());

    dataSource.setResetStatEnable(true);
    dataSource.resetStat();
    Assert.assertEquals(0, dataSource.getConnectCount());
  }
예제 #20
0
  public void test_error_validateConnection_2() throws Exception {
    DruidPooledConnection conn = dataSource.getConnection().unwrap(DruidPooledConnection.class);

    conn.getConnection().close();

    {
      Exception error = null;
      try {
        dataSource.validateConnection(conn);
      } catch (SQLException ex) {
        error = ex;
      }
      Assert.assertNotNull(error);
    }
  }
예제 #21
0
  public void test_prepareStatement_error() throws Exception {
    DruidPooledConnection conn = dataSource.getConnection().unwrap(DruidPooledConnection.class);

    conn.close();

    {
      Exception error = null;
      try {
        dataSource.setUsername("xxx");
      } catch (Exception ex) {
        error = ex;
      }
      Assert.assertNotNull(error);
    }
  }
예제 #22
0
  public void test_releaseSavepoint_1() throws Exception {
    DruidPooledConnection conn = dataSource.getConnection().unwrap(DruidPooledConnection.class);

    conn.getConnection().close();
    {
      SQLException error = null;
      try {
        conn.releaseSavepoint(null);
      } catch (SQLException ex) {
        error = ex;
      }
      Assert.assertNotNull(error);
    }

    conn.close();
  }
예제 #23
0
  public void test_create_2() throws Exception {
    DruidPooledConnection conn = dataSource.getConnection().unwrap(DruidPooledConnection.class);

    conn.getConnection().close();
    {
      SQLException error = null;
      try {
        conn.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
      } catch (SQLException ex) {
        error = ex;
      }
      Assert.assertNotNull(error);
    }

    conn.close();
  }
예제 #24
0
  public void test_preCall_error_2() throws Exception {
    DruidPooledConnection conn = dataSource.getConnection().unwrap(DruidPooledConnection.class);

    conn.getConnection().close();
    {
      SQLException error = null;
      try {
        conn.prepareCall("SELECT 1");
      } catch (SQLException ex) {
        error = ex;
      }
      Assert.assertNotNull(error);
    }

    conn.close();
  }
예제 #25
0
  public void test_preCall_error_1() throws Exception {
    DruidPooledConnection conn = dataSource.getConnection().unwrap(DruidPooledConnection.class);

    conn.getConnection().close();
    {
      SQLException error = null;
      try {
        conn.prepareCall("SELECT 1", ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
      } catch (SQLException ex) {
        error = ex;
      }
      Assert.assertNotNull(error);
    }

    conn.close();
  }
예제 #26
0
  public void test_handleException_4() throws Exception {
    DruidPooledConnection conn = dataSource.getConnection().unwrap(DruidPooledConnection.class);
    conn.getConnection().close();

    {
      SQLException error = null;
      try {
        conn.prepareStatement("SELECT 1");
      } catch (SQLException ex) {
        error = ex;
      }
      Assert.assertNotNull(error);
    }

    Assert.assertEquals(true, conn.isClosed());
  }
예제 #27
0
  public void test_handleException_2() throws Exception {
    DruidPooledConnection conn = dataSource.getConnection().unwrap(DruidPooledConnection.class);
    conn.getConnection().close();

    {
      SQLException error = null;
      try {
        conn.handleException(new RuntimeException());
      } catch (SQLException ex) {
        error = ex;
      }
      Assert.assertNotNull(error);
    }

    conn.close();
  }
예제 #28
0
  public void test_error_5() throws Exception {
    DruidPooledConnection conn = dataSource.getConnection().unwrap(DruidPooledConnection.class);

    conn.close();

    dataSource.setInitialSize(dataSource.getInitialSize());

    {
      Exception error = null;
      try {
        dataSource.setInitialSize(10);
      } catch (Exception ex) {
        error = ex;
      }
      Assert.assertNotNull(error);
    }
  }
  public void test_stmtCache() throws Exception {
    for (int j = 0; j < 10; ++j) {
      for (int i = 0; i < 10; ++i) {
        Connection conn = dataSource.getConnection();
        String sql = "SELECT" + i;
        PreparedStatement stmt = conn.prepareStatement(sql);
        stmt.execute();
        stmt.close();
        conn.close();
      }
    }

    dataSource.setPoolPreparedStatements(true);

    for (int j = 0; j < 10; ++j) {
      for (int i = 0; i < 10; ++i) {
        Connection conn = dataSource.getConnection();
        String sql = "SELECT" + i;
        PreparedStatement stmt = conn.prepareStatement(sql);
        stmt.execute();
        stmt.close();
        conn.close();
      }
    }

    for (int i = 0; i < 1000 * 1; ++i) {
      Connection conn = dataSource.getConnection();
      PreparedStatement stmt = conn.prepareStatement("SELECT " + i);
      stmt.execute();
      stmt.close();
      conn.close();
    }

    Connection conn = dataSource.getConnection();
    DruidPooledConnection poolableConn = conn.unwrap(DruidPooledConnection.class);
    Assert.assertNotNull(poolableConn);

    Assert.assertEquals(
        dataSource.getMaxPoolPreparedStatementPerConnectionSize(),
        poolableConn.getConnectionHolder().getStatementPool().getMap().size());

    conn.close();

    Assert.assertEquals(0, dataSource.getActiveCount());
    Assert.assertEquals(1, dataSource.getPoolingCount());
  }
예제 #30
0
  public void test_prepareStatement_4() throws Exception {
    DruidPooledConnection conn = dataSource.getConnection().unwrap(DruidPooledConnection.class);

    MockPreparedStatement raw = null;
    {
      PreparedStatement stmt = conn.prepareStatement("SELECT 1", 0);
      raw = stmt.unwrap(MockPreparedStatement.class);
      stmt.close();
    }
    {
      PreparedStatement stmt = conn.prepareStatement("SELECT 1", 0);
      Assert.assertEquals(raw, stmt.unwrap(MockPreparedStatement.class));
      stmt.close();
    }

    conn.close();
  }