View Javadoc

1   package com.atlassian.vcache.internal.legacy;
2   
3   import com.atlassian.cache.CacheFactory;
4   import com.atlassian.cache.CacheSettings;
5   import com.atlassian.cache.CacheSettingsBuilder;
6   import com.atlassian.cache.ehcache.EhCacheManager;
7   import com.atlassian.cache.ehcache.replication.rmi.RMICacheReplicatorConfigFactory;
8   import com.atlassian.marshalling.jdk.StringMarshalling;
9   import com.atlassian.vcache.DirectExternalCache;
10  import com.atlassian.vcache.ExternalCacheSettings;
11  import com.atlassian.vcache.internal.RequestContext;
12  import com.atlassian.vcache.internal.core.DefaultRequestContext;
13  import com.atlassian.vcache.internal.core.Sha1ExternalCacheKeyGenerator;
14  import com.atlassian.vcache.internal.test.AbstractDirectExternalCacheIT;
15  import net.sf.ehcache.CacheManager;
16  import org.junit.Ignore;
17  
18  import java.util.Optional;
19  import java.util.concurrent.ExecutionException;
20  import java.util.concurrent.TimeUnit;
21  
22  public class LegacyDirectExternalCacheEhcacheIT extends AbstractDirectExternalCacheIT {
23      private final RequestContext requestContext = new DefaultRequestContext("tenant-id");
24      private CacheFactory cacheFactory;
25      {
26          final CacheManager rawEhcache = CacheManager.create();
27          // Make sure we are not getting old caches for our test.
28          rawEhcache.removeAllCaches();
29  
30          cacheFactory = new EhCacheManager(rawEhcache, new RMICacheReplicatorConfigFactory(), null);
31      }
32  
33      @Override
34      protected DirectExternalCache<String> createCache(String name, ExternalCacheSettings settings) {
35          final CacheSettings legacySettings = new CacheSettingsBuilder()
36                  .remote()
37                  .maxEntries(settings.getEntryCountHint().get())
38                  .expireAfterWrite(settings.getDefaultTtl().get().toNanos(), TimeUnit.NANOSECONDS)
39                  .build();
40  
41          return new LegacyDirectExternalCache<>(
42                  cacheFactory.getCache(name, null, legacySettings),
43                  () -> requestContext,
44                  new Sha1ExternalCacheKeyGenerator("it-test-42"),
45                  Optional.of(StringMarshalling.pair()),
46                  new LegacyServiceSettingsBuilder().enableAvoidCasOperations().build());
47      }
48  
49      @Ignore("CAS operations not supported")
50      @Override
51      public void simple_get_add() throws ExecutionException, InterruptedException {
52      }
53  
54      @Ignore("CAS operations not supported")
55      @Override
56      public void simple_getBulkIdentified() throws ExecutionException, InterruptedException {
57      }
58  
59      @Ignore("CAS operations not supported")
60      @Override
61      public void simple_getIdentified_removeIf() throws ExecutionException, InterruptedException {
62      }
63  
64      @Ignore("CAS operations not supported")
65      @Override
66      public void simple_getIdentifiedSupplier_removeIf() throws ExecutionException, InterruptedException {
67      }
68  
69      @Ignore("CAS operations not supported")
70      @Override
71      public void exact_getIdentified_removeIf() throws ExecutionException, InterruptedException {
72      }
73  
74      @Ignore("CAS operations not supported")
75      @Override
76      public void simple_getIdentified_replaceIf() throws ExecutionException, InterruptedException {
77      }
78  
79      @Ignore("CAS operations not supported")
80      @Override
81      public void exact_getIdentified_replaceIf() throws ExecutionException, InterruptedException {
82      }
83  
84      @Ignore("CAS operations not supported")
85      @Override
86      public void check_null_detection_with_cas() {
87      }
88  }