コード例 #1
0
ファイル: PlayCacheTest.java プロジェクト: netmau5/sparkmuse
 @Test
 public void shouldAllowRawPutAndGet() {
   final Cache cache = newCache();
   Object obj1 = new SerializableObj();
   cache.set("Key", obj1);
   MatcherAssert.assertThat(cache.get("Key"), Matchers.is(obj1));
 }
コード例 #2
0
ファイル: PlayCacheTest.java プロジェクト: netmau5/sparkmuse
 @Test
 public void shouldAllowCacheablePutAndGet() {
   final Cache cache = newCache();
   final CacheableObj cacheable = new CacheableObj();
   cache.set(cacheable);
   MatcherAssert.assertThat(cache.get(cacheable.getKey()), Matchers.is(cacheable.getInstance()));
 }
コード例 #3
0
ファイル: PlayCacheTest.java プロジェクト: netmau5/sparkmuse
 @Test
 public void shouldOverwriteValueOnRawPut() {
   final Cache cache = newCache();
   Object obj1 = new SerializableObj();
   Object obj2 = new SerializableObj();
   cache.set("Key", obj1);
   cache.set("Key", obj2);
   MatcherAssert.assertThat(cache.get("Key"), Matchers.is(obj2));
 }
コード例 #4
0
ファイル: PlayCacheTest.java プロジェクト: netmau5/sparkmuse
  @Test(expected = NullPointerException.class)
  public void shouldNotAllowCacheablePutWithNullCacheableCacheKey() {
    final Cache cache = newCache();
    final Cacheable cacheable =
        new Cacheable() {
          public CacheKey getKey() {
            return null;
          }

          public Object getInstance() {
            return new Object();
          }
        };
    cache.set(cacheable);
  }
コード例 #5
0
ファイル: PlayCacheTest.java プロジェクト: netmau5/sparkmuse
  @Test(expected = IllegalArgumentException.class)
  public void shouldNotAllowCacheablePutWithNonSerializableValue() {
    final Cache cache = newCache();
    final Cacheable<Object> cacheable =
        new Cacheable() {
          public CacheKey getKey() {
            return new CacheKey<Object>(Object.class);
          }

          public Object getInstance() {
            return new Object();
          }
        };
    cache.set(cacheable);
  }
コード例 #6
0
ファイル: PlayCacheTest.java プロジェクト: netmau5/sparkmuse
 @Test(expected = NullPointerException.class)
 public void shouldNotAllowCacheablePutWithNullCacheable() {
   final Cache cache = newCache();
   cache.set(null);
 }
コード例 #7
0
ファイル: PlayCacheTest.java プロジェクト: netmau5/sparkmuse
 @Test(expected = IllegalArgumentException.class)
 public void shouldNotAllowPutWithNonSerializableValue() {
   final Cache cache = newCache();
   Object obj1 = new Object();
   cache.set("Key", obj1);
 }
コード例 #8
0
ファイル: PlayCacheTest.java プロジェクト: netmau5/sparkmuse
 @Test(expected = NullPointerException.class)
 public void shouldNotAllowPutWithNullValue() {
   final Cache cache = newCache();
   cache.set("key", null);
 }
コード例 #9
0
ファイル: PlayCacheTest.java プロジェクト: netmau5/sparkmuse
 @Test(expected = NullPointerException.class)
 public void shouldNotAllowPutWithNullKey() {
   final Cache cache = newCache();
   cache.set(null, new SerializableObj());
 }