CsvProductReaderPlugIn implements ProductReaderPlugIn { @Override public DecodeQualification getDecodeQualification(Object input) { final File file = new File(input.toString()); if (!isFileExtensionValid(file)) { return DecodeQualification.UNABLE; } CsvSourceParser csvFile = null; try { csvFile = CsvFile.createCsvSourceParser(input.toString()); csvFile.parseMetadata(); csvFile.checkReadingFirstRecord(); } catch (Exception e) { return DecodeQualification.UNABLE; } finally { if (csvFile != null) { csvFile.close(); } } return DecodeQualification.SUITABLE; }  @Override DecodeQualification getDecodeQualification(Object input); @Override Class[] getInputTypes(); @Override ProductReader createReaderInstance(); @Override String[] getFormatNames(); @Override String[] getDefaultFileExtensions(); @Override String getDescription(Locale locale); @Override BeamFileFilter getProductFileFilter();  }
@Test public void testGetDecodeQualification() throws Exception { File validFile = new File(getClass().getResource("simple_format_example.txt").getFile()); File validFileWithoutProperties = new File(getClass().getResource("simple_format_no_properties.txt").getFile()); File invalidProperties = new File(getClass().getResource("simple_format_invalid_properties.txt").getFile()); File invalidHeader = new File(getClass().getResource("simple_format_no_header.txt").getFile()); File invalidType = new File(getClass().getResource("simple_format_invalid_type.txt").getFile()); assertEquals(DecodeQualification.SUITABLE, csvProductReaderPlugIn.getDecodeQualification(validFile)); assertEquals(DecodeQualification.SUITABLE, csvProductReaderPlugIn.getDecodeQualification(validFileWithoutProperties)); assertEquals(DecodeQualification.UNABLE, csvProductReaderPlugIn.getDecodeQualification(invalidProperties)); assertEquals(DecodeQualification.UNABLE, csvProductReaderPlugIn.getDecodeQualification(invalidHeader)); assertEquals(DecodeQualification.UNABLE, csvProductReaderPlugIn.getDecodeQualification(invalidType)); }