From: Dennis Schafroth Date: Mon, 9 Jan 2012 16:22:46 +0000 (+0100) Subject: New gzip test X-Git-Tag: v2.5~23^2~12 X-Git-Url: http://sru.miketaylor.org.uk/cgi-bin?a=commitdiff_plain;h=a1a91e18ca49040c09e988a5010810d0833195dd;p=marc4j.git New gzip test --- diff --git a/src/org/marc4j/test/GzipRecordTest.java b/src/org/marc4j/test/GzipRecordTest.java new file mode 100644 index 0000000..3e0c190 --- /dev/null +++ b/src/org/marc4j/test/GzipRecordTest.java @@ -0,0 +1,45 @@ +package org.marc4j.test; + +import java.io.InputStream; +import java.util.zip.GZIPInputStream; + +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; +import junit.textui.TestRunner; + +import org.marc4j.MarcReader; +import org.marc4j.MarcStreamReader; +import org.marc4j.marc.Record; + +public class GzipRecordTest extends TestCase { + + Record record = null; + + public void testGzipRecordRead() throws Exception { + InputStream input = getClass().getResourceAsStream( + "resources/oais.26.mrc.gz"); + assertTrue("No test data", input != null); + GZIPInputStream gzipped = new GZIPInputStream(input); + MarcReader reader = new MarcStreamReader(gzipped, "MARC-8"); + int index = 0; + while (reader.hasNext()) { + record = reader.next(); + ++index; + } + assertTrue("Number of records was not correct: " + index, index == 60221); + input.close(); + } + + public void tearDown() { + record = null; + } + + public static Test suite() { + return new TestSuite(GzipRecordTest.class); + } + + public static void main(String args[]) { + TestRunner.run(suite()); + } +}