public void testGetNames() {
   String[] names = ConnectionProviderFactory.getNames();
   System.out.println("\nall active providers: " + names.length);
   for (int i = 0; i < names.length; i++) {
     System.out.println("[" + i + "]" + names[i]);
   }
 }
 private void createConnection() throws SQLException {
   connectionProvider = ConnectionProviderFactory.newConnectionProvider(properties);
   connection = connectionProvider.getConnection();
   if (!connection.getAutoCommit()) {
     connection.commit();
     connection.setAutoCommit(true);
   }
 }
  public void testLookupByName() {
    this.log("to test lookupByName() ...");

    IConnectionProvider provider = null;
    try {
      String sName = "Local";
      System.out.println("\n\n to find connection provider " + sName + "...");
      provider = ConnectionProviderFactory.lookupByName(sName);

      if (provider == null) {
        fail("connection provider " + sName + " is not found");
      }

      // else
      System.out.println("connection provider " + sName + " is found");
      System.out.println(provider.toString());

      long lStartTime, lEndTime;
      Connection connection;
      for (int i = 0; i < 8; i++) {
        try {
          lStartTime = System.currentTimeMillis();
          connection = provider.getConnection();
          lEndTime = System.currentTimeMillis();
          System.out.println(
              "["
                  + (i + 1)
                  + "] connection is fetched using time "
                  + (lEndTime - lStartTime)
                  + "ms");
          if ((i / 4) % 2 == 1) {
            provider.closeConnection(connection);
          }
        } catch (Exception ex) {
          ex.printStackTrace(System.out);
        }

        System.out.println("\nto sleep 1s...");
        Thread.sleep(1000);
      }
      assertTrue(true);
    } catch (Exception ex) {
      ex.printStackTrace(System.out);
      fail(ex.getMessage());
    } finally {
      if (provider != null) {
        provider.clear();
      }
    }
  }
  public void testLookupDefault() {
    this.log("to test lookupDefault() ...");

    try {
      IConnectionProvider provider = ConnectionProviderFactory.lookupDefault();
      if (provider == null) {
        fail("default connection provider is not found");
      }

      // else
      System.out.println(
          "default connection provider is found: "
              + DolphinConfigHelper.getDefaultConnectionProviderName());
      System.out.println(provider.toString());
      assertTrue(true);
    } catch (Exception ex) {
      ex.printStackTrace(System.out);
      fail(ex.getMessage());
    }
  }