### Question:
ClassFileIterator implements ResourceIterator { public final InputStream next() { if (index >= files.size()) return null; File fp = (File) files.get(index++); try { return new FileInputStream(fp); } catch (FileNotFoundException e) { throw new ResourceReadingException("Couldn't read file " + fp, e); } } ClassFileIterator(File file, Filter filter);  ClassFileIterator(File fileToAdd); final InputStream next(); void close();  }### Answer:
@Test public void testIterateWithFilter() { file = new File("."); iterator = new ClassFileIterator(file, filter); Assert.assertEquals(iterator.next().getClass(),FileInputStream.class); Assert.assertNotNull(iterator.next()); }
@Test public void testIterateWithoutFilter() { try { file = new File("."); iterator = new ClassFileIterator(file); Assert.assertEquals(iterator.next().getClass(),FileInputStream.class); Assert.assertNotNull(iterator.next()); } catch (ResourceReadingException e) { Assert.assertEquals("Couldn't read file .",e.getMessage()); } }
@Test public void testNoClassIterate() { try { file = new File("/com/impetus/kundera/"); iterator = new ClassFileIterator(file); } catch (ResourceReadingException e) { Assert.assertNull(iterator.next()); Assert.assertEquals("Couldn't read file /com/impetus/kundera",e.getMessage()); } }