openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Pinaki Poddar" <ppod...@bea.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:46:58 GMT
/**
 * Gets the number of SQL issued since last reset.
*/
 public int getSQLCount() 

/**
 * Resets SQL count.
 * @return number of SQL counted since last reset.
 */
 public int resetSQLCount() 

JavaDoc for the methods disambiguates a naive reader's assumption/confusion.  
sql.size() will return total number of SQL while getSQLCount()/resetSQLCount() will provide
a stopwatch-like count.

Moreover, no one is naïve, really.

Pinaki Poddar
972.834.2865
 

>-----Original Message-----
>From: Patrick Linskey [mailto:plinskey@gmail.com] 
>Sent: Thursday, November 01, 2007 4:33 PM
>To: dev@openjpa.apache.org
>Subject: Re: svn commit: r591135 - 
>/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apach
>e/openjpa/persistence/test/SQLListenerTestCase.java
>
>... but a naive reader would probably assume that sql.size() and
>getSQLSize() should return the same thing. Hence, it seems 
>confusing, and if the functionality can be easily attained 
>with existing data structures, then adding confusion to the 
>base class seems bad.
>
>-Patrick
>
>On Nov 1, 2007 2:09 PM, Pinaki Poddar <ppoddar@bea.com> wrote:
>> >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?
>> That is what this change is doing.
>>
>> is this a utility general enough to be in the base class or 
>every test 
>> case that wants to count SQL has to do it locally? I thought it is 
>> generic enough to be in the base class and did introduce a separate 
>> variable rather than sql.size() so that it does not impact anything 
>> else.
>>
>> Pinaki Poddar
>> 972.834.2865
>>
>>
>>
>> >-----Original Message-----
>> >From: Patrick Linskey [mailto:plinskey@gmail.com]
>> >Sent: Thursday, November 01, 2007 4:01 PM
>> >To: dev@openjpa.apache.org
>> >Subject: Re: svn commit: r591135 -
>> >/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apach
>> >e/openjpa/persistence/test/SQLListenerTestCase.java
>> >
>> >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/openj
>> >p
>> >> a/persistence/test/SQLListenerTestCase.java
>> >>
>> >> Modified:
>> >>
>> 
>>openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openj
>> >p
>> >> a/persistence/test/SQLListenerTestCase.java
>> >> URL:
>> >>
>> 
>>http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/s
>> >r
>> >>
>> 
>>c/test/java/org/apache/openjpa/persistence/test/SQLListenerTestCase.j
>> >a
>> >> va?rev=591135&r1=591134&r2=591135&view=diff
>> >>
>> 
>>=====================================================================
>> >=
>> >> ========
>> >> ---
>> >>
>> 
>>openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openj
>> >p
>> >> a/persistence/test/SQLListenerTestCase.java (original)
>> >> +++
>> >openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/op
>> >> +++ enjpa/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
>> >
>>
>> Notice:  This email message, together with any attachments, 
>may contain information  of  BEA Systems,  Inc.,  its 
>subsidiaries  and  affiliated entities,  that may be 
>confidential,  proprietary,  copyrighted  and/or legally 
>privileged, and is intended solely for the use of the 
>individual or entity named in this message. If you are not the 
>intended recipient, and have received this message in error, 
>please immediately return this by email and then delete it.
>>
>
>
>
>--
>Patrick Linskey
>202 669 5907
>

Notice:  This email message, together with any attachments, may contain information  of  BEA
Systems,  Inc.,  its subsidiaries  and  affiliated entities,  that may be confidential,  proprietary,
 copyrighted  and/or legally privileged, and is intended solely for the use of the individual
or entity named in this message. If you are not the intended recipient, and have received
this message in error, please immediately return this by email and then delete it.

Mime
View raw message