Package org.archive.wayback.core

Examples of org.archive.wayback.core.CaptureSearchResult


        Resource payloadResource = createTestHtmlResource("20100601000000", "hogehogehogehoge\n".getBytes("UTF-8"));
        CaptureSearchResults results = setupCaptures(
                0,
                payloadResource
                );
        CaptureSearchResult closest = results.getClosest();
       
        // when closest's timestamp == request's timestamp,
        // it gets ReplayRenderer with replay.getRenderer(wbRequest, closest, httpHeaderResource, payloadResource),
        // and calls renderResource() on it.
        EasyMock.expect(replay.getRenderer(wbRequest, closest, payloadResource, payloadResource)).andReturn(replayRenderer);
View Full Code Here


        // - calls queryIndex(), which calls collection.resourceIndex.query(),
        //     which returns CaptureSearchResults
        //   (unexpected object from queryIndex() results in WaybackException("Unknown index format").
        //    this is considered to be a programming/configuration error. not tested.)
        CaptureSearchResults results = new CaptureSearchResults();
        CaptureSearchResult result = new CaptureSearchResult();
        results.setClosest(result);
        EasyMock.expect(resourceIndex.query(wbRequest)).andReturn(results);
        // - calls MementoUtils.printTimemapResponse(results, wbRequest, httpResponse) instead
        //     if wbRequst.isMementoTimemapRequest() (N/A here) (TODO: can we move this to
        //     QueryRenderer implementation?)
        // - calls query.renderCaptureResults(...)
        query.renderCaptureResults(httpRequest, httpResponse, wbRequest, results, cut.getUriConverter());
       
        EasyMock.replay(httpRequest, httpResponse, resourceIndex, query);
       
        cut.init();
        boolean r = cut.handleRequest(httpRequest, httpResponse);
       
        EasyMock.verify(query);
       
        // result shall have closest flag set (FIrefox proxy plugin expects this)
        assertTrue("closest flag", result.isClosest());
       
        assertTrue("handleRequest return value", r);
       
    }
View Full Code Here

    return 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

    assertTrue("subpath",isBlocked(filter,"http://www.peagreenboat.com/foo"));
    assertTrue("emptypath",isBlocked(filter,"http://www.peagreenboat.com/"));
  }
 
  private boolean isBlocked(ObjectFilter<CaptureSearchResult> filter, String url) {
    CaptureSearchResult result = new CaptureSearchResult();
    result.setOriginalUrl(url);
    int filterResult = filter.filterObject(result);
    if(filterResult == ObjectFilter.FILTER_EXCLUDE) {
      return true;
    }
    return false;
View Full Code Here

import junit.framework.TestCase;

public class CDXFormatTest extends TestCase {
  public void testParseSpec() {
    CaptureSearchResult c;
    CDXFormat f = OKFormat(" CDX a V");
    c = OKParse(f,"http://foo.com 12");
    assertEquals("http://foo.com",c.getOriginalUrl());
    assertEquals(c.getOffset(), 12);

   
    f = OKFormat(" CDX a V k");
    c = OKParse(f,"http://foo.com 12 10");
    assertEquals("http://foo.com",c.getOriginalUrl());
    assertEquals(12,c.getOffset());
    assertEquals("10",c.getDigest());
   
   
    exceptionFormat("CDX a k");
    exceptionFormat("\tCDX a k");
    exceptionFormat("\tCDX a k ");
    exceptionFormat(" CDX\ta k");
    exceptionFormat(" CDX\ta k\t");
    exceptionFormat(" CDX\ta\tk\t");
   
    f = OKFormat(" CDX\ta\tV\tk");
    c = OKParse(f,"http://foo.com\t12\t10");
    assertEquals("http://foo.com",c.getOriginalUrl());
    assertEquals(12,c.getOffset());
    assertEquals("10",c.getDigest());

    c = OKParse(f,"http://foo .com\t12\t10");
    assertEquals("http://foo .com",c.getOriginalUrl());
    assertEquals(12,c.getOffset());
    assertEquals("10",c.getDigest());
  }
View Full Code Here

    assertEquals("http://foo .com",c.getOriginalUrl());
    assertEquals(12,c.getOffset());
    assertEquals("10",c.getDigest());
  }
  private CaptureSearchResult OKParse(CDXFormat f, String line) {
    CaptureSearchResult r = null;
    try {
      r = f.parseResult(line);
    } catch (CDXFormatException e) {
      fail(e.getLocalizedMessage());
    }
View Full Code Here

  public void testFilterObject() {
    List<String> in = Arrays.asList(patterns);
    FileRegexFilter f = new FileRegexFilter();
    f.setPatterns(in);
    CaptureSearchResult c = new CaptureSearchResult();
    c.setFile("one-11");
    assertEquals(f.filterObject(c), ObjectFilter.FILTER_INCLUDE);
    c.setFile("onedd-11");
    assertEquals(f.filterObject(c), ObjectFilter.FILTER_EXCLUDE);
    c.setFile("two-11");
    assertEquals(f.filterObject(c), ObjectFilter.FILTER_INCLUDE);
    f.setPatterns(new ArrayList<String>());
    assertEquals(f.filterObject(c), ObjectFilter.FILTER_EXCLUDE);
  }
View Full Code Here

     
      Thread.currentThread().setName("Thread " +
          Thread.currentThread().getId() + " " + getBeanName() +
          " handling: " + urlString);
     
      CaptureSearchResult result = new FastCaptureSearchResult();
     
      r = this.getLiveWebResource(result, urlString);
     
      if (r != null) {       
        CaptureSearchResults results = new CaptureSearchResults();
        results.addSearchResult(result);
     
        wbRequest.setReplayTimestamp(result.getCaptureTimestamp());
         
        inner.getReplay().getRenderer(wbRequest, result, r).renderResource(httpRequest, httpResponse, wbRequest, result, r,
            inner.getUriConverter(), results)
      } else {
        throw new LiveDocumentNotAvailableException(urlString);
View Full Code Here

  private int annotate(CaptureSearchResult o) {
    o.flagDuplicateDigest();
   
    String thisDigest = o.getDigest();
    CaptureSearchResult last = memory.get(thisDigest);
    if (last == null) {
      if (LOGGER.isLoggable(Level.FINER)) {
        LOGGER.finer("did not find matching digest in previous fetch of url, hopefully it's a new-style revisit - "
            + o.getCaptureTimestamp() + " " + o.getOriginalUrl());
      }
View Full Code Here

TOP

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

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.