1 25 package org.archive.io.arc; 26 27 import java.io.File ; 28 import java.io.IOException ; 29 import java.net.MalformedURLException ; 30 import java.net.URL ; 31 import java.util.Iterator ; 32 33 import org.archive.util.TmpDirTestCase; 34 35 public class ARCReaderFactoryTest extends TmpDirTestCase { 36 54 61 public void testGetFileURL() throws MalformedURLException , IOException { 62 File arc = ARCWriterTest.createARCFile(getTmpDir(), true); 63 doGetFileUrl(arc); 64 } 65 66 protected void doGetFileUrl(File arc) 67 throws MalformedURLException , IOException { 68 ARCReader reader = null; 69 File tmpFile = null; 70 try { 71 reader = ARCReaderFactory. 72 get(new URL ("file:////" + arc.getAbsolutePath())); 73 tmpFile = null; 74 for (Iterator i = reader.iterator(); i.hasNext();) { 75 ARCRecord r = (ARCRecord)i.next(); 76 if (tmpFile == null) { 77 tmpFile = new File (r.getMetaData().getArc()); 78 } 79 } 80 assertTrue(tmpFile.exists()); 81 } finally { 82 if (reader != null) { 83 reader.close(); 84 } 85 } 86 assertTrue(tmpFile.exists()); 87 } 88 89 94 public void testGetPathOrURL() throws MalformedURLException , IOException { 95 File arc = ARCWriterTest.createARCFile(getTmpDir(), true); 96 ARCReader reader = ARCReaderFactory.get(arc.getAbsoluteFile()); 97 assertNotNull(reader); 98 reader.close(); 99 doGetFileUrl(arc); 100 } 101 } 102 | Popular Tags |