commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mohan Kishore <>
Subject RE: [math] stupid question about test input files
Date Wed, 14 May 2003 21:49:26 GMT
I think, what Phil is saying is that the current API accepts a String
indicating path to data file. Now, this path coupld be either the full path, or
relative to current directory.

IMHO, if it makes sense to use InputStream as the input in API, it would be the
best. The other overloaded methods (String or File etc) can just route the
call. And then we can use Gary's or Craig's way to test it.

If that does not make sense, I guess we should use the current directory
approach, which should work uniformly when using Ant...

--- Gary Gregory <> wrote:
> Here is an example of using the class path and class loader to resolved
> files:
> Your code is rooted in src/java/
> Example: 
> /Apache Jakarta
> Commons/lang/src/java/org/apache/commons/lang/
> Your tests are rooted in src/test
> Example:
> /Apache Jakarta
> Commons/lang/src/test/org/apache/commons/lang/
> Your test fixture files are rooted in home/src/resource
> Example:
> /Project/src/resource/com/company/foo/bar/test.xml
> Code is compiled to bin. 
> Put "bin" and "src/resource" on your classpath. Some environments may copy
> your resources to your bin directory.
> From your code:
> URL url = ClassLoader.getSystemResource("com/company/foo/bar/test.xml");
> That's it. From there you can get a for example.
> Gary
> -----Original Message-----
> From: Phil Steitz [] 
> Sent: Wednesday, May 14, 2003 2:10 PM
> To:
> Subject: RE: [math] stupid question about test input files
> Sorry if I am being exceedingly dense here, but I
> looked at the Digester test cases and unless I am
> missing something, that approach will not work for me,
> since the objects that I am testing open files
> themselves using fully qualified file paths passed in
> to them as strings -- i.e., my test cases have code
> like:
> empiricalDistribution.setFilePath("full-file-path");
> or empiricalDistribution.load("full-file-path");
> In my local non-jakarta-standard setup, I use the ant
> java dir attribute to force the tests to run from the
> location where the test data file lives or I use full
> path specs.  I do not like this.  Am I missing some
> easy way out of this ugliness?  
> If the answer is to extend the API to take Files or
> Streams, I am or course open to this, but I would
> prefer to do so for a reason other than so that I can
> get my tests deployed :-)
> Phil
> __________________________________
> Do you Yahoo!?
> The New Yahoo! Search - Faster. Easier. Bingo.
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message