EnviProductReaderPlugIn implements ProductReaderPlugIn { @Override public DecodeQualification getDecodeQualification(Object input) { if (input instanceof ImageInputStream) { return checkDecodeQualificationOnStream((ImageInputStream) input); } else if(input != null){ return checkDecodeQualificationOnFile(new File(input.toString())); } return DecodeQualification.UNABLE; }  @Override DecodeQualification getDecodeQualification(Object input); @Override String[] getFormatNames(); @Override ProductReader createReaderInstance(); @Override String[] getDefaultFileExtensions(); @Override Class[] getInputTypes(); @Override String getDescription(Locale locale); @Override BeamFileFilter getProductFileFilter();  }
@Test public void testDecodeQualfication_wrongObject() { assertEquals(DecodeQualification.UNABLE, readerPlugIn.getDecodeQualification(new Double(23.8))); }
@Test public void testDecodeQualfication_Stream_success() { final String line = EnviConstants.FIRST_LINE + "dklfj\n234j\nsdf\tsdf\tsdaf\n"; final ByteArrayInputStream bais = new ByteArrayInputStream(line.getBytes()); final ImageInputStream stReader = new MemoryCacheImageInputStream(bais); assertEquals(DecodeQualification.SUITABLE, readerPlugIn.getDecodeQualification(stReader)); }
@Test public void testDecodeQualfication_Stream_fail_invalid() { final String lines = "This is no success!"; final ByteArrayInputStream bais = new ByteArrayInputStream(lines.getBytes()); final ImageInputStream stReader = new MemoryCacheImageInputStream(bais); assertEquals(DecodeQualification.UNABLE, readerPlugIn.getDecodeQualification(stReader)); }
@Test public void testDecodeQualification_File_success() throws IOException { final String line = EnviConstants.FIRST_LINE + "dklfj\n234j\nsdf\tsdf\tsdaf\n"; writeToTestFile(line); assertEquals(DecodeQualification.SUITABLE, readerPlugIn.getDecodeQualification(headerFile)); }
@Test public void testDecodeQualification_File_failure() throws IOException { writeToTestFile("blaberrhabarber"); assertEquals(DecodeQualification.UNABLE, readerPlugIn.getDecodeQualification(headerFile)); }
@Test public void testDecodeQualification_String_success() throws IOException { final String line = EnviConstants.FIRST_LINE + "dklfj\n234j\nsdf\tsdf\tsdaf\n"; writeToTestFile(line); assertEquals(DecodeQualification.SUITABLE, readerPlugIn.getDecodeQualification(headerFile.getName())); }
@Test public void testDecodeQualification_String_failure() throws IOException { writeToTestFile("blaberrhabarber"); assertEquals(DecodeQualification.UNABLE, readerPlugIn.getDecodeQualification(headerFile.getName())); }
@Test public void testDecodeQualification_ZipFile_success() throws IOException { final String line = EnviConstants.FIRST_LINE + "dklfj\n234j\nsdf\tsdf\tsdaf\n"; writeToZipTestFile(line, true); assertEquals(DecodeQualification.SUITABLE, readerPlugIn.getDecodeQualification(headerFile)); }
@Test public void testDecodeQualification_ZipFile_failure() throws IOException { writeToZipTestFile("blaberrhabarber", true); assertEquals(DecodeQualification.UNABLE, readerPlugIn.getDecodeQualification(headerFile)); }
@Test public void testDecodeQualification_ZipFile_failureNotEnoughEntries() throws IOException { final String line = EnviConstants.FIRST_LINE + "dklfj\n234j\nsdf\tsdf\tsdaf\n"; writeToZipTestFile(line, false); assertEquals(DecodeQualification.UNABLE, readerPlugIn.getDecodeQualification(headerFile)); }