summaryrefslogtreecommitdiffstats
path: root/src/test/java/org/onap/aai/validation/config/TestRestConfig.java
blob: 0c632ee5345a4700783aec2c2757e87f756f5f6a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/*
 * ============LICENSE_START===================================================
 * Copyright (c) 2018 Amdocs
 * ============================================================================
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *        http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * ============LICENSE_END=====================================================
 */
package org.onap.aai.validation.config;

import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;

import javax.inject.Inject;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath:/rest-config/test-validation-service-beans.xml"})
public class TestRestConfig {

    static {
        System.setProperty("APP_HOME", ".");
    }

    @Inject
    private RestConfig restConfig;

    @Test
    public void testRestConfigPopulation() throws Exception {
        RestConfig expectedRestConfig = new RestConfig();

        expectedRestConfig.setHost("localhost");
        expectedRestConfig.setPort(8080);
        expectedRestConfig.setProtocol("https");
        expectedRestConfig.setBaseModelURI("${baseModelURI}");
        expectedRestConfig.setTrustStorePath("/dir1/dir2/trustStorePath");
        expectedRestConfig.setTrustStorePassword("OBF:1i9a1u2a1unz1lr61wn51wn11lss1unz1u301i6o");
        expectedRestConfig.setKeyStorePath("/dir1/dir2/keyStorePath");
        expectedRestConfig.setKeyStorePassword("OBF:1i9a1u2a1unz1lr61wn51wn11lss1unz1u301i6o");
        expectedRestConfig.setKeyManagerFactoryAlgorithm("AES");
        expectedRestConfig.setKeyStoreType("jks");
        expectedRestConfig.setSecurityProtocol("TLS");
        expectedRestConfig.setConnectionTimeout(100);
        expectedRestConfig.setReadTimeout(200);

        assertThat(expectedRestConfig, is(restConfig));
        assertThat(expectedRestConfig.getBaseModelURI(), is(restConfig.getBaseModelURI()));
        assertThat(expectedRestConfig.getConnectionTimeout(), is(restConfig.getConnectionTimeout()));
        assertThat(expectedRestConfig.getHost(), is(restConfig.getHost()));
        assertThat(expectedRestConfig.getKeyManagerFactoryAlgorithm(), is(restConfig.getKeyManagerFactoryAlgorithm()));
        assertThat(expectedRestConfig.getKeyStorePassword(), is(restConfig.getKeyStorePassword()));
        assertThat(expectedRestConfig.getKeyStorePath(), is(restConfig.getKeyStorePath()));
        assertThat(expectedRestConfig.getKeyStoreType(), is(restConfig.getKeyStoreType()));
        assertThat(expectedRestConfig.getPort(), is(restConfig.getPort()));
        assertThat(expectedRestConfig.getProtocol(), is(restConfig.getProtocol()));
        assertThat(expectedRestConfig.getReadTimeout(), is(restConfig.getReadTimeout()));
        assertThat(expectedRestConfig.getSecurityProtocol(), is(restConfig.getSecurityProtocol()));
        assertThat(expectedRestConfig.getTrustStorePassword(), is(restConfig.getTrustStorePassword()));
        assertThat(expectedRestConfig.getTrustStorePath(), is(restConfig.getTrustStorePath()));
        assertThat(expectedRestConfig.hashCode(), is(restConfig.hashCode()));
        assertThat(expectedRestConfig.toString(), is(restConfig.toString()));
        assertTrue(expectedRestConfig.equals(restConfig));

    }
}