Package org.archive.io.warc

Examples of org.archive.io.warc.TestWARCReader


        result.setCaptureTimestamp("20100101123456");
    }
   
    public static Resource createTestHtmlResource(byte[] payloadBytes) throws IOException {
        WARCRecordInfo recinfo = TestWARCRecordInfo.createCompressedHttpResponse("text/html", payloadBytes);
        TestWARCReader ar = new TestWARCReader(recinfo);
        WARCRecord rec = ar.get(0);
        WarcResource resource = new WarcResource(rec, ar);
        resource.parseHeaders();
        return resource;
    }
View Full Code Here


    super.setUp();
  }
 
  public static Resource createTestJSResource(byte[] payloadBytes) throws IOException {
    WARCRecordInfo recinfo = TestWARCRecordInfo.createHttpResponse("text/javascript", payloadBytes);
    TestWARCReader ar = new TestWARCReader(recinfo);
    WARCRecord rec = ar.get(0);
    WarcResource resource = new WarcResource(rec, ar);
    resource.parseHeaders();
    return resource;
  }
View Full Code Here

        result.setOriginalUrl("http://www.example.com/");
    }
   
    public static Resource createTestHtmlResource(byte[] payloadBytes) throws IOException {
        WARCRecordInfo recinfo = TestWARCRecordInfo.createCompressedHttpResponse("text/html", payloadBytes);
        TestWARCReader ar = new TestWARCReader(recinfo);
        WARCRecord rec = ar.get(0);
        WarcResource resource = new WarcResource(rec, ar);
        resource.parseHeaders();
        return resource;
    }
View Full Code Here

        return resource;
    }
    public static Resource createTestRevisitResource(byte[] payloadBytes, boolean withHeader, boolean gzipContent) throws IOException {
        WARCRecordInfo recinfo = TestWARCRecordInfo.createRevisitHttpResponse(
                "text/html", payloadBytes.length, withHeader, gzipContent);
        TestWARCReader ar = new TestWARCReader(recinfo);
        WARCRecord rec = ar.get(0);
        WarcResource resource = new WarcResource(rec, ar);
        resource.parseHeaders();
        return resource;
    }
View Full Code Here

        String payload = "hogehogehogehogehoge";
        String ctype = "text/plain";
        WARCRecordInfo recinfo = new TestWARCRecordInfo(
                TestWARCRecordInfo.buildCompressedHttpResponseBlock(ctype,
                        payload.getBytes()));
        TestWARCReader ar = new TestWARCReader(recinfo);
        WARCRecord rec = ar.get(0);
        WarcResource res = new WarcResource(rec, ar);
        res.parseHeaders();
       
        assertEquals("statusCode", 200, res.getStatusCode());
        assertEquals("content-type", ctype, res.getHeader("Content-Type"));
View Full Code Here

        String payload = "hogehogehogehogehoge";
        String ctype = "text/plain";
        WARCRecordInfo recinfo = new TestWARCRecordInfo(
                TestWARCRecordInfo.buildCompressedHttpResponseBlock(ctype,
                        payload.getBytes(), true));
        TestWARCReader ar = new TestWARCReader(recinfo);
        WARCRecord rec = ar.get(0);
        WarcResource res = new WarcResource(rec, ar);
        res.parseHeaders();
       
        assertEquals("statusCode", 200, res.getStatusCode());
        assertEquals("content-type", ctype, res.getHeader("Content-Type"));
View Full Code Here

        };
        final String ct = "image/gif";
        WARCRecordInfo recinfo = new TestWARCRecordInfo(block);
        recinfo.setType(WARCRecordType.metadata);
        recinfo.setMimetype(ct);
        TestWARCReader ar = new TestWARCReader(recinfo);
        WARCRecord rec = ar.get(0);
        WarcResource res = new WarcResource(rec, ar);
        // must not fail
        res.parseHeaders();
       
        // should return assumed 200
View Full Code Here

     * @throws Exception
     */
    public void testRevisitRecord() throws Exception {
        final String ct = "text/html";
        WARCRecordInfo recinfo = TestWARCRecordInfo.createRevisitHttpResponse(ct, 1345);
        TestWARCReader ar = new TestWARCReader(recinfo);
        WARCRecord rec = ar.get(0);
        WarcResource res = new WarcResource(rec, ar);
        res.parseHeaders();
       
        // these are from this record.
        assertEquals("statusCode", 200, res.getStatusCode());
View Full Code Here

     * @see StandardCharsetDetector#getCharset(org.archive.wayback.core.Resource, org.archive.wayback.core.Resource, org.archive.wayback.core.WaybackRequest)
     */
    public void testOldRevisitRecord() throws Exception {
        final String ct = "text/html";
        WARCRecordInfo recinfo = TestWARCRecordInfo.createRevisitHttpResponse(ct, 1345, false);
        TestWARCReader ar = new TestWARCReader(recinfo);
        WARCRecord rec = ar.get(0);
        WarcResource res = new WarcResource(rec, ar);
        res.parseHeaders();
       
        // should either return special value or throw appropriate exception (TBD)
        int scode = res.getStatusCode();
View Full Code Here

        final byte[] block = "blahblahblah\n".getBytes();
        WARCRecordInfo recinfo = new TestWARCRecordInfo(block);
        recinfo.setType(WARCRecordType.resource);
        recinfo.setUrl("ftp://ftp.example.com/afile.txt");
        recinfo.setMimetype(ct);
        ArchiveReader ar = new TestWARCReader(recinfo);
        WARCRecord rec = (WARCRecord)ar.get(0);
        WarcResource res = new WarcResource(rec, ar);
        res.parseHeaders();
               
        int scode = res.getStatusCode();
        assertEquals("statusCode", 200, scode);
View Full Code Here

TOP

Related Classes of org.archive.io.warc.TestWARCReader

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.