Package org.archive.io.warc

Examples of org.archive.io.warc.WARCRecord


     */
    public void testPlainHttpRecord() throws Exception {
        String payload = "hogehogehogehogehoge";
        WARCRecordInfo recinfo = TestWARCRecordInfo.createHttpResponse(payload);
        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", "text/plain", res.getHeader("Content-Type"));
View Full Code Here


        String payload = "hogehogehogehogehoge";
        WARCRecordInfo recinfo = new TestWARCRecordInfo(
                TestWARCRecordInfo.buildHttpResponseBlock("200 OK",
                        "text/plain", payload.getBytes("UTF-8"), 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", "text/plain", res.getHeader("Content-Type"));
View Full Code Here

        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 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

     */
    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

     */
    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

        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

  public static Resource createTestTextResource(String ctype, byte[] payloadBytes)
      throws IOException {
    WARCRecordInfo recinfo = TestWARCRecordInfo.createHttpResponse(ctype,
      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

    /* (non-Javadoc)
     * @see org.archive.wayback.util.Adapter#adapt(java.lang.Object)
     */
                @Override
    public WARCRecord adapt(ArchiveRecord o) {
      WARCRecord rec = null;
      if (o instanceof WARCRecord) {
        rec = (WARCRecord) o;
      }
      return rec;
    }
View Full Code Here

TOP

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

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.