Standalone TCA with EELF Logger
[dcaegen2/analytics/tca-gen2.git] / dcae-analytics / dcae-analytics-web / src / test / java / org / onap / dcae / analytics / web / spring / ConfigBindingServiceEnvironmentPostProcessorIT.java
1 /*
2  * ================================================================================
3  * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
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
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
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.
16  * ============LICENSE_END=========================================================
17  *
18  */
19
20 package org.onap.dcae.analytics.web.spring;
21
22 import static org.onap.dcae.analytics.model.configbindingservice.ConfigBindingServiceConstants
23         .CONFIG_BINDING_SERVICE_ENV_VARIABLE_KEY;
24 import static org.onap.dcae.analytics.model.configbindingservice.ConfigBindingServiceConstants
25         .CONFIG_BINDING_SERVICE_PROPERTIES_KEY;
26 import static org.onap.dcae.analytics.model.configbindingservice.ConfigBindingServiceConstants
27         .CONSUL_HOST_ENV_VARIABLE_KEY;
28 import static org.onap.dcae.analytics.model.configbindingservice.ConfigBindingServiceConstants
29         .SERVICE_NAME_ENV_VARIABLE_KEY;
30
31 import java.util.HashMap;
32 import java.util.Map;
33
34 import org.junit.jupiter.api.BeforeAll;
35 import org.junit.jupiter.api.Disabled;
36 import org.junit.jupiter.api.Test;
37 import org.onap.dcae.analytics.model.AnalyticsProfile;
38 import org.onap.dcae.analytics.web.BaseAnalyticsWebSpringBootIT;
39 import org.springframework.beans.factory.annotation.Autowired;
40 import org.springframework.core.env.AbstractEnvironment;
41 import org.springframework.core.env.Environment;
42 import org.springframework.core.env.MapPropertySource;
43 import org.springframework.core.env.PropertySource;
44 import org.springframework.test.context.ActiveProfiles;
45
46 /**
47  * @author Rajiv Singla
48  */
49 @ActiveProfiles(value = {AnalyticsProfile.CONFIG_BINDING_SERVICE_PROFILE_NAME}, inheritProfiles = false)
50 @Disabled
51 class ConfigBindingServiceEnvironmentPostProcessorIT extends BaseAnalyticsWebSpringBootIT {
52
53     @BeforeAll
54     static void beforeAll() throws Exception {
55         // sets up environment variables for testing purposes
56         final HashMap<String, String> testEnvironmentVariables = new HashMap<>();
57         final String testConsulHostValue = "localhost";
58         final String testConfigBindingService = "config_binding_service";
59         final String testServiceName = "tca_dev";
60         testEnvironmentVariables.put(CONSUL_HOST_ENV_VARIABLE_KEY, testConsulHostValue);
61         testEnvironmentVariables.put(CONFIG_BINDING_SERVICE_ENV_VARIABLE_KEY, testConfigBindingService);
62         testEnvironmentVariables.put(SERVICE_NAME_ENV_VARIABLE_KEY, testServiceName);
63         setEnvironmentVariables(testEnvironmentVariables);
64     }
65
66     @Autowired
67     private Environment environment;
68
69     @Test
70     void postProcessEnvironment() {
71
72         final Map<String, Object> properties = new HashMap<>();
73         for (final PropertySource<?> propertySource : ((AbstractEnvironment) environment).getPropertySources()) {
74             if (propertySource.getName().equals(CONFIG_BINDING_SERVICE_PROPERTIES_KEY)) {
75                 properties.putAll(((MapPropertySource) propertySource).getSource());
76             }
77         }
78         properties.forEach((key, value) -> logger.debug("{} -> {}", key, value));
79
80     }
81
82 }