コード例 #1
0
ファイル: StoreClearTest.java プロジェクト: hhuynh/ehcache3
  @SPITest
  public void removesAllOfTheMappings()
      throws IllegalAccessException, InstantiationException, CacheAccessException {
    final Store<K, V> kvStore =
        factory.newStore(
            new StoreConfigurationImpl<K, V>(
                factory.getKeyType(),
                factory.getValueType(),
                null,
                Predicates.<Cache.Entry<K, V>>all(),
                null,
                ClassLoader.getSystemClassLoader(),
                Expirations.noExpiration()));

    K key = factory.getKeyType().newInstance();
    V value = factory.getValueType().newInstance();

    kvStore.put(key, value);

    try {
      kvStore.clear();
    } catch (CacheAccessException e) {
      System.err.println("Warning, an exception is thrown due to the SPI test");
      e.printStackTrace();
    }

    assertThat(kvStore.containsKey(key), is(false));
  }