@Test(expectedExceptions = SystemException.class) public void testIndexFileShouldThrowExceptionWhenFileNotFound() throws IOException { given(fileInputStreamFactory.createFileInputStream(file)).willThrow(new FileNotFoundException()); underTest.indexFile(file); }
public void indexFile(final File file) { FileInputStream fis = getInputStream(file); Document doc = documentFactory.createDocument(); Field pathField = new StringField(fieldName, file.getAbsolutePath(), Field.Store.YES); doc.add(pathField); doc.add(new LongField("modified", file.lastModified(), Field.Store.NO)); BufferedReader bufferedReader; try { bufferedReader = bufferedReaderFactory.createReader(fis); doc.add(new Field("contents", bufferedReader, TextField.TYPE_NOT_STORED)); addDocument(file, doc); fis.close(); } catch (IOException e) { logger.error(" caught a " + e.getClass() + "\n with message: " + e.getMessage()); } }
FileIndexer { public void indexFile(final File file) { FileInputStream fis = getInputStream(file); Document doc = documentFactory.createDocument(); Field pathField = new StringField(fieldName, file.getAbsolutePath(), Field.Store.YES); doc.add(pathField); doc.add(new LongField("modified", file.lastModified(), Field.Store.NO)); BufferedReader bufferedReader; try { bufferedReader = bufferedReaderFactory.createReader(fis); doc.add(new Field("contents", bufferedReader, TextField.TYPE_NOT_STORED)); addDocument(file, doc); fis.close(); } catch (IOException e) { logger.error(" caught a " + e.getClass() + "\n with message: " + e.getMessage()); } } }
FileIndexer { public void indexFile(final File file) { FileInputStream fis = getInputStream(file); Document doc = documentFactory.createDocument(); Field pathField = new StringField(fieldName, file.getAbsolutePath(), Field.Store.YES); doc.add(pathField); doc.add(new LongField("modified", file.lastModified(), Field.Store.NO)); BufferedReader bufferedReader; try { bufferedReader = bufferedReaderFactory.createReader(fis); doc.add(new Field("contents", bufferedReader, TextField.TYPE_NOT_STORED)); addDocument(file, doc); fis.close(); } catch (IOException e) { logger.error(" caught a " + e.getClass() + "\n with message: " + e.getMessage()); } }  }
FileIndexer { public void indexFile(final File file) { FileInputStream fis = getInputStream(file); Document doc = documentFactory.createDocument(); Field pathField = new StringField(fieldName, file.getAbsolutePath(), Field.Store.YES); doc.add(pathField); doc.add(new LongField("modified", file.lastModified(), Field.Store.NO)); BufferedReader bufferedReader; try { bufferedReader = bufferedReaderFactory.createReader(fis); doc.add(new Field("contents", bufferedReader, TextField.TYPE_NOT_STORED)); addDocument(file, doc); fis.close(); } catch (IOException e) { logger.error(" caught a " + e.getClass() + "\n with message: " + e.getMessage()); } }  void indexFile(final File file); }
FileIndexer { public void indexFile(final File file) { FileInputStream fis = getInputStream(file); Document doc = documentFactory.createDocument(); Field pathField = new StringField(fieldName, file.getAbsolutePath(), Field.Store.YES); doc.add(pathField); doc.add(new LongField("modified", file.lastModified(), Field.Store.NO)); BufferedReader bufferedReader; try { bufferedReader = bufferedReaderFactory.createReader(fis); doc.add(new Field("contents", bufferedReader, TextField.TYPE_NOT_STORED)); addDocument(file, doc); fis.close(); } catch (IOException e) { logger.error(" caught a " + e.getClass() + "\n with message: " + e.getMessage()); } }  void indexFile(final File file);  }