Package org.archive.wayback.core

Examples of org.archive.wayback.core.Resource


  public void testMimeTypeFromIndex() throws Exception {
    WaybackRequest wbRequest = new WaybackRequest();
    CaptureSearchResult result = new CaptureSearchResult();
    result.setMimeType("text/javascript");
    Resource resource = createTestTextResource("text/javascript", "var i=1;".getBytes("UTF-8"));
    ReplayRenderer rr = cut.getRenderer(wbRequest, result, resource);

    assertEquals("js", ((TestReplayRenderer)rr).name);   
  }
View Full Code Here


  public void testMimeTypeForced() throws Exception {
    WaybackRequest wbRequest = new WaybackRequest();
    wbRequest.setJSContext(true);
    CaptureSearchResult result = new CaptureSearchResult();
    result.setMimeType("text/plain");
    Resource resource = createTestTextResource("text/plain", "a".getBytes("UTF-8"));
    ReplayRenderer rr = cut.getRenderer(wbRequest, result, resource);

    assertEquals("js", ((TestReplayRenderer)rr).name);
  }
View Full Code Here

    public void testHandleRequest_Replay_2() throws Exception {
        // make sure wbRequesat.requestUrl, replayTimestamp are set up.
        setReplayRequest(wbRequest, "http://test.example.com/", "20100601000000");
       
        // there's capture with timestamp exactly requested for.
        Resource payloadResource = createTestHtmlResource("20100601000000", "hogheogehoge\n".getBytes("UTF-8"));
        CaptureSearchResults results = setupCaptures(
                0,
                payloadResource
                );
        CaptureSearchResult closest = results.getClosest();
View Full Code Here

     */
    public void testHandleRequest_Replay_Revisit() throws Exception {
        setReplayRequest(wbRequest, "http://www.example.com/", "20100601000000");
        // closest SearchResult has isDuplicateDigest() == true.
        byte[] payload = "hogehogehogehoge\n".getBytes("UTF-8");
        Resource payloadResource = createTestHtmlResource("20100501000001", payload);
        Resource headerResource = createTestRevisitResource("20100601000000", payload.length, true);
        CaptureSearchResults results = setupCaptures(1, payloadResource, headerResource);

        CaptureSearchResult previous = results.getResults().get(0);
        CaptureSearchResult closest = results.getClosest();
//        previous.setFile("aaa.warc.gz");
View Full Code Here

        cut.getConfigs().setProperty(MementoUtils.AGGREGATION_PREFIX_CONFIG, AGGREGATION_PREFIX);
       
        // make sure wbRequesat.requestUrl, replayTimestamp are set up.
        setReplayRequest(wbRequest, "http://www.example.com/", "20100601000000");
        assertFalse(wbRequest.isMementoTimegate());
        Resource payloadResource = createTestHtmlResource("20100601000000", "hogehogehogehoge\n".getBytes("UTF-8"));
        CaptureSearchResults results = setupCaptures(
                0,
                payloadResource
                );
        CaptureSearchResult closest = results.getClosest();
View Full Code Here

        cut.setEnableMemento(true);
        // make sure wbRequesat.requestUrl, replayTimestamp are set up.
        setReplayRequest(wbRequest, "http://www.example.com/", "20100601123456");
        assertFalse(wbRequest.isMementoTimegate());
       
        Resource payloadResource = createTestHtmlResource("20100601000000", "hogehogehogehoge\n".getBytes("UTF-8"));
        CaptureSearchResults results = setupCaptures(0, payloadResource);
        // handleRequest()
        // calls handleReplay()
        // - calls checkInterstitialRedirect()
        // - calls selfRedirectCanonicalizer.urlStringToKey(requestURL) if non-null
View Full Code Here

        res.parseHeaders();
       
        assertEquals("statusCode", 200, res.getStatusCode());
        assertEquals("content-type", ctype, res.getHeader("Content-Type"));
       
        Resource zres = TextReplayRenderer.decodeResource(res);
        assertTrue("wrapped with GzipDecodingResource", (zres instanceof GzipDecodingResource));
       
        byte[] buf = new byte[payload.getBytes().length + 1];
        int n = zres.read(buf);
        assertEquals("content length", buf.length - 1, n);
       
        res.close();
    }
View Full Code Here

        res.parseHeaders();
       
        assertEquals("statusCode", 200, res.getStatusCode());
        assertEquals("content-type", ctype, res.getHeader("Content-Type"));
       
        Resource zres = TextReplayRenderer.decodeResource(res);
        assertTrue("wrapped with GzipDecodingResource", (zres instanceof GzipDecodingResource));
       
        byte[] buf = new byte[payload.getBytes().length + 1];
        int n = zres.read(buf);
        assertEquals("content length", buf.length - 1, n);
       
        res.close();
    }
View Full Code Here

          if(status == 200) {
            ARCRecord r =
              new ARCRecord(new GZIPInputStream(
                  method.getResponseBodyAsStream()),
                  "id",0L,false,false,true);
            Resource res = null;
            try {
          res = ResourceFactory.ARCArchiveRecordToResource(r, null);
        } catch (ResourceNotAvailableException e) {
          LOGGER.severe(e.getMessage());
          throw new IOException(e);
        }
            httpResponse.setStatus(res.getStatusCode());

            Map<String,String> headers = res.getHttpHeaders();
            Iterator<String> keys = headers.keySet().iterator();
            while(keys.hasNext()) {
              String key = keys.next();
              if(!key.equalsIgnoreCase("Connection")
                  && !key.equalsIgnoreCase("Content-Length")
View Full Code Here

      Resource payloadResource, ResultURIConverter uriConverter,
      CaptureSearchResults results) throws ServletException,
      IOException, BadContentException {

    // Decode resource (such as if gzip encoded)
    Resource decodedResource = decodeResource(httpHeadersResource, payloadResource);
   
    HttpHeaderOperation.copyHTTPMessageHeader(httpHeadersResource, httpResponse);

    Map<String,String> headers = HttpHeaderOperation.processHeaders(
        httpHeadersResource, result, uriConverter, httpHeaderProcessor);
View Full Code Here

TOP

Related Classes of org.archive.wayback.core.Resource

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.