Search in sources :

Example 6 with NamedCache

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()));
}
Also used : NamedCache(com.tangosol.net.NamedCache) Test(org.junit.jupiter.api.Test)

Example 7 with NamedCache

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);
}
Also used : InvocableMap(com.tangosol.util.InvocableMap) QueryMap(com.tangosol.util.QueryMap) NamedMap(com.tangosol.net.NamedMap) NamedCollection(com.tangosol.net.NamedCollection) ConcurrentMap(com.tangosol.util.ConcurrentMap) CacheMap(com.tangosol.net.cache.CacheMap) Releasable(com.tangosol.net.Releasable) ObservableMap(com.tangosol.util.ObservableMap) InvocableMap(com.tangosol.util.InvocableMap) CacheMap(com.tangosol.net.cache.CacheMap) AbstractKeySetBasedMap(com.tangosol.util.AbstractKeySetBasedMap) QueryMap(com.tangosol.util.QueryMap) Map(java.util.Map) ObservableMap(com.tangosol.util.ObservableMap) AbstractKeyBasedMap(com.tangosol.util.AbstractKeyBasedMap) ConcurrentMap(com.tangosol.util.ConcurrentMap) NamedMap(com.tangosol.net.NamedMap) NamedCache(com.tangosol.net.NamedCache) Test(org.junit.jupiter.api.Test)

Example 8 with NamedCache

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());
}
Also used : SessionCreatedEvent(org.springframework.session.events.SessionCreatedEvent) Authentication(org.springframework.security.core.Authentication) SecurityContext(org.springframework.security.core.context.SecurityContext) UsernamePasswordAuthenticationToken(org.springframework.security.authentication.UsernamePasswordAuthenticationToken) NamedCache(com.tangosol.net.NamedCache) EnableCoherenceHttpSession(com.oracle.coherence.spring.session.config.annotation.web.http.EnableCoherenceHttpSession) Session(org.springframework.session.Session) Test(org.junit.jupiter.api.Test)

Example 9 with NamedCache

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");
}
Also used : Session(com.tangosol.net.Session) NamedCache(com.tangosol.net.NamedCache) Test(org.junit.jupiter.api.Test)

Example 10 with NamedCache

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");
}
Also used : CoherenceCache(com.oracle.coherence.spring.cache.CoherenceCache) Cache(org.springframework.cache.Cache) CoherenceCache(com.oracle.coherence.spring.cache.CoherenceCache) NamedCache(com.tangosol.net.NamedCache) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

NamedCache (com.tangosol.net.NamedCache)28 Test (org.junit.jupiter.api.Test)14 Map (java.util.Map)10 BeanFactory (org.springframework.beans.factory.BeanFactory)6 VisualVMModel (com.oracle.coherence.plugin.visualvm.VisualVMModel)3 RequestSender (com.oracle.coherence.plugin.visualvm.helper.RequestSender)3 CacheData (com.oracle.coherence.plugin.visualvm.tablemodel.model.CacheData)3 CacheDetailData (com.oracle.coherence.plugin.visualvm.tablemodel.model.CacheDetailData)3 ClusterData (com.oracle.coherence.plugin.visualvm.tablemodel.model.ClusterData)3 Data (com.oracle.coherence.plugin.visualvm.tablemodel.model.Data)3 FederationData (com.oracle.coherence.plugin.visualvm.tablemodel.model.FederationData)3 FederationDestinationDetailsData (com.oracle.coherence.plugin.visualvm.tablemodel.model.FederationDestinationDetailsData)3 FederationOriginDetailsData (com.oracle.coherence.plugin.visualvm.tablemodel.model.FederationOriginDetailsData)3 MemberData (com.oracle.coherence.plugin.visualvm.tablemodel.model.MemberData)3 PersistenceData (com.oracle.coherence.plugin.visualvm.tablemodel.model.PersistenceData)3 ProxyData (com.oracle.coherence.plugin.visualvm.tablemodel.model.ProxyData)3 RamJournalData (com.oracle.coherence.plugin.visualvm.tablemodel.model.RamJournalData)3 ServiceData (com.oracle.coherence.plugin.visualvm.tablemodel.model.ServiceData)3 ServiceMemberData (com.oracle.coherence.plugin.visualvm.tablemodel.model.ServiceMemberData)3 ExtensibleConfigurableCacheFactory (com.tangosol.net.ExtensibleConfigurableCacheFactory)3