Search in sources :

Example 1 with SessionConfigurationProvider

use of io.micronaut.coherence.SessionConfigurationProvider in project micronaut-coherence by micronaut-projects.

the class GrpcSessionConfigurationBeanTest method shouldConfigureSessions.

@Test
void shouldConfigureSessions() {
    Map<String, SessionConfiguration> beans = ctx.getBeansOfType(GrpcSessionConfigurationBean.class).stream().map(SessionConfigurationProvider::getConfiguration).filter(Optional::isPresent).map(Optional::get).collect(Collectors.toMap(SessionConfiguration::getName, cfg -> cfg));
    Optional<Channel> optional = ctx.findBean(Channel.class, Qualifiers.byName("default"));
    assertThat(optional.isPresent(), is(true));
    assertThat(beans.size(), is(2));
    GrpcSessionConfiguration beanBar = (GrpcSessionConfiguration) beans.get("bar");
    assertThat(beanBar, is(notNullValue()));
    assertThat(beanBar.getName(), is("bar"));
    assertThat(beanBar.getScopeName(), is(Coherence.DEFAULT_SCOPE));
    assertThat(beanBar.getSerializer().orElseThrow(AssertionFailedError::new), notNullValue());
    assertThat(beanBar.getFormat().orElseThrow(AssertionFailedError::new), is("java"));
    assertThat(beanBar.enableTracing(), is(true));
    GrpcSessionConfiguration beanBaz = (GrpcSessionConfiguration) beans.get("baz");
    assertThat(beanBaz, is(notNullValue()));
    assertThat(beanBaz.getName(), is("baz"));
    assertThat(beanBaz.getScopeName(), is("scoped"));
    assertThat(beanBaz.getSerializer().isPresent(), is(false));
    assertThat(beanBaz.getFormat().orElseThrow(AssertionFailedError::new), is("binary"));
    assertThat(beanBaz.enableTracing(), is(false));
}
Also used : CoreMatchers.is(org.hamcrest.CoreMatchers.is) Coherence(com.tangosol.net.Coherence) SessionConfigurationProvider(io.micronaut.coherence.SessionConfigurationProvider) GrpcSessionConfiguration(com.oracle.coherence.client.GrpcSessionConfiguration) Qualifiers(io.micronaut.inject.qualifiers.Qualifiers) Channel(io.grpc.Channel) Collectors(java.util.stream.Collectors) CoreMatchers.notNullValue(org.hamcrest.CoreMatchers.notNullValue) Inject(javax.inject.Inject) Test(org.junit.jupiter.api.Test) ApplicationContext(io.micronaut.context.ApplicationContext) AssertionFailedError(org.opentest4j.AssertionFailedError) Map(java.util.Map) Serializer(com.tangosol.io.Serializer) Optional(java.util.Optional) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) MicronautTest(io.micronaut.test.extensions.junit5.annotation.MicronautTest) SessionConfiguration(com.tangosol.net.SessionConfiguration) GrpcSessionConfiguration(com.oracle.coherence.client.GrpcSessionConfiguration) Optional(java.util.Optional) Channel(io.grpc.Channel) GrpcSessionConfiguration(com.oracle.coherence.client.GrpcSessionConfiguration) SessionConfiguration(com.tangosol.net.SessionConfiguration) Test(org.junit.jupiter.api.Test) MicronautTest(io.micronaut.test.extensions.junit5.annotation.MicronautTest)

Aggregations

GrpcSessionConfiguration (com.oracle.coherence.client.GrpcSessionConfiguration)1 Serializer (com.tangosol.io.Serializer)1 Coherence (com.tangosol.net.Coherence)1 SessionConfiguration (com.tangosol.net.SessionConfiguration)1 Channel (io.grpc.Channel)1 SessionConfigurationProvider (io.micronaut.coherence.SessionConfigurationProvider)1 ApplicationContext (io.micronaut.context.ApplicationContext)1 Qualifiers (io.micronaut.inject.qualifiers.Qualifiers)1 MicronautTest (io.micronaut.test.extensions.junit5.annotation.MicronautTest)1 Map (java.util.Map)1 Optional (java.util.Optional)1 Collectors (java.util.stream.Collectors)1 Inject (javax.inject.Inject)1 CoreMatchers.is (org.hamcrest.CoreMatchers.is)1 CoreMatchers.notNullValue (org.hamcrest.CoreMatchers.notNullValue)1 MatcherAssert.assertThat (org.hamcrest.MatcherAssert.assertThat)1 Test (org.junit.jupiter.api.Test)1 AssertionFailedError (org.opentest4j.AssertionFailedError)1