commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mohan Kishore <mohankish...@yahoo.com>
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 <ggregory@seagullsw.com> 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/ArrayUtils.java
> 
> Your tests are rooted in src/test
> Example:
> /Apache Jakarta
> Commons/lang/src/test/org/apache/commons/lang/ArrayUtilsTest.java
> 
> 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 java.io.File for example.
> 
> Gary
> 
> -----Original Message-----
> From: Phil Steitz [mailto:steitzp@yahoo.com] 
> Sent: Wednesday, May 14, 2003 2:10 PM
> To: commons-dev@jakarta.apache.org
> 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.
> http://search.yahoo.com
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
> 


__________________________________
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo.
http://search.yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message