@Test public void testWrappingElementValueComparatorEquals() throws Exception { CacheConfiguration cacheConfiguration = mock(CacheConfiguration.class); CopyStrategyConfiguration copyStrategyConfiguration = mock(CopyStrategyConfiguration.class); when(copyStrategyConfiguration.getCopyStrategyInstance(any(ClassLoader.class))).thenReturn(new ReadWriteSerializationCopyStrategy()); when(cacheConfiguration.getCopyStrategyConfiguration()).thenReturn(copyStrategyConfiguration); when(cacheConfiguration.isCopyOnRead()).thenReturn(true); when(cacheConfiguration.isCopyOnWrite()).thenReturn(true); when(cacheConfiguration.getClassLoader()).thenReturn(getClass().getClassLoader()); ElementValueComparator wrappedComparator = TxCopyingCacheStore.wrap(new DefaultElementValueComparator(cacheConfiguration), cacheConfiguration); Element e = new Element(1, serialize("aaa")); assertThat(wrappedComparator.equals(e, e), is(true)); assertThat(wrappedComparator.equals(null, null), is(true)); assertThat(wrappedComparator.equals(null, e), is(false)); assertThat(wrappedComparator.equals(e, null), is(false)); }
private static <T extends Store> TxCopyingCacheStore<T> wrap(final T cacheStore, final CacheConfiguration cacheConfiguration) { final ReadWriteCopyStrategy<Element> copyStrategyInstance = cacheConfiguration.getCopyStrategyConfiguration() .getCopyStrategyInstance(cacheConfiguration.getClassLoader()); return new TxCopyingCacheStore<T>(cacheStore, cacheConfiguration.isCopyOnRead(), cacheConfiguration.isCopyOnWrite(), copyStrategyInstance, cacheConfiguration.getClassLoader()); }
TxCopyingCacheStore extends AbstractCopyingCacheStore<T> { private static <T extends Store> TxCopyingCacheStore<T> wrap(final T cacheStore, final CacheConfiguration cacheConfiguration) { final ReadWriteCopyStrategy<Element> copyStrategyInstance = cacheConfiguration.getCopyStrategyConfiguration() .getCopyStrategyInstance(cacheConfiguration.getClassLoader()); return new TxCopyingCacheStore<T>(cacheStore, cacheConfiguration.isCopyOnRead(), cacheConfiguration.isCopyOnWrite(), copyStrategyInstance, cacheConfiguration.getClassLoader()); } }
TxCopyingCacheStore extends AbstractCopyingCacheStore<T> { private static <T extends Store> TxCopyingCacheStore<T> wrap(final T cacheStore, final CacheConfiguration cacheConfiguration) { final ReadWriteCopyStrategy<Element> copyStrategyInstance = cacheConfiguration.getCopyStrategyConfiguration() .getCopyStrategyInstance(cacheConfiguration.getClassLoader()); return new TxCopyingCacheStore<T>(cacheStore, cacheConfiguration.isCopyOnRead(), cacheConfiguration.isCopyOnWrite(), copyStrategyInstance, cacheConfiguration.getClassLoader()); } TxCopyingCacheStore(T store, boolean copyOnRead, boolean copyOnWrite, ReadWriteCopyStrategy<Element> copyStrategyInstance, ClassLoader loader); }
TxCopyingCacheStore extends AbstractCopyingCacheStore<T> { private static <T extends Store> TxCopyingCacheStore<T> wrap(final T cacheStore, final CacheConfiguration cacheConfiguration) { final ReadWriteCopyStrategy<Element> copyStrategyInstance = cacheConfiguration.getCopyStrategyConfiguration() .getCopyStrategyInstance(cacheConfiguration.getClassLoader()); return new TxCopyingCacheStore<T>(cacheStore, cacheConfiguration.isCopyOnRead(), cacheConfiguration.isCopyOnWrite(), copyStrategyInstance, cacheConfiguration.getClassLoader()); } TxCopyingCacheStore(T store, boolean copyOnRead, boolean copyOnWrite, ReadWriteCopyStrategy<Element> copyStrategyInstance, ClassLoader loader); Element getOldElement(Object key); static Store wrapTxStore(final AbstractTransactionStore cacheStore, final CacheConfiguration cacheConfiguration); static ElementValueComparator wrap(final ElementValueComparator comparator, final CacheConfiguration cacheConfiguration); }
TxCopyingCacheStore extends AbstractCopyingCacheStore<T> { private static <T extends Store> TxCopyingCacheStore<T> wrap(final T cacheStore, final CacheConfiguration cacheConfiguration) { final ReadWriteCopyStrategy<Element> copyStrategyInstance = cacheConfiguration.getCopyStrategyConfiguration() .getCopyStrategyInstance(cacheConfiguration.getClassLoader()); return new TxCopyingCacheStore<T>(cacheStore, cacheConfiguration.isCopyOnRead(), cacheConfiguration.isCopyOnWrite(), copyStrategyInstance, cacheConfiguration.getClassLoader()); } TxCopyingCacheStore(T store, boolean copyOnRead, boolean copyOnWrite, ReadWriteCopyStrategy<Element> copyStrategyInstance, ClassLoader loader); Element getOldElement(Object key); static Store wrapTxStore(final AbstractTransactionStore cacheStore, final CacheConfiguration cacheConfiguration); static ElementValueComparator wrap(final ElementValueComparator comparator, final CacheConfiguration cacheConfiguration);  }