From a1a91e18ca49040c09e988a5010810d0833195dd Mon Sep 17 00:00:00 2001 From: Dennis Schafroth Date: Mon, 9 Jan 2012 17:22:46 +0100 Subject: [PATCH] New gzip test --- src/org/marc4j/test/GzipRecordTest.java | 45 +++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 src/org/marc4j/test/GzipRecordTest.java 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()); + } +} -- 1.7.10.4