Examples of FakeTimeSource


Examples of org.apache.shindig.common.util.FakeTimeSource

  }

  @Test
  public void testCopyToServletResponseAndOverrideCacheHeadersForPrivate()
      throws Exception {
    FakeTimeSource fakeTime = new FakeTimeSource();
    HttpUtil.setTimeSource(fakeTime);

    HttpResponse response = new HttpResponseBuilder()
        .setResponseString("response string").setHttpStatusCode(200).addHeader("h1", "v1")
        .addHeader("h2", "v2").addHeader("Cache-Control", "private,no-store,max-age=10")
        .addHeader("Expires", "123").create();

    HttpServletResponse servletResponse = EasyMock.createMock(HttpServletResponse.class);
    HttpServletResponseRecorder recorder = new HttpServletResponseRecorder(servletResponse);
    long testStartTime = fakeTime.currentTimeMillis();
    ServletUtil.copyToServletResponseAndOverrideCacheHeaders(response, recorder);
    assertEquals(200, recorder.getHttpStatusCode());
    assertEquals("response string", recorder.getResponseAsString());
    assertEquals("v1", recorder.getHeader("h1"));
    assertEquals("v2", recorder.getHeader("h2"));
View Full Code Here

Examples of org.apache.shindig.common.util.FakeTimeSource

        .addHeader("h2", "v2").setStrictNoCache().create();

    HttpServletResponse servletResponse = EasyMock.createMock(HttpServletResponse.class);
    HttpServletResponseRecorder recorder = new HttpServletResponseRecorder(servletResponse);

    FakeTimeSource fakeTime = new FakeTimeSource();
    HttpUtil.setTimeSource(fakeTime);
    ServletUtil.copyToServletResponseAndOverrideCacheHeaders(response, recorder);

    assertEquals(200, recorder.getHttpStatusCode());
    assertEquals("response string", recorder.getResponseAsString());
View Full Code Here

Examples of org.apache.shindig.common.util.FakeTimeSource

  @Test
  public void testWithCache() throws Exception {
    String url = "http://example.org/file.evil";
    String domain = "example.org";
    HttpResponse.setTimeSource(new FakeTimeSource());

    setupProxyRequestMock(domain, url, false, 120, null, null);
    setupGadgetAdminMock(true);

    HttpRequest req = new HttpRequestCache(Uri.parse(url)).setCacheTtl(120).setIgnoreCache(false);
View Full Code Here

Examples of org.apache.shindig.common.util.FakeTimeSource

  @Test
  public void testWithBadTtl() throws Exception {
    String url = "http://example.org/file.evil";
    String domain = "example.org";
    HttpResponse.setTimeSource(new FakeTimeSource());

    setupProxyRequestMock(domain, url, false, -1, null, null);
    setupGadgetAdminMock(true);

    HttpRequest req = new HttpRequestCache(Uri.parse(url)).setCacheTtl(-1).setIgnoreCache(false);
View Full Code Here

Examples of org.apache.shindig.common.util.FakeTimeSource

  private BasicBlobCrypter crypter;
  private FakeTimeSource timeSource;

  public BlobCrypterTest() {
    crypter = new BasicBlobCrypter("0123456789abcdef".getBytes(),HMACType.HMACSHA1);
    timeSource = new FakeTimeSource();
    crypter.timeSource = timeSource;
  }
View Full Code Here

Examples of org.apache.shindig.common.util.FakeTimeSource

public class CryptoTest {
  private BasicBlobCrypter crypter;

  public CryptoTest() {
    crypter = new BasicBlobCrypter("0123456789abcdef".getBytes());
    crypter.timeSource = new FakeTimeSource();
  }
View Full Code Here

Examples of org.apache.shindig.common.util.FakeTimeSource

  private FakeTimeSource timeSource;
  private Cache<String, String> cache;

  @Before
  public void setUp() throws Exception {
    timeSource = new FakeTimeSource(0);
    cache = new LruCache<String, String>(5);
  }
View Full Code Here

Examples of org.apache.shindig.common.util.FakeTimeSource

        .addContainer(makeContainer("default"))
        .addContainer(makeContainer("container"))
        .addContainer(makeContainer("example"))
        .commit();
    codec = new BlobCrypterSecurityTokenCodec(config);
    timeSource = new FakeTimeSource();
  }
View Full Code Here

Examples of org.apache.shindig.common.util.FakeTimeSource

  }

  @Before
  public void setUp() {
    fetcher = createMock(HttpFetcher.class);
    timeSource = new FakeTimeSource();
    timeSource.setCurrentTimeMillis(0);
    loader = new TestFeatureResourceLoader(fetcher, timeSource, new DefaultFeatureFileSystem());
  }
View Full Code Here

Examples of org.apache.shindig.common.util.FakeTimeSource

    privateToken.setAppUrl(GADGET_URL);

    stateCrypter = new BasicBlobCrypter("abcdefghijklmnop".getBytes());
    clientState = new OAuthClientState(stateCrypter);
    responseParams = new OAuthResponseParams(socialToken, null, stateCrypter);
    fetcherConfig = new OAuthFetcherConfig(stateCrypter, store, new FakeTimeSource(), null, false);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.