Search in sources :

Example 1 with StreamParametersBuilder

use of com.rabbitmq.stream.impl.Client.StreamParametersBuilder in project rabbitmq-stream-java-client by rabbitmq.

the class ClientTest method createStreamWithDifferentParametersShouldThrowException.

@Test
void createStreamWithDifferentParametersShouldThrowException(TestInfo info) {
    String s = streamName(info);
    Client client = cf.get();
    try {
        StreamParametersBuilder streamParametersBuilder = new StreamParametersBuilder().maxAge(Duration.ofDays(1));
        Response response = client.create(s, streamParametersBuilder.build());
        assertThat(response.isOk()).isTrue();
        response = client.create(s, streamParametersBuilder.maxAge(Duration.ofDays(4)).build());
        assertThat(response.isOk()).isFalse();
        assertThat(response.getResponseCode()).isEqualTo(Constants.RESPONSE_CODE_PRECONDITION_FAILED);
    } finally {
        assertThat(client.delete(s).isOk()).isTrue();
    }
}
Also used : StreamParametersBuilder(com.rabbitmq.stream.impl.Client.StreamParametersBuilder) Response(com.rabbitmq.stream.impl.Client.Response) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 2 with StreamParametersBuilder

use of com.rabbitmq.stream.impl.Client.StreamParametersBuilder in project rabbitmq-stream-java-client by rabbitmq.

the class StreamPerfTestTest method streamCreationIsIdempotentWhateverTheDifferencesInStreamProperties.

@Test
void streamCreationIsIdempotentWhateverTheDifferencesInStreamProperties() throws Exception {
    Response response = client.create(s, new StreamParametersBuilder().maxLengthBytes(ByteCapacity.GB(1)).maxSegmentSizeBytes(ByteCapacity.MB(500)).leaderLocator(LeaderLocator.LEAST_LEADERS).build());
    assertThat(response.isOk()).isTrue();
    Future<?> run = run(builder().maxLengthBytes(// different than already existing stream
    ByteCapacity.GB(42)).streamMaxSegmentSizeBytes(ByteCapacity.MB(500)).leaderLocator(LeaderLocator.LEAST_LEADERS));
    waitOneSecond();
    run.cancel(true);
    waitRunEnds();
    assertThat(consoleOutput()).contains("Warning: stream '" + s + "'");
}
Also used : Response(com.rabbitmq.stream.impl.Client.Response) StreamParametersBuilder(com.rabbitmq.stream.impl.Client.StreamParametersBuilder) Test(org.junit.jupiter.api.Test)

Aggregations

Response (com.rabbitmq.stream.impl.Client.Response)2 StreamParametersBuilder (com.rabbitmq.stream.impl.Client.StreamParametersBuilder)2 Test (org.junit.jupiter.api.Test)2 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)1