use of com.tangosol.net.NamedCache in project coherence-spring by coherence-community.
the class CoherenceNamedCacheConfigurationViewTest method shouldInjectSuperTypeNamedCache.
@Test
@SuppressWarnings("rawtypes")
void shouldInjectSuperTypeNamedCache() {
SuperTypesBean bean = this.ctx.getBean(SuperTypesBean.class);
NamedCache cache = bean.getNamedCache();
assertThat(cache, is(notNullValue()));
}
use of com.tangosol.net.NamedCache in project coherence-spring by coherence-community.
the class CoherenceGenericConverterTests method testNamedCacheConversion.
@Test
public void testNamedCacheConversion() {
final Map map = this.conversionService.convert(this.mockedNamedCache, Map.class);
assertThat(map).isSameAs(this.mockedNamedCache);
final NamedCache namedCache = this.conversionService.convert(this.mockedNamedCache, NamedCache.class);
assertThat(namedCache).isSameAs(this.mockedNamedCache);
final NamedMap namedMap = this.conversionService.convert(this.mockedNamedCache, NamedMap.class);
assertThat(namedMap).isSameAs(this.mockedNamedCache);
final CacheMap cacheMap = this.conversionService.convert(this.mockedNamedCache, CacheMap.class);
assertThat(cacheMap).isSameAs(this.mockedNamedCache);
final NamedCollection namedCollection = this.conversionService.convert(this.mockedNamedCache, NamedCollection.class);
assertThat(namedCollection).isSameAs(this.mockedNamedCache);
final ObservableMap observableMap = this.conversionService.convert(this.mockedNamedCache, ObservableMap.class);
assertThat(observableMap).isSameAs(this.mockedNamedCache);
final ConcurrentMap concurrentMap = this.conversionService.convert(this.mockedNamedCache, ConcurrentMap.class);
assertThat(concurrentMap).isSameAs(this.mockedNamedCache);
final QueryMap queryMap = this.conversionService.convert(this.mockedNamedCache, QueryMap.class);
assertThat(queryMap).isSameAs(this.mockedNamedCache);
final InvocableMap invocableMap = this.conversionService.convert(this.mockedNamedCache, InvocableMap.class);
assertThat(invocableMap).isSameAs(this.mockedNamedCache);
final Releasable releasable = this.conversionService.convert(this.mockedNamedCache, Releasable.class);
assertThat(releasable).isSameAs(this.mockedNamedCache);
}
use of com.tangosol.net.NamedCache in project coherence-spring by coherence-community.
the class AbstractSessionEventTests method saveSessionTest.
@Test
void saveSessionTest() throws InterruptedException {
final NamedCache sessionCache = this.coherence.getSession().getCache(this.expectedCacheName);
assertThat(sessionCache.isActive()).isTrue();
assertThat(sessionCache.size()).isEqualTo(0);
final String username = "coherence_rocks";
final Session sessionToSave = this.repository.createSession();
final String expectedAttributeName = "foo-key";
final String expectedAttributeValue = "foo-value";
sessionToSave.setAttribute(expectedAttributeName, expectedAttributeValue);
final Authentication toSaveToken = new UsernamePasswordAuthenticationToken(username, "password", AuthorityUtils.createAuthorityList("ROLE_USER"));
final SecurityContext toSaveContext = SecurityContextHolder.createEmptyContext();
toSaveContext.setAuthentication(toSaveToken);
sessionToSave.setAttribute("SPRING_SECURITY_CONTEXT", toSaveContext);
sessionToSave.setAttribute(FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME, username);
this.repository.save(sessionToSave);
assertThat(this.sessionEventApplicationListener.receivedEvent(sessionToSave.getId())).isTrue();
assertThat(this.sessionEventApplicationListener.<SessionCreatedEvent>getEvent(sessionToSave.getId())).isInstanceOf(SessionCreatedEvent.class);
final Session sessionFromRepository = this.repository.findById(sessionToSave.getId());
assertThat(sessionFromRepository.getId()).isEqualTo(sessionToSave.getId());
assertThat(sessionFromRepository.getAttributeNames()).isEqualTo(sessionToSave.getAttributeNames());
assertThat(sessionFromRepository.<String>getAttribute(expectedAttributeName)).isEqualTo(sessionToSave.getAttribute(expectedAttributeName));
assertThat(sessionCache.size()).isEqualTo(1);
this.repository.deleteById(sessionToSave.getId());
}
use of com.tangosol.net.NamedCache in project coherence-spring by coherence-community.
the class CoherenceGrpcClientTests method testDefaultCacheManagerExists.
@Test
public void testDefaultCacheManagerExists() throws Exception {
final CoherenceConfigClientProperties coherenceConfigClientProperties = new CoherenceConfigClientProperties();
coherenceConfigClientProperties.getClient().setHost("localhost");
coherenceConfigClientProperties.getClient().setPort(1408);
coherenceConfigClientProperties.getClient().setEnableTls(false);
final CoherenceGrpcClient coherenceGrpcClient = new CoherenceGrpcClient(coherenceConfigClientProperties);
final Session grpcCoherenceSession = coherenceGrpcClient.getCoherenceSession();
final NamedCache cache = grpcCoherenceSession.getCache("test");
cache.put("foo2", "bar2");
coherenceGrpcClient.close();
final Session coherenceSession = this.coherence.getSession();
assertThat(coherenceSession.getCache("test")).hasSize(1);
assertThat(coherenceSession.getCache("test").get("foo2")).isEqualTo("bar2");
}
use of com.tangosol.net.NamedCache in project coherence-spring by coherence-community.
the class CacheAbstractionWithPrefixTests method testCachePrefix.
@Test
public void testCachePrefix() {
final Cache cache = this.cacheManager.getCache("foo");
final CoherenceCache coherenceCache = (CoherenceCache) cache;
assertThat(coherenceCache.getCacheConfiguration().getTimeToLive()).isEqualTo(Duration.ZERO);
assertThat(coherenceCache.getCacheConfiguration().getCacheNamePrefix()).isEqualTo("FooTesting_");
assertThat(coherenceCache.getCacheConfiguration().isUseCacheNamePrefix()).isTrue();
cache.put("fookey", "foovalue");
final NamedCache<String, String> nativeFooCache = this.session.getCache("foo");
assertThat(nativeFooCache.size()).isZero();
final NamedCache<String, String> nativeFooCacheWithPrefix = this.session.getCache("FooTesting_foo");
assertThat(nativeFooCacheWithPrefix.size()).isOne();
assertThat(nativeFooCacheWithPrefix.get("fookey")).isEqualTo("foovalue");
}
Aggregations