View source | View content page | Page history | Printable version   
Toolbox
Main Page
Upload file
What links here
Recent changes
Help

PDF Books
Show collection (0 pages)
Collections help

Search

Projects:Inclusion Of Apache JDBC Connection Pool In Distribution/QA

Test Plan

Defined in TestLink in Platform > Connection Pool Project suite. The following scenarios have been tested manually to check any problems in the upgrade to 3.0PR15Q4.

Performance test

As we saw in Performance considerations section some performance tests to obtain multiple serial connections have been made. This performance test is following:

package org.openbravo.test;
 
import java.lang.reflect.Method;
import java.sql.Connection;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Properties;
 
import org.hibernate.Session;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
import org.openbravo.base.session.OBPropertiesProvider;
import org.openbravo.dal.core.SessionHandler;
import org.openbravo.database.ConnectionProviderImpl;
import org.openbravo.database.ExternalConnectionPool;
import org.openbravo.test.base.HiddenObjectHelper;
import org.openbravo.test.base.OBBaseTest;
 
@RunWith(Parameterized.class)
public class ConnectionPool extends OBBaseTest {
  private static final int NUM_OF_EXECUTIONS = 10;
 
  private String poolClass;
  private int numOfConns;
 
  public ConnectionPool(String poolClass, int numOfConns) {
    this.poolClass = poolClass;
    this.numOfConns = numOfConns;
  }
 
  @Parameters(name = "{0} - {1}")
  public static Collection<Object[]> params() {
 
    String pools[] = { //
    "org.openbravo.apachejdbcconnectionpool.JdbcExternalConnectionPool", //
        "", //
    };
    List<Object[]> configs = new ArrayList<Object[]>();
    for (String pool : pools) {
      configs.add(new Object[] { pool, 10 });
      configs.add(new Object[] { pool, 50 });
      configs.add(new Object[] { pool, 100 });
      configs.add(new Object[] { pool, 1000 });
      configs.add(new Object[] { pool, 10000 });
      // configs.add(new Object[] { pool, 100000 });
      // configs.add(new Object[] { pool, 1000000 });
    }
 
    return configs;
  }
 
  @Test
  public void xsql() throws Exception {
 
    Properties properties = OBPropertiesProvider.getInstance().getOpenbravoProperties();
    properties.put("db.externalPoolClassName", poolClass);
    ConnectionProviderImpl cp = new ConnectionProviderImpl(properties);
    // cp.getConnection();
 
    Method newConnMethod = ConnectionProviderImpl.class.getDeclaredMethod("getNewConnection",
        String.class);
    newConnMethod.setAccessible(true);
 
    for (int exec = 0; exec < NUM_OF_EXECUTIONS; exec++) {
      long t = System.currentTimeMillis();
      for (int i = 0; i < numOfConns; i++) {
        Connection cn = (Connection) newConnMethod.invoke(cp, "myPool");
        cn.close();
      }
      System.out.println("xsql   :" + ("".equals(poolClass) ? "commons.dbcp" : poolClass) + "("
          + numOfConns + "): " + (System.currentTimeMillis() - t));
    }
  }
 
  @Test
  public void dal() throws Exception {
    SessionHandler sh = SessionHandler.getInstance();
    sh.commitAndClose();
    if (!"".equals(poolClass)) {
      HiddenObjectHelper.set(sh, "externalConnectionPool",
          ExternalConnectionPool.getInstance(poolClass));
    } else {
      HiddenObjectHelper.set(sh, "externalConnectionPool", null);
    }
    Method createSession = SessionHandler.class.getDeclaredMethod("createSession");
    createSession.setAccessible(true);
    for (int exec = 0; exec < NUM_OF_EXECUTIONS; exec++) {
      long t = System.currentTimeMillis();
      for (int i = 0; i < numOfConns; i++) {
        HiddenObjectHelper.set(sh, "connection", null);
        Session s = (Session) createSession.invoke(sh);
 
        Connection conn = sh.getConnection();
        if (conn != null) {
          sh.getConnection().close();
        }
        s.close();
      }
      System.out.println("dal    :" + ("".equals(poolClass) ? "commons.dbcp" : poolClass) + "("
          + numOfConns + "): " + (System.currentTimeMillis() - t));
    }
  }
}

Retrieved from "http://wiki.openbravo.com/wiki/Projects:Inclusion_Of_Apache_JDBC_Connection_Pool_In_Distribution/QA"

This page has been accessed 334 times. This page was last modified on 6 August 2015, at 08:24. Content is available under Creative Commons Attribution-ShareAlike 2.5 Spain License.