|
| 1 | +/* |
| 2 | + * Copyright 2012-2023 the original author or authors. |
| 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 | + * https://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 | + |
| 17 | +package org.springframework.boot.autoconfigure.amqp; |
| 18 | + |
| 19 | +import java.util.List; |
| 20 | + |
| 21 | +import org.junit.jupiter.api.Test; |
| 22 | + |
| 23 | +import org.springframework.boot.autoconfigure.amqp.RabbitConnectionDetails.Address; |
| 24 | + |
| 25 | +import static org.assertj.core.api.Assertions.assertThat; |
| 26 | + |
| 27 | +/** |
| 28 | + * Tests for {@link PropertiesRabbitConnectionDetails}. |
| 29 | + * |
| 30 | + * @author Jonas Fügedi |
| 31 | + */ |
| 32 | +class PropertiesRabbitConnectionDetailsTests { |
| 33 | + |
| 34 | + private static final int DEFAULT_PORT = 5672; |
| 35 | + |
| 36 | + @Test |
| 37 | + void getAddresses() { |
| 38 | + RabbitProperties properties = new RabbitProperties(); |
| 39 | + properties.setAddresses("localhost,localhost:1234,[::1],[::1]:32863"); |
| 40 | + PropertiesRabbitConnectionDetails propertiesRabbitConnectionDetails = new PropertiesRabbitConnectionDetails( |
| 41 | + properties); |
| 42 | + List<Address> addresses = propertiesRabbitConnectionDetails.getAddresses(); |
| 43 | + assertThat(addresses.size()).isEqualTo(4); |
| 44 | + assertThat(addresses.get(0).host()).isEqualTo("localhost"); |
| 45 | + assertThat(addresses.get(0).port()).isEqualTo(DEFAULT_PORT); |
| 46 | + assertThat(addresses.get(1).host()).isEqualTo("localhost"); |
| 47 | + assertThat(addresses.get(1).port()).isEqualTo(1234); |
| 48 | + assertThat(addresses.get(2).host()).isEqualTo("[::1]"); |
| 49 | + assertThat(addresses.get(2).port()).isEqualTo(DEFAULT_PORT); |
| 50 | + assertThat(addresses.get(3).host()).isEqualTo("[::1]"); |
| 51 | + assertThat(addresses.get(3).port()).isEqualTo(32863); |
| 52 | + } |
| 53 | + |
| 54 | +} |
0 commit comments