Search in sources :

Example 1 with EnvironmentBuilder

use of com.rabbitmq.stream.EnvironmentBuilder in project spring-boot by spring-projects.

the class RabbitStreamConfigurationTests method whenStreamCredentialsAreSetThenEnvironmentUsesStreamCredentials.

@Test
void whenStreamCredentialsAreSetThenEnvironmentUsesStreamCredentials() {
    EnvironmentBuilder builder = mock(EnvironmentBuilder.class);
    RabbitProperties properties = new RabbitProperties();
    properties.setUsername("alice");
    properties.setPassword("secret");
    properties.getStream().setUsername("bob");
    properties.getStream().setPassword("confidential");
    RabbitStreamConfiguration.configure(builder, properties);
    then(builder).should().username("bob");
    then(builder).should().password("confidential");
}
Also used : EnvironmentBuilder(com.rabbitmq.stream.EnvironmentBuilder) Test(org.junit.jupiter.api.Test)

Example 2 with EnvironmentBuilder

use of com.rabbitmq.stream.EnvironmentBuilder in project spring-boot by spring-projects.

the class RabbitStreamConfigurationTests method whenStreamHostIsSetThenEnvironmentUsesCustomHost.

@Test
void whenStreamHostIsSetThenEnvironmentUsesCustomHost() {
    EnvironmentBuilder builder = mock(EnvironmentBuilder.class);
    RabbitProperties properties = new RabbitProperties();
    properties.getStream().setHost("stream.rabbit.example.com");
    RabbitStreamConfiguration.configure(builder, properties);
    then(builder).should().host("stream.rabbit.example.com");
}
Also used : EnvironmentBuilder(com.rabbitmq.stream.EnvironmentBuilder) Test(org.junit.jupiter.api.Test)

Example 3 with EnvironmentBuilder

use of com.rabbitmq.stream.EnvironmentBuilder in project spring-boot by spring-projects.

the class RabbitStreamConfigurationTests method whenStreamPortIsSetThenEnvironmentUsesCustomPort.

@Test
void whenStreamPortIsSetThenEnvironmentUsesCustomPort() {
    EnvironmentBuilder builder = mock(EnvironmentBuilder.class);
    RabbitProperties properties = new RabbitProperties();
    properties.getStream().setPort(5553);
    RabbitStreamConfiguration.configure(builder, properties);
    then(builder).should().port(5553);
}
Also used : EnvironmentBuilder(com.rabbitmq.stream.EnvironmentBuilder) Test(org.junit.jupiter.api.Test)

Example 4 with EnvironmentBuilder

use of com.rabbitmq.stream.EnvironmentBuilder in project spring-boot by spring-projects.

the class RabbitStreamConfigurationTests method whenStreamCredentialsAreNotSetThenEnvironmentUsesRabbitCredentials.

@Test
void whenStreamCredentialsAreNotSetThenEnvironmentUsesRabbitCredentials() {
    EnvironmentBuilder builder = mock(EnvironmentBuilder.class);
    RabbitProperties properties = new RabbitProperties();
    properties.setUsername("alice");
    properties.setPassword("secret");
    RabbitStreamConfiguration.configure(builder, properties);
    then(builder).should().username("alice");
    then(builder).should().password("secret");
}
Also used : EnvironmentBuilder(com.rabbitmq.stream.EnvironmentBuilder) Test(org.junit.jupiter.api.Test)

Example 5 with EnvironmentBuilder

use of com.rabbitmq.stream.EnvironmentBuilder in project rabbitmq-stream-java-client by rabbitmq.

the class StreamEnvironmentTest method environmentCreationShouldSucceedWhenUsingTls.

