3e0c190373e98aa1bd9351163e38c95fac6fe05f
[marc4j.git] / src / org / marc4j / test / GzipRecordTest.java
1 package org.marc4j.test;\r
2 \r
3 import java.io.InputStream;\r
4 import java.util.zip.GZIPInputStream;\r
5 \r
6 import junit.framework.Test;\r
7 import junit.framework.TestCase;\r
8 import junit.framework.TestSuite;\r
9 import junit.textui.TestRunner;\r
10 \r
11 import org.marc4j.MarcReader;\r
12 import org.marc4j.MarcStreamReader;\r
13 import org.marc4j.marc.Record;\r
14 \r
15 public class GzipRecordTest extends TestCase {\r
16 \r
17     Record record = null;\r
18 \r
19     public void testGzipRecordRead() throws Exception {\r
20         InputStream input = getClass().getResourceAsStream(\r
21                 "resources/oais.26.mrc.gz");\r
22         assertTrue("No test data", input != null);\r
23         GZIPInputStream gzipped = new GZIPInputStream(input);\r
24         MarcReader reader = new MarcStreamReader(gzipped, "MARC-8");\r
25         int index = 0;\r
26         while (reader.hasNext()) {\r
27             record = reader.next();\r
28             ++index;\r
29         }\r
30         assertTrue("Number of records was not correct: " +  index, index == 60221); \r
31         input.close();\r
32     }\r
33 \r
34     public void tearDown() {\r
35         record = null;\r
36     }\r
37 \r
38     public static Test suite() {\r
39         return new TestSuite(GzipRecordTest.class);\r
40     }\r
41 \r
42     public static void main(String args[]) {\r
43         TestRunner.run(suite());\r
44     }\r
45 }\r