src/test/java/org/embulk/decoder/TestArchiveInputStreamIterator.java in embulk-decoder-commons-compress-0.3.3 vs src/test/java/org/embulk/decoder/TestArchiveInputStreamIterator.java in embulk-decoder-commons-compress-0.4.0
- old
+ new
@@ -69,9 +69,24 @@
assertFalse("Verify there is no next item.", it.hasNext());
assertNull("Verify there is no stream.", it.next());
}
@Test
+ public void testHasNextForNameMatch(@Mocked final ArchiveInputStream ain, @Mocked final ArchiveEntry entry) throws Exception {
+ new NonStrictExpectations() {{
+ ain.getNextEntry(); result = entry; result = entry; result = entry; result = null;
+ entry.getName(); result = "first.csv"; result = "second.txt"; result = "third.csv";
+ }};
+ ArchiveInputStreamIterator it = new ArchiveInputStreamIterator(ain, ".*\\.csv");
+ assertTrue("Verify 1st file match", it.hasNext());
+ assertEquals("Verify ArchiveInputStream is return.", (InputStream)ain, it.next());
+ assertTrue("Verify 3rd file match", it.hasNext());
+ assertEquals("Verify ArchiveInputStream is return.", (InputStream)ain, it.next());
+ assertFalse("Veryfy no more entry because second.txt is skipped.", it.hasNext());
+ assertNull("Verify there is no stream.", it.next());
+ }
+
+ @Test
public void testArchiveFile() throws Exception {
InputStream in = getClass().getResourceAsStream("samples.tar");
ArchiveInputStream ain = new ArchiveStreamFactory().createArchiveInputStream(in);
ArchiveInputStreamIterator it = new ArchiveInputStreamIterator(ain);
assertTrue("Verify there is 1st item.", it.hasNext());