@DisabledIfTlsNotEnabled
@Test
void environmentCreationShouldSucceedWhenUsingTls() {
    ChannelCustomizer channelCustomizer = ch -> {
        SslHandler sslHandler = ch.pipeline().get(SslHandler.class);
        if (sslHandler != null) {
            SSLParameters sslParameters = sslHandler.engine().getSSLParameters();
            sslParameters.setServerNames(Collections.singletonList(new SNIHostName("localhost")));
            sslHandler.engine().setSSLParameters(sslParameters);
        }
    };
    environmentBuilder.uri("rabbitmq-stream+tls://guest:guest@localhost:5551/%2f").channelCustomizer(channelCustomizer).tls().trustEverything().environmentBuilder().build().close();
}
Also used : BeforeEach(org.junit.jupiter.api.BeforeEach) SNIHostName(javax.net.ssl.SNIHostName) Message(com.rabbitmq.stream.Message) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Random(java.util.Random) TestUtils.streamName(com.rabbitmq.stream.impl.TestUtils.streamName) AuthenticationFailureException(com.rabbitmq.stream.AuthenticationFailureException) AfterAll(org.junit.jupiter.api.AfterAll) StreamException(com.rabbitmq.stream.StreamException) ExtendWith(org.junit.jupiter.api.extension.ExtendWith) BeforeAll(org.junit.jupiter.api.BeforeAll) ConsumerBuilder(com.rabbitmq.stream.ConsumerBuilder) Duration(java.time.Duration) Map(java.util.Map) Host(com.rabbitmq.stream.Host) TestUtils.waitAtMost(com.rabbitmq.stream.impl.TestUtils.waitAtMost) Collection(java.util.Collection) UUID(java.util.UUID) Collectors(java.util.stream.Collectors) NioEventLoopGroup(io.netty.channel.nio.NioEventLoopGroup) StandardCharsets(java.nio.charset.StandardCharsets) TestInfo(org.junit.jupiter.api.TestInfo) BackOffDelayPolicy(com.rabbitmq.stream.BackOffDelayPolicy) Test(org.junit.jupiter.api.Test) CountDownLatch(java.util.concurrent.CountDownLatch) List(java.util.List) StreamCreator(com.rabbitmq.stream.StreamCreator) SslHandler(io.netty.handler.ssl.SslHandler) ProducerBuilder(com.rabbitmq.stream.ProducerBuilder) Constants(com.rabbitmq.stream.Constants) OffsetSpecification(com.rabbitmq.stream.OffsetSpecification) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) IntStream(java.util.stream.IntStream) SSLParameters(javax.net.ssl.SSLParameters) StreamMetadata(com.rabbitmq.stream.impl.Client.StreamMetadata) TestUtils.latchAssert(com.rabbitmq.stream.impl.TestUtils.latchAssert) Address(com.rabbitmq.stream.Address) ConfirmationHandler(com.rabbitmq.stream.ConfirmationHandler) Assertions.assertThatThrownBy(org.assertj.core.api.Assertions.assertThatThrownBy) EnvironmentInfo(com.rabbitmq.stream.impl.MonitoringTestUtils.EnvironmentInfo) ConnectException(java.net.ConnectException) ChannelCustomizer(com.rabbitmq.stream.ChannelCustomizer) ValueSource(org.junit.jupiter.params.provider.ValueSource) EventLoopGroup(io.netty.channel.EventLoopGroup) Environment(com.rabbitmq.stream.Environment) Consumer(com.rabbitmq.stream.Consumer) Producer(com.rabbitmq.stream.Producer) EnvironmentBuilder(com.rabbitmq.stream.EnvironmentBuilder) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) DisabledIfTlsNotEnabled(com.rabbitmq.stream.impl.TestUtils.DisabledIfTlsNotEnabled) Collections(java.util.Collections) SECONDS(java.util.concurrent.TimeUnit.SECONDS) TestUtils.localhost(com.rabbitmq.stream.impl.TestUtils.localhost) TestUtils.localhostTls(com.rabbitmq.stream.impl.TestUtils.localhostTls) SSLParameters(javax.net.ssl.SSLParameters) SNIHostName(javax.net.ssl.SNIHostName) ChannelCustomizer(com.rabbitmq.stream.ChannelCustomizer) SslHandler(io.netty.handler.ssl.SslHandler) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) DisabledIfTlsNotEnabled(com.rabbitmq.stream.impl.TestUtils.DisabledIfTlsNotEnabled)

Aggregations

EnvironmentBuilder (com.rabbitmq.stream.EnvironmentBuilder)12 BeforeEach (org.junit.jupiter.api.BeforeEach)6 Test (org.junit.jupiter.api.Test)5 ConnectionFactory (com.rabbitmq.client.ConnectionFactory)3 Address (com.rabbitmq.stream.Address)2 ChannelCustomizer (com.rabbitmq.stream.ChannelCustomizer)2 ConfirmationHandler (com.rabbitmq.stream.ConfirmationHandler)2 Constants (com.rabbitmq.stream.Constants)2 Consumer (com.rabbitmq.stream.Consumer)2 ConsumerBuilder (com.rabbitmq.stream.ConsumerBuilder)2 Environment (com.rabbitmq.stream.Environment)2 OffsetSpecification (com.rabbitmq.stream.OffsetSpecification)2 Producer (com.rabbitmq.stream.Producer)2 ProducerBuilder (com.rabbitmq.stream.ProducerBuilder)2 StreamCreator (com.rabbitmq.stream.StreamCreator)2 StreamException (com.rabbitmq.stream.StreamException)2 SslHandler (io.netty.handler.ssl.SslHandler)2 RateLimiter (com.google.common.util.concurrent.RateLimiter)1 AddressResolver (com.rabbitmq.stream.AddressResolver)1 AuthenticationFailureException (com.rabbitmq.stream.AuthenticationFailureException)1