2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2023-2024 Nordix Foundation.
4 * ================================================================================
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
17 * SPDX-License-Identifier: Apache-2.0
18 * ============LICENSE_END=========================================================
21 package org.onap.cps.ncmp.api.impl.config
23 import org.springframework.beans.factory.annotation.Autowired
24 import org.springframework.boot.context.properties.EnableConfigurationProperties
25 import org.springframework.boot.test.context.SpringBootTest
26 import org.springframework.test.context.ContextConfiguration
27 import org.springframework.test.context.TestPropertySource
28 import spock.lang.Specification
31 @ContextConfiguration(classes = [HttpClientConfiguration])
32 @EnableConfigurationProperties(HttpClientConfiguration.class)
33 @TestPropertySource(properties = ["ncmp.dmi.httpclient.data-services.readTimeoutInSeconds=789", "ncmp.dmi.httpclient.model-services.maximumConnectionsTotal=111"])
34 class HttpClientConfigurationSpec extends Specification {
37 private HttpClientConfiguration httpClientConfiguration
39 def 'Test http client configuration properties of data with custom and default values'() {
40 expect: 'properties are populated correctly for data'
41 with(httpClientConfiguration.dataServices) {
42 assert connectionTimeoutInSeconds == 123
43 assert readTimeoutInSeconds == 789
44 assert writeTimeoutInSeconds == 30
45 assert maximumConnectionsTotal == 100
46 assert pendingAcquireMaxCount == 22
47 assert maximumInMemorySizeInMegabytes == 7
51 def 'Test http client configuration properties of model with custom and default values'() {
52 expect: 'properties are populated correctly for model'
53 with(httpClientConfiguration.modelServices) {
54 assert connectionTimeoutInSeconds == 456
55 assert readTimeoutInSeconds == 30
56 assert writeTimeoutInSeconds == 30
57 assert maximumConnectionsTotal == 111
58 assert pendingAcquireMaxCount == 44
59 assert maximumInMemorySizeInMegabytes == 8
63 def 'Test http client configuration properties of health with default values'() {
64 expect: 'properties are populated correctly for health'
65 with(httpClientConfiguration.healthCheckServices) {
66 assert connectionTimeoutInSeconds == 30
67 assert readTimeoutInSeconds == 30
68 assert writeTimeoutInSeconds == 30
69 assert maximumConnectionsTotal == 10
70 assert pendingAcquireMaxCount == 5
71 assert maximumInMemorySizeInMegabytes == 1