SpotVgtProductReaderPlugIn implements ProductReaderPlugIn { @Override public DecodeQualification getDecodeQualification(Object input) { File file = getFileInput(input); if (file == null) { return DecodeQualification.UNABLE; } VirtualDir virtualDir = VirtualDir.create(file); if (virtualDir == null) { return DecodeQualification.UNABLE; } try { try { Reader reader = virtualDir.getReader(SpotVgtConstants.PHYS_VOL_FILENAME); if (reader == null) { return DecodeQualification.UNABLE; } try { PhysVolDescriptor descriptor = new PhysVolDescriptor(reader); String[] strings = virtualDir.list(descriptor.getLogVolDirName()); if (strings.length == 0) { return DecodeQualification.UNABLE; } } finally { reader.close(); } return DecodeQualification.INTENDED; } catch (IOException e) { return DecodeQualification.UNABLE; } } finally { virtualDir.close(); } }  @Override DecodeQualification getDecodeQualification(Object input); @Override Class[] getInputTypes(); @Override ProductReader createReaderInstance(); @Override BeamFileFilter getProductFileFilter(); @Override String[] getDefaultFileExtensions(); @Override String getDescription(Locale locale); @Override String[] getFormatNames();  }
@Test public void testDecodeQualification() { SpotVgtProductReaderPlugIn plugIn = new SpotVgtProductReaderPlugIn(); assertEquals(DecodeQualification.UNABLE, plugIn.getDecodeQualification(null)); File dir = TestDataDir.get(); File file; file = new File(dir, "decode_qual_intended.zip"); assertEquals(DecodeQualification.INTENDED, plugIn.getDecodeQualification(file)); assertEquals(DecodeQualification.INTENDED, plugIn.getDecodeQualification(file.getPath())); file = new File(dir, "decode_qual_intended"); assertEquals(DecodeQualification.INTENDED, plugIn.getDecodeQualification(file)); assertEquals(DecodeQualification.INTENDED, plugIn.getDecodeQualification(file.getPath())); file = new File(dir, "decode_qual_intended/PHYS_VOL.TXT"); assertEquals(DecodeQualification.INTENDED, plugIn.getDecodeQualification(file)); assertEquals(DecodeQualification.INTENDED, plugIn.getDecodeQualification(file.getPath())); file = new File(dir, "decode_qual_unable_1"); assertEquals(DecodeQualification.UNABLE, plugIn.getDecodeQualification(file)); assertEquals(DecodeQualification.UNABLE, plugIn.getDecodeQualification(file.getPath())); file = new File(dir, "decode_qual_unable_1/PHYS_VOL.TXT"); assertEquals(DecodeQualification.UNABLE, plugIn.getDecodeQualification(file)); assertEquals(DecodeQualification.UNABLE, plugIn.getDecodeQualification(file.getPath())); file = new File(dir, "decode_qual_unable_2"); assertEquals(DecodeQualification.UNABLE, plugIn.getDecodeQualification(file)); assertEquals(DecodeQualification.UNABLE, plugIn.getDecodeQualification(file.getPath())); file = new File(dir, "decode_qual_unable_2/PHYS_VOL.TXT"); assertEquals(DecodeQualification.UNABLE, plugIn.getDecodeQualification(file)); assertEquals(DecodeQualification.UNABLE, plugIn.getDecodeQualification(file.getPath())); file = new File(dir, "decode_qual_unable_3"); assertEquals(DecodeQualification.UNABLE, plugIn.getDecodeQualification(file)); assertEquals(DecodeQualification.UNABLE, plugIn.getDecodeQualification(file.getPath())); file = new File(dir, "decode_qual_unable_3/TEST.TXT"); assertEquals(DecodeQualification.UNABLE, plugIn.getDecodeQualification(file)); assertEquals(DecodeQualification.UNABLE, plugIn.getDecodeQualification(file.getPath())); file = new File(dir, "decode_qual_unable_3/NON_EXISTENT"); assertEquals(DecodeQualification.UNABLE, plugIn.getDecodeQualification(file)); assertEquals(DecodeQualification.UNABLE, plugIn.getDecodeQualification(file.getPath())); }