From: Simon L. <sim...@uk...> - 2002-09-16 16:23:31
|
As part of my role to evaluate/develop the MockObjects SQL functionality=20 I've re-worked some of the classes in order to satisfy the testing=20 requirements we'd like to meet. I've also been looking at them in order to implement a=20 MockCallableStatement (Not yet done). I'd like to present my current set of changes back to the group for=20 comments and/or inclusion into the codebase. They are as follows: =2D ExpectationMap & ReturnObjectList - methods to enable and perform the verify()cation of objects contained therein. Default to original functionality. - ReturnObjectList keeps its list of objects to allow above. =2D CommonMockConnection=20 - method to allow the automated checking of associated PreparedStatements. - Automatically associates Statements with Connection on return. =2D CommonMockStatement: - INTERFACE CHANGE: setExpectedQueryString now makes given query the only one on the object. addExpectedQueryString allows more to be=20 added. Did this for constancy more than anything. - setupResultSet/setupAddResultSet used to set/add ResultSets to the=20 connection. - addResultSet deprecated (in favour to setupAddResultSet(). - An update count is treated the same as a normal ResultSet - more=20 closely follows the java.jdbc specification (eg. a Statement result=20 is either a ResultSet or an update count). The query counts are queued with the ResultSets for retrieval after execute calls. - Automatically associates ResultSets with the Statement on return.=20 - method to allow the automated checking of associated ResultSets. ResultSets (in general) - CommonMockResult created in jdk/common that defines single a ResultSet interface that supports single & multi row result sets. - Allows the verification/expectation checking of row data retrieval from all rows (not just the first). - Each jdk/<version>/com/mockobjects/sql now defines a single=20 MockResultSet that allows the definition of JDK specific additional=20 methods/interfaces that may be required. MockResultSet removed from jdk/common. Now uses a similar model to Connection and Statement. - MockSingleRowResultSet & MockMultiRowResultSet objects/interfaces=20 retained for backwards compatibility (moved into jdk/common -=20 extends MockResultSet defined in jdk/<version>)). Both removed from jdk/<version> trees. MockMultiRowResultSet basically just defines a single deprecated method from its original interface (MockResultSet defines the rest). - MockUpdateResultSet added for update count support (extends=20 MockSingleRowResultSet). - POTENTIAL issue: These changes add a requirement that=20 jdk/common/com/mockobjects/sql needs a jdk/<version> derived MockResultSet in order to compile. (Doesn't break ant build though). - Can now set/add to the row name mappings and rows returned. MockSingleRowResultSet allows setting/adding of individual elements=20 within the row. - If name mapping supplied, can use name and/or index to access row=20 data. (Name mapping currently needs to be supplied before data to=20 work correctly). - Automatically associates ResultSet with Statement on return. - method to allow the automated checking of Row expectations. Given that there is a fair bit of class movement in these changes how=20 should supply these (a cvs diff -u doesn't cope with new/deleted files). Perhaps a CVS branch where I could commit these to? Other things I'd like to do: =2D Develop a DeferredException class that causes an exception to be thrown after a certain number of events has occured (eg. throws an=20 SQLException on the third call to next() on a ResultSet) =2D Add mechanism for specifying a particular value on a row shouldn't be retrieved (code may be retrieving different columns depending on data it find in others). =2D Add support for Statements that return Multiple resultSets on one=20 execution. (Not that high a priority). Cheers, Simon., =2D-=20 =2D------------------------------------------------------------------------- Simon Levitt, Senior Development Engineer @ WorldPay plc, WorldPay Centre, The Science Park, Milton Rd., Cambridge, CB4 0WE, ENGLAND = =20 Sim...@uk... Ph:+44(0)1223 715151 F:+44(0)1223 715157 =2D------------------------ http://www.worldpay.com/ ----------------------- |