2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
6 * Copyright © 2017-2018 Amdocs
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
22 package org.onap.aai.sparky.dal.rest.config;
24 import static org.junit.Assert.assertEquals;
25 import static org.junit.Assert.assertNotNull;
26 import static org.junit.Assert.assertNull;
27 import static org.junit.Assert.assertTrue;
29 import org.junit.Before;
30 import org.junit.Test;
32 import org.onap.aai.restclient.enums.RestAuthenticationMode;
34 public class RestEndpointConfigTest {
36 private RestEndpointConfig restEndpointConfig;
38 public void init() throws Exception{
40 restEndpointConfig = new RestEndpointConfig();
46 public void updateValues(){
47 restEndpointConfig.setValidateServerCertChain(true);
48 assertTrue(restEndpointConfig.isValidateServerCertChain());
49 restEndpointConfig.setValidateServerHostname(true);
50 assertTrue(restEndpointConfig.isValidateServerHostname());
51 restEndpointConfig.setEndpointIpAddress("10.147.110.199");
52 assertNotNull(restEndpointConfig.getEndpointIpAddress());
53 restEndpointConfig.setEndpointServerPort("9885");
54 assertNotNull(restEndpointConfig.getEndpointServerPort());
55 restEndpointConfig.setNumRequestRetries(5);
56 assertEquals(restEndpointConfig.getNumRequestRetries(),5);
57 restEndpointConfig.setBasicAuthUserName("sparky");
58 assertNotNull(restEndpointConfig.getBasicAuthUserName());
59 restEndpointConfig.setBasicAuthPassword("sparky");
60 assertNotNull(restEndpointConfig.getBasicAuthPassword());
61 restEndpointConfig.setRestAuthenticationMode(RestAuthenticationMode.SSL_BASIC);
62 assertEquals(restEndpointConfig.getRestAuthenticationMode(),RestAuthenticationMode.SSL_BASIC);
63 restEndpointConfig.setConnectTimeoutInMs(6000);
64 assertEquals(restEndpointConfig.getConnectTimeoutInMs(),6000);
65 restEndpointConfig.setCertFileName("aai-client-cert.p12");
66 assertNotNull(restEndpointConfig.getCertFileName());
67 restEndpointConfig.setReadTimeoutInMs(4000);
68 assertEquals(restEndpointConfig.getReadTimeoutInMs(),4000);
69 restEndpointConfig.setCertPassword("1i9a1u2a1unz1lr61wn51wn11lss1unz1u301i6o");
70 assertNotNull(restEndpointConfig.getCertPassword());
71 restEndpointConfig.setTruststoreFileName("synchronizer.jks");
72 assertNotNull(restEndpointConfig.getTruststoreFileName());
73 assertNotNull(restEndpointConfig.toString());
75 restEndpointConfig.setEndpointIpAddress(null);
76 assertNull(restEndpointConfig.getEndpointIpAddress());
77 restEndpointConfig.setEndpointServerPort(null);
78 assertNull(restEndpointConfig.getEndpointServerPort());
79 restEndpointConfig.setCertFileName(null);
80 assertNull(restEndpointConfig.getCertFileName());
81 restEndpointConfig.setTruststoreFileName(null);
82 assertNull(restEndpointConfig.getTruststoreFileName());
83 restEndpointConfig.setRestAuthenticationMode(null);
84 assertNull(restEndpointConfig.getRestAuthenticationMode());
85 restEndpointConfig.setCertPassword(null);
86 assertNull(restEndpointConfig.getCertPassword());
87 restEndpointConfig.setBasicAuthUserName(null);
88 assertNull(restEndpointConfig.getBasicAuthUserName());
89 restEndpointConfig.setBasicAuthPassword(null);
90 assertNull(restEndpointConfig.getBasicAuthPassword());
91 assertNotNull(restEndpointConfig.toString());