2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2022 Samsung Electronics
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.
19 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
20 * ============LICENSE_END=========================================================
23 package org.onap.ccsdk.sli.adaptors.resource.sql;
25 import static org.junit.Assert.assertNotNull;
26 import java.lang.reflect.Field;
28 import java.util.Properties;
30 import org.junit.Test;
32 public class SqlResourceProviderTest {
34 private static SqlResourcePropertiesProvider provider;
35 private static final String SDNC_CONFIG_DIR = "SDNC_CONFIG_DIR";
38 public void testSqlResourceProvider() {
40 Map<String, String> env = System.getenv();
41 Class<?> cl = env.getClass();
42 Field field = cl.getDeclaredField("m");
43 field.setAccessible(true);
44 Map<String, String> writableEnv = (Map<String, String>) field.get(env);
45 writableEnv.put(SDNC_CONFIG_DIR, "./src/test/resources");
46 } catch (Exception e) {
47 throw new IllegalStateException("Failed to set environment variable", e);
50 provider = new SqlResourcePropertiesProviderImpl();
51 assertNotNull(provider);
55 public void testGetProperties() {
56 Properties properties = provider.getProperties();
57 assertNotNull(properties);
61 public void testReportSuccess() {
63 Map<String, String> env = System.getenv();
64 Class<?> cl = env.getClass();
65 Field field = cl.getDeclaredField("m");
66 field.setAccessible(true);
67 Map<String, String> writableEnv = (Map<String, String>) field.get(env);
68 writableEnv.put(SDNC_CONFIG_DIR, "./src/test/resources");
69 } catch (Exception e) {
70 throw new IllegalStateException("Failed to set environment variable", e);
73 provider = new SqlResourcePropertiesProviderImpl();
74 Properties properties = provider.getProperties();
75 assertNotNull(properties);