From 40cf2dabd310bdd9c01eeccba7357689a8bb1936 Mon Sep 17 00:00:00 2001 From: Dennis Schafroth Date: Wed, 1 Feb 2012 16:38:28 +0100 Subject: [PATCH] Add test data. Move to resources/ --- src/org/marc4j/test/WriterTest.java | 393 +++++++++++++++++++++++++++++++++++ 1 file changed, 393 insertions(+) diff --git a/src/org/marc4j/test/WriterTest.java b/src/org/marc4j/test/WriterTest.java index 2e0760a..7707fc2 100644 --- a/src/org/marc4j/test/WriterTest.java +++ b/src/org/marc4j/test/WriterTest.java @@ -2,7 +2,13 @@ package org.marc4j.test; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FileOutputStream; import java.io.InputStream; +import java.io.StringReader; + +import javax.xml.transform.stream.StreamResult; +import javax.xml.transform.stream.StreamSource; import junit.framework.Test; import junit.framework.TestCase; @@ -19,6 +25,8 @@ import org.marc4j.marc.Record; public class WriterTest extends TestCase { + + public void testMarcStreamWriter() throws Exception { InputStream input = getClass().getResourceAsStream( "resources/summerland.xml"); @@ -57,7 +65,55 @@ public class WriterTest extends TestCase { input.close(); writer.close(); } + + public void testTurboMarcXmlWriterAutoGraphics() throws Exception { + InputStream input = getClass().getResourceAsStream( + "resources/auto-graphics.mrc"); + MarcWriter writer = new TurboMarcXmlWriter(new FileOutputStream( new File("auto-graphics.txml")), true); + MarcStreamReader reader = new MarcStreamReader(input); + int index = 0; + while (reader.hasNext()) { + Record record = reader.next(); + writer.write(record); + index++; + } + System.out.println("Number of records: " + index); + input.close(); + writer.close(); + } + + public void testMarcXmlWriterAutoGraphics() throws Exception { + InputStream input = getClass().getResourceAsStream( + "resources/auto-graphics.mrc"); + MarcWriter writer = new MarcXmlWriter(new FileOutputStream( new File("auto-graphics.txml")), true); + MarcStreamReader reader = new MarcStreamReader(input); + int index = 0; + while (reader.hasNext()) { + Record record = reader.next(); + writer.write(record); + index++; + } + System.out.println("Number of records: " + index); + input.close(); + writer.close(); + } + + public void testTurboMarcXmlWriter2pz() throws Exception { + InputStream input = getClass().getResourceAsStream( + "resources/summerland.mrc"); + StreamResult result = new StreamResult(System.out); + MarcWriter writer = new MarcXmlWriter(result, new StreamSource(new StringReader(tmarc2pz))); + + MarcStreamReader reader = new MarcStreamReader(input); + while (reader.hasNext()) { + Record record = reader.next(); + writer.write(record); + } + input.close(); + writer.close(); + } + public void testWriteAndRead() throws Exception { InputStream input = getClass().getResourceAsStream( "resources/summerland.xml"); @@ -91,4 +147,341 @@ public class WriterTest extends TestCase { public static void main(String args[]) { TestRunner.run(suite()); } + + + String tmarc2pz + = "\r\n" + + "\r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + "\r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " electronic resource\r\n" + + " \r\n" + + " \r\n" + + " electronic resource\r\n" + + " \r\n" + + " \r\n" + + " article\r\n" + + " \r\n" + + " \r\n" + + " book\r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + "\r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + "\r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + "\r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + "\r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + "\r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + "\r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + "\r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + "\r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + "\r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + "\r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + "\r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + "\r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + "\r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + "\r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + "\r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + "\r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " 1\">\r\n" + + " , \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + "\r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + "\r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + "\r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + "\r\n" + + " \r\n" + + "\r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + "\r\n" + + " \r\n" + + "\r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + "\r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " 1\">\r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + "\r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " 1\">\r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + "\r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " 1\">\r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + "\r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + "\r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + "\r\n" + + " \r\n" + + " \r\n" + + "\r\n" + + " \r\n" + + " \r\n" + + "\r\n" + + ""; + + } -- 1.7.10.4