|
| 1 | +/** |
| 2 | + * Copyright (c) 2013-2026 Nikita Koksharov |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | +package org.redisson.transaction; |
| 17 | + |
| 18 | +import org.junit.jupiter.api.Test; |
| 19 | +import org.redisson.api.TransactionOptions; |
| 20 | + |
| 21 | +import java.util.concurrent.TimeUnit; |
| 22 | + |
| 23 | +import static org.assertj.core.api.Assertions.assertThat; |
| 24 | + |
| 25 | +public class RedissonTransactionSyncSlavesTest { |
| 26 | + |
| 27 | + @Test |
| 28 | + public void testTransactionOptionsSyncSlaves() { |
| 29 | + TransactionOptions options = TransactionOptions.defaults() |
| 30 | + .syncSlaves(3, 10, TimeUnit.SECONDS); |
| 31 | + |
| 32 | + assertThat(options.getSyncSlaves()).isEqualTo(3); |
| 33 | + assertThat(options.getSyncTimeout()).isEqualTo(10000L); |
| 34 | + |
| 35 | + TransactionOptions optionsCopy = TransactionOptions.defaults() |
| 36 | + .syncSlaves(3, 10, TimeUnit.SECONDS); |
| 37 | + assertThat(options).isEqualTo(optionsCopy); |
| 38 | + assertThat(options.hashCode()).isEqualTo(optionsCopy.hashCode()); |
| 39 | + |
| 40 | + TransactionOptions noSync = TransactionOptions.defaults() |
| 41 | + .syncSlaves(-1, 5, TimeUnit.SECONDS); |
| 42 | + assertThat(noSync.getSyncSlaves()).isEqualTo(-1); |
| 43 | + } |
| 44 | + |
| 45 | +} |
0 commit comments