Mockeryを使ってjavaでFileオブジェクトをモックできるようにしたい。私は、javaのFileのインターフェースを作成できないようです。これは可能ですか?Mockery、ファイルシステムオブジェクトを模倣する
EDIT:
私はインデクサークラスにindexDoc機能をテストする必要があります。インデクサクラス
private static void indexDocs(File file) throws Exception{
//Check for file to be a directory or file to be indexed look for html files and add to document
if(file.isDirectory()){
String[] files = file.list();
Arrays.sort(files);
for (int i = 0; i < files.length; i++) // recursively index them
indexDocs(new File(file, files[i]));
} else if(file.getPath().endsWith(".html") || file.getPath().endsWith("htm")){
// Get the document from HTMLDocument class which takes care of stripping of HTML tag, get the path
// of HTML file and title of HTML document.
Document doc = HTMLDocument.Document(file);
// TODO Get the book of HTML, it can be a part of HTML document class.
writer.addDocument(doc);
}
}
私は質問を編集しました。あなたは私の懸念を少しは良く理解しています。 – remo