Am using jdk1.6 and want to find an easy way, from within a JUnittest, to locate files in my project of a specific type
I want my test to find all files that end with "hbm.xml" and once i have a list of the files, to then
read their contents.
I can do the below individually for one file but I've to specify it's path:
Check out File.listFiles(FileFilter) or File.listFiles(FilenameFilter). The former is probably better because that one allows you to list folders as well, so you can check the folder recursively. In code, with a few gaps:
Hi, am using hibernate in my application and want to, as part of a JUnit test, execute all named queries that i've defined. In hibernate, named queries are defined in files
ending in "hbm.xml" so I want to find all files in my application with this file ending then I'm going to use the java Matcher and Pattern classes to
find, in each "hbm.xml" file the name of the query. The i'm going to execute each query. I tried to see if there was a way in hibernate to get all named queries which you've
defined but there doesn't appear to be. Hence me going the java route of finding the file and parsing the contents..
I'm not sure if that makes any sense to me: it doesn't test that the named queries you actually *need* are there, that would have to be done on a query-by-query basis, by code that knows (a) what the query is named, and (b) what the query is supposed to return.
I'm just not really sure what you're testing doing what you want to do is all.