Skip to content

Commit cd45199

Browse files
committed
Changes test because behaviour is different now
1 parent 93c15b3 commit cd45199

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

epub4j-core/src/main/java/io/documentnode/epub4j/epub/ResourcesLoader.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,7 @@ public static Resources loadResources(ZipInputStream zipInputStream,
128128
private static LocalFileHeader getNextZipEntry(ZipInputStream zipInputStream)
129129
throws IOException {
130130
try {
131-
LocalFileHeader nextEntry = zipInputStream.getNextEntry();
132-
return nextEntry;
131+
return zipInputStream.getNextEntry();
133132
} catch (IOException e) {
134133
//see <a href="https://github.com/psiegman/epublib/issues/122">Issue #122 Infinite loop</a>.
135134
//when reading a file that is not a real zip archive or a zero length file, zipInputStream.getNextEntry()

epub4j-core/src/test/java/io/documentnode/epub4j/epub/ResourcesLoaderTest.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import java.util.List;
1414

1515
import net.lingala.zip4j.ZipFile;
16+
import net.lingala.zip4j.exception.ZipException;
1617
import net.lingala.zip4j.io.inputstream.ZipInputStream;
1718
import org.junit.AfterClass;
1819
import org.junit.Assert;
@@ -63,7 +64,7 @@ public void testLoadResources_ZipInputStream() throws IOException {
6364
* Loads the Resources from a zero length file, using ZipInputStream<br/>
6465
* See <a href="https://github.com/psiegman/epublib/issues/122">Issue #122 Infinite loop</a>.
6566
*/
66-
@Test(expected = IOException.class)
67+
@Test(expected = ZipException.class)
6768
public void testLoadResources_ZipInputStream_WithZeroLengthFile()
6869
throws IOException {
6970
// given
@@ -78,7 +79,7 @@ public void testLoadResources_ZipInputStream_WithZeroLengthFile()
7879
* Loads the Resources from a file that is not a valid zip, using ZipInputStream<br/>
7980
* See <a href="https://github.com/psiegman/epublib/issues/122">Issue #122 Infinite loop</a>.
8081
*/
81-
@Test(expected = IOException.class)
82+
@Test
8283
public void testLoadResources_ZipInputStream_WithInvalidFile()
8384
throws IOException {
8485
// given
@@ -87,7 +88,9 @@ public void testLoadResources_ZipInputStream_WithInvalidFile()
8788

8889
// when
8990
Resources resources = ResourcesLoader.loadResources(zipInputStream, encoding);
90-
resources.getAll().forEach(System.out::println);
91+
92+
// then
93+
Assert.assertEquals(0, resources.getAll().size());
9194
}
9295

9396
/**
@@ -146,7 +149,7 @@ public void testLoadResources_ZipFile_partial_lazy() throws IOException {
146149
Assert
147150
.assertEquals(Resource.class, resources.getById("chapter1").getClass());
148151
}
149-
152+
150153
private void verifyResources(Resources resources) throws IOException {
151154
Assert.assertNotNull(resources);
152155
Assert.assertEquals(12, resources.getAll().size());

0 commit comments

Comments
 (0)