1 23 package org.archive.io.warc; 24 25 import java.io.ByteArrayInputStream ; 26 import java.io.IOException ; 27 28 import junit.framework.TestCase; 29 30 public class WARCRecordTest extends TestCase { 31 public void testParseHeaderLine() throws IOException { 32 final String body = "GET /robots.txt HTTP/1.0"; 33 final String hdr = "WARC/0.9 000000000496 request " + 34 "http://foo.maths.uq.edu.au/robots.txt 20060825210905 " + 35 "uuri:dbf1ef20-db01-4cc6-ba93-6baf7a906356;type=request " + 36 "application/http; msgtype=request\r\n" + 37 "Related-Record-ID: uuri:dbf1ef20-db01-4cc6-ba93-6baf7a906356\r\n" + 38 "\r\n" + 39 body + 40 "\r\n\r\n"; 41 WARCRecord r = new WARCRecord(new ByteArrayInputStream (hdr.getBytes()), 42 "READER_IDENTIFIER", 0, false, true); 43 assertEquals(r.getHeader().getLength(), 496); 44 assertEquals(r.getHeader().getMimetype(), 45 "application/http; msgtype=request"); 46 assertEquals(r.getHeader().getRecordIdentifier(), 47 "uuri:dbf1ef20-db01-4cc6-ba93-6baf7a906356;type=request"); 48 byte [] b = new byte[body.length()]; 49 r.read(b); 50 String bodyRead = new String (b); 51 assertEquals(body, bodyRead); 52 } 53 } 54 | Popular Tags |