Package com.google.common.base

Examples of com.google.common.base.Ticker


      return new Module() {
         @Override
         public void configure(Binder binder) {
            // predictable time
            binder.bind(Ticker.class).toInstance(new Ticker() {
               @Override
               public long read() {
                  return 0;
               }
            });
View Full Code Here


      Reservations(final Amount<Long, Time> duration, final Clock clock) {
        requireNonNull(duration);
        requireNonNull(clock);
        this.reservations = CacheBuilder.newBuilder()
            .expireAfterWrite(duration.as(Time.MINUTES), TimeUnit.MINUTES)
            .ticker(new Ticker() {
              @Override
              public long read() {
                return clock.nowNanos();
              }
            })
View Full Code Here

        makeLocalCache(createCacheBuilder().removalListener(testListener));
    assertSame(testListener, map.removalListener);
  }

  public void testSetTicker() {
    Ticker testTicker = new Ticker() {
      @Override
      public long read() {
        return 0;
      }
    };
View Full Code Here

  public void testSerializationProxyLoading() {
    CacheLoader<Object, Object> loader = new SerializableCacheLoader();
    RemovalListener<Object, Object> listener = new SerializableRemovalListener<Object, Object>();
    SerializableWeigher<Object, Object> weigher = new SerializableWeigher<Object, Object>();
    Ticker ticker = new SerializableTicker();
    @SuppressWarnings("unchecked") // createMock
    LocalLoadingCache<Object, Object> one = (LocalLoadingCache) CacheBuilder.newBuilder()
        .weakKeys()
        .softValues()
        .expireAfterAccess(123, SECONDS)
View Full Code Here

  }

  public void testSerializationProxyManual() {
    RemovalListener<Object, Object> listener = new SerializableRemovalListener<Object, Object>();
    SerializableWeigher<Object, Object> weigher = new SerializableWeigher<Object, Object>();
    Ticker ticker = new SerializableTicker();
    @SuppressWarnings("unchecked") // createMock
    LocalManualCache<Object, Object> one = (LocalManualCache) CacheBuilder.newBuilder()
        .weakKeys()
        .softValues()
        .expireAfterAccess(123, NANOSECONDS)
View Full Code Here

      }
    };
  }

  @Generates private Ticker generateTicker() {
    return new Ticker() {
      @Override public long read() {
        return 0;
      }
      final String string = paramString(Ticker.class, generateInt());
      @Override public String toString() {
View Full Code Here

        .build(identityLoader());
    // well, it didn't blow up.
  }

  public void testTicker_setTwice() {
    Ticker testTicker = Ticker.systemTicker();
    CacheBuilder<Object, Object> builder =
        new CacheBuilder<Object, Object>().ticker(testTicker);
    try {
      // even to the same instance is not allowed
      builder.ticker(testTicker);
View Full Code Here

    } catch (IllegalStateException expected) {}
  }

  @GwtIncompatible("ticker")
  public void testTicker_setTwice() {
    Ticker testTicker = Ticker.systemTicker();
    CacheBuilder<Object, Object> builder =
        new CacheBuilder<Object, Object>().ticker(testTicker);
    try {
      // even to the same instance is not allowed
      builder.ticker(testTicker);
View Full Code Here

        makeLocalCache(createCacheBuilder().removalListener(testListener));
    assertSame(testListener, map.removalListener);
  }

  public void testSetTicker() {
    Ticker testTicker = new Ticker() {
      @Override
      public long read() {
        return 0;
      }
    };
View Full Code Here

  public void testSerializationProxyLoading() {
    CacheLoader<Object, Object> loader = new SerializableCacheLoader();
    RemovalListener<Object, Object> listener = new SerializableRemovalListener<Object, Object>();
    SerializableWeigher<Object, Object> weigher = new SerializableWeigher<Object, Object>();
    Ticker ticker = new SerializableTicker();
    @SuppressWarnings("unchecked") // createMock
    LocalLoadingCache<Object, Object> one = (LocalLoadingCache) CacheBuilder.newBuilder()
        .weakKeys()
        .softValues()
        .expireAfterAccess(123, SECONDS)
View Full Code Here

TOP

Related Classes of com.google.common.base.Ticker

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.