2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.openecomp.sdc;
23 import org.junit.Before;
24 import org.junit.Test;
25 import org.openecomp.sdc.be.config.ErrorConfiguration;
26 import org.openecomp.sdc.be.config.ErrorInfo;
27 import org.openecomp.sdc.common.api.BasicConfiguration;
28 import org.openecomp.sdc.common.api.ConfigurationListener;
29 import org.openecomp.sdc.common.api.ConfigurationSource;
30 import org.openecomp.sdc.common.api.FileChangeCallback;
31 import org.openecomp.sdc.common.impl.ExternalConfiguration;
32 import org.openecomp.sdc.common.impl.FSConfigurationSource;
33 import org.slf4j.Logger;
34 import org.slf4j.LoggerFactory;
38 import static org.junit.Assert.assertTrue;
40 public class ErrorConfigurationTest {
41 ConfigurationSource configurationSource = null;
42 private static final Logger log = LoggerFactory.getLogger(ErrorConfigurationTest.class);
47 ExternalConfiguration.setAppName("catalog-be");
48 ExternalConfiguration.setConfigDir("src/test/resources/config");
49 ExternalConfiguration.listenForChanges();
51 configurationSource = new FSConfigurationSource(ExternalConfiguration.getChangeListener(), ExternalConfiguration.getConfigDir() + File.separator + ExternalConfiguration.getAppName());
56 public void testReadConfigurationFile() {
58 ConfigurationListener configurationListener = new ConfigurationListener(ErrorConfiguration.class, new FileChangeCallback() {
60 public void reconfigure(BasicConfiguration obj) {
61 // TODO Auto-generated method stub
62 log.debug("In reconfigure of {}", obj);
67 ErrorConfiguration testConfiguration = configurationSource.getAndWatchConfiguration(ErrorConfiguration.class, configurationListener);
69 assertTrue(testConfiguration != null);
70 ErrorInfo errorInfo = testConfiguration.getErrorInfo("USER_NOT_FOUND");
71 assertTrue(errorInfo != null);
72 log.debug("{}", testConfiguration);
73 log.debug("{}", errorInfo);