use of com.tangosol.net.NamedMap 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.NamedMap in project micronaut-coherence by micronaut-projects.
the class CoherenceConfigurationClientTest method shouldProvidePropertySources.
@Test
public void shouldProvidePropertySources() {
NamedMap<String, Object> applicationMap = session.getMap("application");
applicationMap.put("hello", "app hello");
applicationMap.put("foo", "app foo");
applicationMap.put("my-app", "app my-app");
applicationMap.put("test", "app test");
applicationMap.put("backend", "app backend");
NamedMap<String, Object> applicationFooMap = session.getMap("application-foo");
applicationFooMap.put("bar", "app foo bar");
NamedMap<String, Object> applicationTestMap = session.getMap("application-test");
applicationTestMap.put("foo", "app test foo");
NamedMap<String, Object> applicationBackendMap = session.getMap("application-backend");
applicationBackendMap.put("foo", "app backend foo");
applicationBackendMap.put("bar", "app backend bar");
NamedMap<String, Object> myAppMap = session.getMap("my-app");
myAppMap.put("hello", "my-app hello");
myAppMap.put("foo", "my-app foo");
NamedMap<String, Object> myAppTestMap = session.getMap("my-app-test");
myAppTestMap.put("hello", "my-app test hello");
NamedMap<String, Object> myAppBackendMap = session.getMap("my-app-backend");
myAppBackendMap.put("hello", "my-app backend hello");
myAppBackendMap.put("hello/bar", "my-app backend hello/bar");
NamedMap<String, Object> otherAppBackendMap = session.getMap("other-app");
otherAppBackendMap.put("hello", "other-app hello");
ApplicationConfiguration applicationConfiguration = new ApplicationConfiguration();
applicationConfiguration.setName("my-app");
CoherenceClientConfiguration clientConfig = new CoherenceClientConfiguration();
clientConfig.setEnabled(true);
CoherenceConfigurationClient client = new CoherenceConfigurationClient(applicationConfiguration, clientConfig) {
@Override
protected Session buildSession(CoherenceClientConfiguration coherenceClientConfiguration) {
Session session = mock(Session.class);
when(session.<String, Object>getMap("application")).thenReturn(applicationMap);
when(session.<String, Object>getMap("application-foo")).thenReturn(applicationFooMap);
when(session.<String, Object>getMap("application-test")).thenReturn(applicationTestMap);
when(session.<String, Object>getMap("application-backend")).thenReturn(applicationBackendMap);
when(session.<String, Object>getMap("my-app")).thenReturn(myAppMap);
when(session.<String, Object>getMap("my-app-test")).thenReturn(myAppTestMap);
when(session.<String, Object>getMap("my-app-backend")).thenReturn(myAppBackendMap);
when(session.<String, Object>getMap("other-app")).thenReturn(otherAppBackendMap);
return session;
}
};
Publisher<PropertySource> propertySourcePublisher = client.getPropertySources(context.getEnvironment());
Iterable<PropertySource> propsIt = Flux.from(propertySourcePublisher).toIterable();
Map<String, PropertySource> propertySources = StreamSupport.stream(propsIt.spliterator(), false).collect(Collectors.toMap(PropertySource::getName, Function.identity()));
assertThat(propertySources.keySet().toArray(), arrayContainingInAnyOrder("application", "application-test", "application-backend", "my-app", "my-app-test", "my-app-backend"));
PropertySource appPs = propertySources.get("application");
assertEquals(-99, appPs.getOrder());
Map<String, String> props = StreamSupport.stream(appPs.spliterator(), false).collect(Collectors.toMap(Function.identity(), key -> (String) appPs.get(key)));
Map<String, String> expected = new HashMap<>();
expected.put("hello", "app hello");
expected.put("foo", "app foo");
expected.put("my-app", "app my-app");
expected.put("test", "app test");
expected.put("backend", "app backend");
assertEquals(expected, props);
PropertySource appTestPs = propertySources.get("application-test");
assertEquals(-47, appTestPs.getOrder());
props = StreamSupport.stream(appTestPs.spliterator(), false).collect(Collectors.toMap(Function.identity(), key -> (String) appTestPs.get(key)));
expected = new HashMap<>();
expected.put("foo", "app test foo");
assertEquals(expected, props);
PropertySource appBackendPs = propertySources.get("application-backend");
assertEquals(-45, appBackendPs.getOrder());
props = StreamSupport.stream(appBackendPs.spliterator(), false).collect(Collectors.toMap(Function.identity(), key -> (String) appBackendPs.get(key)));
expected = new HashMap<>();
expected.put("foo", "app backend foo");
expected.put("bar", "app backend bar");
assertEquals(expected, props);
PropertySource myAppPs = propertySources.get("my-app");
assertEquals(-98, myAppPs.getOrder());
props = StreamSupport.stream(myAppPs.spliterator(), false).collect(Collectors.toMap(Function.identity(), key -> (String) myAppPs.get(key)));
expected = new HashMap<>();
expected.put("hello", "my-app hello");
expected.put("foo", "my-app foo");
assertEquals(expected, props);
PropertySource myAppTestPs = propertySources.get("my-app-test");
assertEquals(-46, myAppTestPs.getOrder());
props = StreamSupport.stream(myAppTestPs.spliterator(), false).collect(Collectors.toMap(Function.identity(), key -> (String) myAppTestPs.get(key)));
expected = new HashMap<>();
expected.put("hello", "my-app test hello");
assertEquals(expected, props);
PropertySource myAppBackendPs = propertySources.get("my-app-backend");
assertEquals(-44, myAppBackendPs.getOrder());
props = StreamSupport.stream(myAppBackendPs.spliterator(), false).collect(Collectors.toMap(Function.identity(), key -> (String) myAppBackendPs.get(key)));
expected = new HashMap<>();
expected.put("hello", "my-app backend hello");
expected.put("hello/bar", "my-app backend hello/bar");
assertEquals(expected, props);
}
use of com.tangosol.net.NamedMap in project micronaut-coherence by micronaut-projects.
the class CoherenceConfigurationClient method getPropertySources.
@Override
public Publisher<PropertySource> getPropertySources(Environment environment) {
if (!coherenceClientConfiguration.isEnabled()) {
return Flux.empty();
}
Session session = buildSession(coherenceClientConfiguration);
Map<Integer, String> keys = buildSourceNames(applicationConfiguration, environment);
for (Map.Entry<Integer, String> entry : keys.entrySet()) {
final Integer priority = entry.getKey();
final String propertySource = entry.getValue();
NamedMap<String, Object> configMap = session.getMap(propertySource);
Flux<PropertySource> propertySourceFlux = Flux.just(PropertySource.of(propertySource, configMap, priority));
propertySources.add(propertySourceFlux);
}
return Flux.merge(propertySources);
}
use of com.tangosol.net.NamedMap in project coherence-spring by coherence-community.
the class CoherenceGenericConverterTests method testContinuousQueryCacheConversion.
@Test
public void testContinuousQueryCacheConversion() {
final Map map = this.conversionService.convert(this.mockedContinuousQueryCache, Map.class);
assertThat(map).isSameAs(this.mockedContinuousQueryCache);
final ContinuousQueryCache continuousQueryCache = this.conversionService.convert(this.mockedContinuousQueryCache, ContinuousQueryCache.class);
assertThat(continuousQueryCache).isSameAs(this.mockedContinuousQueryCache);
final AbstractKeySetBasedMap abstractKeySetBasedMap = this.conversionService.convert(this.mockedContinuousQueryCache, AbstractKeySetBasedMap.class);
assertThat(abstractKeySetBasedMap).isSameAs(this.mockedContinuousQueryCache);
final AbstractKeyBasedMap abstractKeyBasedMap = this.conversionService.convert(this.mockedContinuousQueryCache, AbstractKeyBasedMap.class);
assertThat(abstractKeyBasedMap).isSameAs(this.mockedContinuousQueryCache);
final NamedCache namedCache = this.conversionService.convert(this.mockedContinuousQueryCache, NamedCache.class);
assertThat(namedCache).isSameAs(this.mockedContinuousQueryCache);
final NamedMap namedMap = this.conversionService.convert(this.mockedContinuousQueryCache, NamedMap.class);
assertThat(namedMap).isSameAs(this.mockedContinuousQueryCache);
final CacheMap cacheMap = this.conversionService.convert(this.mockedContinuousQueryCache, CacheMap.class);
assertThat(cacheMap).isSameAs(this.mockedContinuousQueryCache);
final NamedCollection namedCollection = this.conversionService.convert(this.mockedContinuousQueryCache, NamedCollection.class);
assertThat(namedCollection).isSameAs(this.mockedContinuousQueryCache);
final ObservableMap observableMap = this.conversionService.convert(this.mockedContinuousQueryCache, ObservableMap.class);
assertThat(observableMap).isSameAs(this.mockedContinuousQueryCache);
final ConcurrentMap concurrentMap = this.conversionService.convert(this.mockedContinuousQueryCache, ConcurrentMap.class);
assertThat(concurrentMap).isSameAs(this.mockedContinuousQueryCache);
final QueryMap queryMap = this.conversionService.convert(this.mockedContinuousQueryCache, QueryMap.class);
assertThat(queryMap).isSameAs(this.mockedContinuousQueryCache);
final InvocableMap invocableMap = this.conversionService.convert(this.mockedContinuousQueryCache, InvocableMap.class);
assertThat(invocableMap).isSameAs(this.mockedContinuousQueryCache);
final Releasable releasable = this.conversionService.convert(this.mockedContinuousQueryCache, Releasable.class);
assertThat(releasable).isSameAs(this.mockedContinuousQueryCache);
}
Aggregations