openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Patrick Linskey" <plins...@gmail.com>
Subject Re: svn commit: r591135 - /openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/test/SQLListenerTestCase.java
Date Thu, 01 Nov 2007 21:00:49 GMT
Hi,

What does this change do that cannot be achieved by just storing the
count in a local variable or something and doing math in the test
case?

I'm nervous about making our base test classes present a number of
ways to do similar things; in the past, I've found that doing that
ends up leading to confusion in the test cases.

-Patrick

On Nov 1, 2007 12:36 PM,  <ppoddar@apache.org> wrote:
> Author: ppoddar
> Date: Thu Nov  1 12:36:55 2007
> New Revision: 591135
>
> URL: http://svn.apache.org/viewvc?rev=591135&view=rev
> Log:
> Added to count SQL issued. Current sql list size is not used so that user can reset the
counter without destroying the list of SQL.
>
> Modified:
>     openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/test/SQLListenerTestCase.java
>
> Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/test/SQLListenerTestCase.java
> URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/test/SQLListenerTestCase.java?rev=591135&r1=591134&r2=591135&view=diff
> ==============================================================================
> --- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/test/SQLListenerTestCase.java
(original)
> +++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/test/SQLListenerTestCase.java
Thu Nov  1 12:36:55 2007
> @@ -35,7 +35,8 @@
>      extends SingleEMFTestCase {
>
>      protected List<String> sql = new ArrayList<String>();
> -
> +    protected int sqlCount;
> +
>      @Override
>      public void setUp(Object... props) {
>          Object[] copy = new Object[props.length + 2];
> @@ -92,14 +93,33 @@
>          fail("Expected regular expression <" + sqlExp + "> to be"
>              + " contained in SQL statements: " + sql);
>      }
> +
> +    /**
> +     * Gets the number of SQL issued since last reset.
> +     */
> +    public int getSQLCount() {
> +       return sqlCount;
> +    }
> +
> +    /**
> +     * Resets SQL count.
> +     * @return number of SQL counted since last reset.
> +     */
> +    public int resetSQLCount() {
> +       int tmp = sqlCount;
> +       sqlCount = 0;
> +       return tmp;
> +    }
>
>      public class Listener
>          extends AbstractJDBCListener {
>
>          @Override
>          public void beforeExecuteStatement(JDBCEvent event) {
> -            if (event.getSQL() != null && sql != null)
> +            if (event.getSQL() != null && sql != null) {
>                  sql.add(event.getSQL());
> +                sqlCount++;
> +            }
>                 }
>         }
>  }
>
>
>



-- 
Patrick Linskey
202 669 5907

Mime
View raw message