WorldFireReaderPlugIn implements ProductReaderPlugIn { @Override public DecodeQualification getDecodeQualification(Object input) { File inputFile = new File(String.valueOf(input)); if(!inputFile.getName().toUpperCase().endsWith(FIRE_FILE_EXTENSION)) { return DecodeQualification.UNABLE; } InputStream inputStream = null; try { inputStream = new FileInputStream(inputFile); return getDecodeQualification(inputStream); } catch (IOException ignored) { return DecodeQualification.UNABLE; }finally { if(inputStream != null) { try { inputStream.close(); } catch (IOException ignored) {} } } }  @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 testDecodeQualificationFile() throws Exception { File input; input = TestResourceHelper.getAatsrAlgo1AsFile(); assertEquals(DecodeQualification.INTENDED, plugIn.getDecodeQualification(input)); input = TestResourceHelper.getAatsrAlgo2AsFile(); assertEquals(DecodeQualification.INTENDED, plugIn.getDecodeQualification(input)); input = TestResourceHelper.getAtsr2Algo1AsFile(); assertEquals(DecodeQualification.INTENDED, plugIn.getDecodeQualification(input)); input = TestResourceHelper.getAtsr2Algo2AsFile(); assertEquals(DecodeQualification.INTENDED, plugIn.getDecodeQualification(input)); input = new File("9708ESA02.notAFile"); assertEquals(DecodeQualification.UNABLE, plugIn.getDecodeQualification(input)); input = File.createTempFile("emptyFile", ".FIRE"); assertEquals(DecodeQualification.UNABLE, plugIn.getDecodeQualification(input)); }
@Test public void testDecodeQualificationString() throws IOException { String input; input = TestResourceHelper.getAatsrAlgo1AsString(); assertEquals(DecodeQualification.INTENDED, plugIn.getDecodeQualification(input)); input = TestResourceHelper.getAatsrAlgo2AsString(); assertEquals(DecodeQualification.INTENDED, plugIn.getDecodeQualification(input)); input = TestResourceHelper.getAtsr2Algo1AsString(); assertEquals(DecodeQualification.INTENDED, plugIn.getDecodeQualification(input)); input = TestResourceHelper.getAtsr2Algo2AsString(); assertEquals(DecodeQualification.INTENDED, plugIn.getDecodeQualification(input)); assertEquals(DecodeQualification.UNABLE, plugIn.getDecodeQualification(null)); assertEquals(DecodeQualification.UNABLE, plugIn.getDecodeQualification("notAValidPath")); }