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.

git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@591135 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Pinaki Poddar 2007-11-01 19:36:55 +00:00
parent 830cc35014
commit 18cc4b932f
1 changed files with 22 additions and 2 deletions

View File

@ -35,6 +35,7 @@ public abstract class SQLListenerTestCase
extends SingleEMFTestCase {
protected List<String> sql = new ArrayList<String>();
protected int sqlCount;
@Override
public void setUp(Object... props) {
@ -93,13 +94,32 @@ public abstract class SQLListenerTestCase
+ " 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++;
}
}
}
}