From: Tim M. <tim...@po...> - 2002-12-18 00:27:12
|
Yes - that would be a good improvement - I think Ivan's mockmaker implementation does this with its ReturnValues object and the not enough values exception... we should roll this into a unified implementation (the flaw in the mockmaker stuff is that it doesn't tell you the name of the object that didn't have enough values (like expection list and set do) so its a bit mysterious. Tim -----Original Message----- From: moc...@li... [mailto:moc...@li...]On Behalf Of Vincent Massol Sent: 17 December 2002 11:09 To: 'MockObjects' Subject: [MO-java-dev] Important "bug" in the library Hi, I believe there is a common "bug" that can be found in several of our mocks objects. Here's an example, from MockResultSet.java (line 281): public ResultSetMetaData getMetaData() throws SQLException { return myMetaData; } If no setup has been done, it will return null. That's the problem. Imagine the following piece of code (that is part of a third party library): 1 protected void introspect() throws SQLException { 2 3 // Accumulate an ordered list of DynaProperties 4 ArrayList list = new ArrayList(); 5 ResultSetMetaData metadata = resultSet.getMetaData(); 6 int n = metadata.getColumnCount(); [...] If I have some of my code that class under test that calls introspect() and if I haven't set up the behaviour for getMetaData(), I will get a NPE. I was very lucky here as I was able to obtain the source code for this third party library and thus I could find out that the problem was that getMetaData was called. But we might not get that lucky every time! I believe the correct implementation should check if myMetaData has been set or not and if not, throw an exception stating it. What do you think? Thanks -Vincent ------------------------------------------------------- This sf.net email is sponsored by: With Great Power, Comes Great Responsibility Learn to use your power at OSDN's High Performance Computing Channel http://hpc.devchannel.org/ _______________________________________________ Mockobjects-java-dev mailing list Moc...@li... https://lists.sourceforge.net/lists/listinfo/mockobjects-java-dev --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.427 / Virus Database: 240 - Release Date: 06/12/2002 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.427 / Virus Database: 240 - Release Date: 06/12/2002 |