diff --git a/lib/src/test/org/kiwix/test/libzim/TestArchive.java b/lib/src/test/org/kiwix/test/libzim/TestArchive.java index 3bd447f..9f3006f 100644 --- a/lib/src/test/org/kiwix/test/libzim/TestArchive.java +++ b/lib/src/test/org/kiwix/test/libzim/TestArchive.java @@ -20,7 +20,6 @@ package org.kiwix.test.libzim; import org.kiwix.libzim.ZimFileFormatException; -import org.kiwix.libzim.Item; import org.kiwix.libzim.EntryIterator; import org.kiwix.libzim.Archive; import java.io.FileDescriptor; @@ -54,10 +53,10 @@ public class TestArchive public int getMediaCount() { return inner.getMediaCount(); } public String getUuid() { return inner.getUuid(); } public String getMetadata(String name) { return inner.getMetadata(name); } - public Item getMetadataItem(String name) { return inner.getMetadataItem(name); } + public TestItem getMetadataItem(String name) { return new TestItem(inner.getMetadataItem(name)); } public String[] getMetadataKeys() { return inner.getMetadataKeys(); } - public Item getIllustrationItem(int size) { return inner.getIllustrationItem(size); } + public TestItem getIllustrationItem(int size) { return new TestItem(inner.getIllustrationItem(size)); } public boolean hasIllustration(int size) { return inner.hasIllustration(size); } public long[] getIllustrationSizes() { return inner.getIllustrationSizes(); } diff --git a/lib/src/test/org/kiwix/test/libzim/TestEntry.java b/lib/src/test/org/kiwix/test/libzim/TestEntry.java index 188f92d..559f8c4 100644 --- a/lib/src/test/org/kiwix/test/libzim/TestEntry.java +++ b/lib/src/test/org/kiwix/test/libzim/TestEntry.java @@ -20,7 +20,6 @@ package org.kiwix.test.libzim; import org.kiwix.libzim.Entry; -import org.kiwix.libzim.Item; public class TestEntry { @@ -30,7 +29,7 @@ public class TestEntry public String getTitle() { return inner.getTitle(); } public String getPath() { return inner.getPath(); } - public Item getItem(boolean follow) { return inner.getItem(follow); } - public Item getRedirect() { return inner.getRedirect(); } + public TestItem getItem(boolean follow) { return new TestItem(inner.getItem(follow)); } + public TestItem getRedirect() { return new TestItem(inner.getRedirect()); } public TestEntry getRedirectEntry() { return new TestEntry(inner.getRedirectEntry()); } } diff --git a/lib/src/test/org/kiwix/test/libzim/TestItem.java b/lib/src/test/org/kiwix/test/libzim/TestItem.java new file mode 100644 index 0000000..6928651 --- /dev/null +++ b/lib/src/test/org/kiwix/test/libzim/TestItem.java @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2022 Matthieu Gautier + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ + +package org.kiwix.test.libzim; + +import org.kiwix.libzim.Item; +import org.kiwix.libzim.Blob; +import org.kiwix.libzim.DirectAccessInfo; + +public class TestItem +{ + private Item inner; + public TestItem(Item _inner) { inner = _inner; } + public String getTitle() { return inner.getTitle(); } + public String getPath() { return inner.getPath(); } + public String getMimetype() { return inner.getMimetype(); } + + public Blob getData() { return inner.getData(); } + public long getSize() { return inner.getSize(); } + + public DirectAccessInfo getDirectAccessInformation() { return inner.getDirectAccessInformation(); } +} diff --git a/lib/src/test/test.java b/lib/src/test/test.java index 8602aa2..22d6325 100644 --- a/lib/src/test/test.java +++ b/lib/src/test/test.java @@ -61,7 +61,7 @@ public class test { // test zim file icon assertEquals(true, archive.hasIllustration(48)); byte[] faviconData = getFileContent("small_zimfile_data/favicon.png"); - Item item = archive.getIllustrationItem(48); + TestItem item = archive.getIllustrationItem(48); assertEquals(faviconData.length, item.getSize()); assert(Arrays.equals(faviconData, item.getData().getData()));