From: Oskar H. <osk...@de...> - 2002-04-17 10:20:54
|
Hi. I could not live with out the unit tests ... they make you feel so safe :) I ran my modified Unit test against your code and found three things missing. * Missing set-up method for getTableName() * Missing set-up method for getColumnClassName() * The getColumnLabel(...) should return the same value as getColumName(...) (At least my Oracle JDBC drivers does so) Also I saw that you used myNames.remove(0) when you retrieve the column Name. Shouldn't it be implemented like this : public String getColumnName(int aColumnIndex) throws SQLException { return (String)myNames.get(aColumnIndex-1); } In stead of: public String getColumnName(int aColumnIndex) throws SQLException { return (String)myNames.remove(0); } Anyway I applied the above changes to MockResultSetMetaData and attached it to this mail plus the Unit test. I put the unittest under the package "com.mockobjects.sql.test" Regards. Oskar H. PS! Here is a diff -u of the code --- C:\tmp\mockobjects\mockobjects-java\src\jdk\common\com\mockobjects\sql\MockR esultSetMetaData.java Tue Apr 16 17:04:02 2002 +++ C:\projects\MockObjects2\src\jdk\common\com\mockobjects\sql\MockResultSetMet aData.java Wed Apr 17 09:38:49 2002 @@ -9,6 +9,8 @@ implements ResultSetMetaData { private Vector myNames =3D new Vector(); + private Vector myTableNames =3D new Vector(); + private Vector myColumnClassNames =3D new Vector(); /** * @see ResultSetMetaData#getColumnCount() @@ -76,9 +78,8 @@ /** * @see ResultSetMetaData#getColumnLabel(int) */ - public String getColumnLabel(int arg0) throws SQLException { - notImplemented(); - return null; + public String getColumnLabel(int aColumnIndex) throws SQLException { + return getColumnName(aColumnIndex); } public void addColumnNames(String[] allNames) { @@ -97,7 +98,7 @@ * @see ResultSetMetaData#getColumnName(int) */ public String getColumnName(int aColumnIndex) throws SQLException { - return (String)myNames.remove(0); + return (String)myNames.get(aColumnIndex-1); } /** @@ -127,9 +128,16 @@ /** * @see ResultSetMetaData#getTableName(int) */ - public String getTableName(int arg0) throws SQLException { - notImplemented(); - return null; + public String getTableName(int aColumnIndex) throws SQLException { + return (String)myTableNames.get(aColumnIndex-1); + } + + public void addTableNames(String[] allNames) { + if (myTableNames !=3D null) { + for (int i =3D 0; i < allNames.length; i++) { + myTableNames.add(allNames[i]); + } + } } /** @@ -183,8 +191,15 @@ /** * @see ResultSetMetaData#getColumnClassName(int) */ - public String getColumnClassName(int arg0) throws SQLException { - notImplemented(); - return null; + public String getColumnClassName(int aColumnIndex) throws SQLException { + return (String)myColumnClassNames.get(aColumnIndex-1); + } + + public void addColumnClassNames(String[] allNames) { + if (myColumnClassNames !=3D null) { + for (int i =3D 0; i < allNames.length; i++) { + myColumnClassNames.add(allNames[i]); + } + } } } ------------------- THE DIFF END ---------------------------- -----Original Message----- From: moc...@li... [mailto:moc...@li...]On Behalf Of Christian Trutz Sent: 16. apr=EDl 2002 16:58 To: Mockobjects Subject: Re: [MO-java-dev] MockConnection Hi Oskar, some unit tests for MockResultSetMetaData would be very nice ;-) Christian -----Urspr=FCngliche Nachricht----- Von: moc...@li... [mailto:moc...@li...]Im Auftrag von Oskar Hannesson Gesendet: Dienstag, 16. April 2002 18:34 An: 'Jeff Martin'; 'MockObjects' Betreff: [MO-java-dev] MockConnection Hi there! It is nice to see the MockResultSetMetaData class finally make its way in to CVS , even though I posted similar code (+ unit test) some six months ago:-( When I started using Mockobjects last year I ran in to problems having multiple Statements pr. connection. The current version of MockConnection supports only one Statement pr. connection so I modified it and posted it to this group. The code never made it to the CVS so I ask: Is someone currently working on this problem or should I try to re-commit my implementation and hope for a better response ? I found some 8 months old code in CVS (mockobjects-java/src/extensions/com/mockobjects/eziba/sql) which seem to be addressing some this problem. Is this perhaps an upcoming version of the sql package? Regards Oskar Hannesson deCODE Genetics Addr: Sturlugata 8 , 101 Reykjavik, Iceland Tel: (354) 570-1900 Fax: (354) 570-1903 Web: www.decode.com PS! I really hate relying on my own private version of MockObjects. =5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F= =5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F Mockobjects-java-dev mailing list Moc...@li... https://lists.sourceforge.net/lists/listinfo/mockobjects-java-dev =5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F= =5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F Mockobjects-java-dev mailing list Moc...@li... https://lists.sourceforge.net/lists/listinfo/mockobjects-java-dev |