/*
   * (non-Javadoc)
   *
   * @see junit.framework.TestCase#setUp()
   */
  public void setUp() throws Exception {
    super.setUp();

    System.out.println("Calculating performance scaling factor...");
    // Run this simple test to get some sort of performance scaling factor,
    // compared to
    // the development environment. This should help reduce false-positives
    // on this test.
    int numLoops = 10000;

    long start = currentTimeMillis();

    for (int j = 0; j < 2000; j++) {
      StringBuffer buf = new StringBuffer(numLoops);

      for (int i = 0; i < numLoops; i++) {
        buf.append('a');
      }
    }

    long elapsedTime = currentTimeMillis() - start;

    System.out.println("Elapsed time for factor: " + elapsedTime);

    this.scaleFactor = (double) elapsedTime / (double) ORIGINAL_LOOP_TIME_MS;

    System.out.println("Performance scaling factor is: " + this.scaleFactor);
  }
Ejemplo n.º 2
0
 /**
  * Destroy resources created by test case
  *
  * @throws Exception if an error occurs
  */
 public void tearDown() throws Exception {
   try {
     this.stmt.executeUpdate("DROP TABLE IF EXISTS BLOBTEST");
   } catch (Exception e) {
     e.printStackTrace();
   } finally {
     super.tearDown();
   }
 }
Ejemplo n.º 3
0
 /**
  * Un-binds the DataSource, and cleans up the filesystem
  *
  * @throws Exception if an error occurs
  */
 @Override
 public void tearDown() throws Exception {
   try {
     this.ctx.unbind(this.tempDir.getAbsolutePath() + "/test");
     this.ctx.close();
     this.tempDir.delete();
   } finally {
     super.tearDown();
   }
 }
  private static final double calculateScaleFactor() {
    // Run this simple test to get some sort of performance scaling factor, compared to the
    // development environment. This should help reduce false-positives
    // on this test.
    int numLoops = 10000;

    long start = BaseTestCase.currentTimeMillis();

    for (int j = 0; j < 2000; j++) {
      // StringBuffer below is used for measuring and can't be changed to StringBuilder.
      StringBuffer buf = new StringBuffer(numLoops);

      for (int i = 0; i < numLoops; i++) {
        buf.append('a');
      }
    }

    long elapsedTime = BaseTestCase.currentTimeMillis() - start;
    return elapsedTime / ORIGINAL_LOOP_TIME_MS;
  }
  @Override
  public synchronized void setUp() throws Exception {
    super.setUp();

    System.out.println("Adjusting global performance scaling factor...");
    System.out.println(
        "Gobal performance scaling factor adjusted from: "
            + scaleFactor
            + " to: "
            + adjustScaleFactor());
  }
Ejemplo n.º 6
0
  /**
   * DOCUMENT ME!
   *
   * @throws Exception DOCUMENT ME!
   */
  public void tearDown() throws Exception {
    stmt.executeUpdate("DROP TABLE statement_test");

    for (int i = 0; i < MAX_COLUMNS_TO_TEST; i += STEP) {

      StringBuffer stmtBuf = new StringBuffer("DROP TABLE IF EXISTS statement_col_test_");
      stmtBuf.append(i);
      stmt.executeUpdate(stmtBuf.toString());
    }

    try {
      stmt.executeUpdate("DROP TABLE statement_batch_test");
    } /* ignore */ catch (SQLException sqlEx) {;
    }

    super.tearDown();
  }
Ejemplo n.º 7
0
  /**
   * Setup the test case
   *
   * @throws Exception if an error occurs
   */
  public void setUp() throws Exception {
    super.setUp();

    if (versionMeetsMinimum(4, 0)) {
      int requiredSize = 32 * 1024 * 1024;

      if (testBlobFile == null || testBlobFile.length() != requiredSize) {
        createBlobFile(requiredSize);
      }

    } else {
      int requiredSize = 8 * 1024 * 1024;

      if (testBlobFile == null || testBlobFile.length() != requiredSize) {
        createBlobFile(requiredSize);
      }
    }

    createTestTable();
  }
 /**
  * DOCUMENT ME!
  *
  * @throws Exception DOCUMENT ME!
  */
 public void setUp() throws Exception {
   super.setUp();
   createTestTable();
 }
Ejemplo n.º 9
0
 /**
  * Sets up this test, calling registerDataSource() to bind a DataSource into JNDI, using the
  * FSContext JNDI provider from Sun
  *
  * @throws Exception if an error occurs.
  */
 @Override
 public void setUp() throws Exception {
   super.setUp();
   registerDataSource();
 }
Ejemplo n.º 10
0
  /**
   * DOCUMENT ME!
   *
   * @throws Exception DOCUMENT ME!
   */
  public void setUp() throws Exception {
    super.setUp();

    try {
      stmt.executeUpdate("DROP TABLE statement_test");
    } /* ignore */ catch (SQLException sqlEx) {;
    }

    try {
      stmt.executeUpdate("DROP TABLE statement_batch_test");
    } /* ignore */ catch (SQLException sqlEx) {;
    }

    stmt.executeUpdate(
        "CREATE TABLE statement_test (id int not null primary key auto_increment, strdata1 varchar(255) not null, strdata2 varchar(255))");

    stmt.executeUpdate(
        "CREATE TABLE statement_batch_test "
            + "(id int not null primary key auto_increment, "
            + "strdata1 varchar(255) not null, strdata2 varchar(255), "
            + "UNIQUE INDEX (strdata1))");

    for (int i = 6; i < MAX_COLUMNS_TO_TEST; i += STEP) {

      StringBuffer insertBuf = new StringBuffer("INSERT INTO statement_col_test_");
      StringBuffer stmtBuf = new StringBuffer("CREATE TABLE IF NOT EXISTS statement_col_test_");
      stmtBuf.append(i);
      insertBuf.append(i);
      stmtBuf.append(" (");
      insertBuf.append(" VALUES (");

      boolean firstTime = true;

      for (int j = 0; j < i; j++) {

        if (!firstTime) {
          stmtBuf.append(",");
          insertBuf.append(",");
        } else {
          firstTime = false;
        }

        stmtBuf.append("col_");
        stmtBuf.append(j);
        stmtBuf.append(" VARCHAR(");
        stmtBuf.append(MAX_COLUMN_LENGTH);
        stmtBuf.append(")");
        insertBuf.append("'");

        int numChars =
            (int) (Math.random() * (MAX_COLUMN_LENGTH - MIN_COLUMN_LENGTH)) + MIN_COLUMN_LENGTH;

        for (int k = 0; k < numChars; k++) {
          insertBuf.append("A");
        }

        insertBuf.append("'");
      }

      stmtBuf.append(")");
      insertBuf.append(")");
      stmt.executeUpdate(stmtBuf.toString());
      stmt.executeUpdate(insertBuf.toString());
    }

    // explicitly set the catalog to exercise code in execute(), executeQuery() and
    // executeUpdate()
    // FIXME: Only works on Windows!
    // conn.setCatalog(conn.getCatalog().toUpperCase());
  }