|
| 1 | +/* |
| 2 | + * Copyright (C) 2015 Red Hat, Inc. |
| 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 io.fabric8.kubernetes.client; |
| 17 | + |
| 18 | +import org.junit.jupiter.api.Test; |
| 19 | + |
| 20 | +import static org.assertj.core.api.Assertions.assertThat; |
| 21 | + |
| 22 | +class ConfigBuilderTest { |
| 23 | + |
| 24 | + @Test |
| 25 | + void withPrimitiveValues() { |
| 26 | + final ConfigBuilder configBuilder = new ConfigBuilder() |
| 27 | + .withAutoConfigure(false) |
| 28 | + .withTrustCerts(true) |
| 29 | + .withDisableHostnameVerification(true) |
| 30 | + .withWebsocketPingInterval(133701) |
| 31 | + .withConnectionTimeout(133702) |
| 32 | + .withMaxConcurrentRequests(133703) |
| 33 | + .withWatchReconnectInterval(133704) |
| 34 | + .withWatchReconnectLimit(133705) |
| 35 | + .withUploadRequestTimeout(133706) |
| 36 | + .withRequestRetryBackoffLimit(133707) |
| 37 | + .withRequestRetryBackoffInterval(133708) |
| 38 | + .withRequestTimeout(133709) |
| 39 | + .withScaleTimeout(133710) |
| 40 | + .withLoggingInterval(133711) |
| 41 | + .withHttp2Disable(true) |
| 42 | + .withOnlyHttpWatches(true); |
| 43 | + assertThat(configBuilder.build()) |
| 44 | + .hasFieldOrPropertyWithValue("autoConfigure", Boolean.FALSE) |
| 45 | + .hasFieldOrPropertyWithValue("trustCerts", Boolean.TRUE) |
| 46 | + .hasFieldOrPropertyWithValue("disableHostnameVerification", Boolean.TRUE) |
| 47 | + .hasFieldOrPropertyWithValue("websocketPingInterval", 133701L) |
| 48 | + .hasFieldOrPropertyWithValue("connectionTimeout", 133702) |
| 49 | + .hasFieldOrPropertyWithValue("maxConcurrentRequests", 133703) |
| 50 | + .hasFieldOrPropertyWithValue("watchReconnectInterval", 133704) |
| 51 | + .hasFieldOrPropertyWithValue("watchReconnectLimit", 133705) |
| 52 | + .hasFieldOrPropertyWithValue("uploadRequestTimeout", 133706) |
| 53 | + .hasFieldOrPropertyWithValue("requestRetryBackoffLimit", 133707) |
| 54 | + .hasFieldOrPropertyWithValue("requestRetryBackoffInterval", 133708) |
| 55 | + .hasFieldOrPropertyWithValue("requestTimeout", 133709) |
| 56 | + .hasFieldOrPropertyWithValue("scaleTimeout", 133710L) |
| 57 | + .hasFieldOrPropertyWithValue("loggingInterval", 133711) |
| 58 | + .hasFieldOrPropertyWithValue("http2Disable", Boolean.TRUE) |
| 59 | + .hasFieldOrPropertyWithValue("onlyHttpWatches", Boolean.TRUE); |
| 60 | + } |
| 61 | + |
| 62 | + @Test |
| 63 | + void withBoxedValues() { |
| 64 | + final ConfigBuilder configBuilder = new ConfigBuilder() |
| 65 | + .withAutoConfigure(Boolean.FALSE) |
| 66 | + .withTrustCerts(Boolean.TRUE) |
| 67 | + .withDisableHostnameVerification(Boolean.TRUE) |
| 68 | + .withWebsocketPingInterval(Long.valueOf(133701)) |
| 69 | + .withConnectionTimeout(Integer.valueOf(133702)) |
| 70 | + .withMaxConcurrentRequests(Integer.valueOf(133703)) |
| 71 | + .withWatchReconnectInterval(Integer.valueOf(133704)) |
| 72 | + .withWatchReconnectLimit(Integer.valueOf(133705)) |
| 73 | + .withUploadRequestTimeout(Integer.valueOf(133706)) |
| 74 | + .withRequestRetryBackoffLimit(Integer.valueOf(133707)) |
| 75 | + .withRequestRetryBackoffInterval(Integer.valueOf(133708)) |
| 76 | + .withRequestTimeout(Integer.valueOf(133709)) |
| 77 | + .withScaleTimeout(Long.valueOf(133710)) |
| 78 | + .withLoggingInterval(Integer.valueOf(133711)) |
| 79 | + .withHttp2Disable(Boolean.TRUE) |
| 80 | + .withOnlyHttpWatches(Boolean.TRUE); |
| 81 | + assertThat(configBuilder.build()) |
| 82 | + .hasFieldOrPropertyWithValue("autoConfigure", false) |
| 83 | + .hasFieldOrPropertyWithValue("trustCerts", true) |
| 84 | + .hasFieldOrPropertyWithValue("disableHostnameVerification", true) |
| 85 | + .hasFieldOrPropertyWithValue("websocketPingInterval", 133701L) |
| 86 | + .hasFieldOrPropertyWithValue("connectionTimeout", 133702) |
| 87 | + .hasFieldOrPropertyWithValue("maxConcurrentRequests", 133703) |
| 88 | + .hasFieldOrPropertyWithValue("watchReconnectInterval", 133704) |
| 89 | + .hasFieldOrPropertyWithValue("watchReconnectLimit", 133705) |
| 90 | + .hasFieldOrPropertyWithValue("uploadRequestTimeout", 133706) |
| 91 | + .hasFieldOrPropertyWithValue("requestRetryBackoffLimit", 133707) |
| 92 | + .hasFieldOrPropertyWithValue("requestRetryBackoffInterval", 133708) |
| 93 | + .hasFieldOrPropertyWithValue("requestTimeout", 133709) |
| 94 | + .hasFieldOrPropertyWithValue("scaleTimeout", 133710L) |
| 95 | + .hasFieldOrPropertyWithValue("loggingInterval", 133711) |
| 96 | + .hasFieldOrPropertyWithValue("http2Disable", true) |
| 97 | + .hasFieldOrPropertyWithValue("onlyHttpWatches", true); |
| 98 | + } |
| 99 | + |
| 100 | +} |
0 commit comments