From: Tim M. <tim...@po...> - 2002-08-22 23:22:35
|
Guys - I don't understand how alt.java.io.File (the interface that sun should have used in the first place) helps us mock stuff up? I must be missing something very obvious - but if I have a MockFile that conforms to that interface, I can't use it with Sun's FileReader object which expects a java.io.File (there is a basic type difference problem here). So I guess I don't understand the point of it??? At connextra we have subclassed things like java.io.Reader (as we did for some of the other io classes - some of which live in the orginial mockobjects code base), and have implemented the crucial methods that get it to work as a stub and a mock. This way a MockReader can be used with a BufferedReader and you can write relevent tests with it. For trickier classes like File - which really seem to require fileDescriptor objects we have adopted the "SimpleFile" convention, which just wraps File and just delegates a subset of the most useful methods. This interface also provides getFile, so that if you do use it at a low level in your code you can get the File object and pass it to something like an XML Document class (although we tend to use a MockReader in preference to the real file anyway). Is alt.java.io.File an equivalent to the SimpleFile strategy? It doesn't seem to be to me - so I am scratching my head trying to understand how its being used in production code at the moment? With regards to some of this stuff, I promise to reintegrate asap to pass on some of the stuff we have lurking around. Its taken us a long time to get off visualAge so we can more easily work on open source projects (we are almost there). Tim --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.381 / Virus Database: 214 - Release Date: 02/08/2002 |