1 package org.onap.aai.sparky.dal.rest.config;
3 import static org.junit.Assert.assertEquals;
4 import static org.junit.Assert.assertNotNull;
5 import static org.junit.Assert.assertNull;
6 import static org.junit.Assert.assertTrue;
8 import org.junit.Before;
11 import org.onap.aai.restclient.enums.RestAuthenticationMode;
13 public class RestEndpointConfigTest {
15 private RestEndpointConfig restEndpointConfig;
17 public void init() throws Exception{
19 restEndpointConfig = new RestEndpointConfig();
25 public void updateValues(){
26 restEndpointConfig.setValidateServerCertChain(true);
27 assertTrue(restEndpointConfig.isValidateServerCertChain());
28 restEndpointConfig.setValidateServerHostname(true);
29 assertTrue(restEndpointConfig.isValidateServerHostname());
30 restEndpointConfig.setEndpointIpAddress("10.147.110.199");
31 assertNotNull(restEndpointConfig.getEndpointIpAddress());
32 restEndpointConfig.setEndpointServerPort("9885");
33 assertNotNull(restEndpointConfig.getEndpointServerPort());
34 restEndpointConfig.setNumRequestRetries(5);
35 assertEquals(restEndpointConfig.getNumRequestRetries(),5);
36 restEndpointConfig.setBasicAuthUserName("sparky");
37 assertNotNull(restEndpointConfig.getBasicAuthUserName());
38 restEndpointConfig.setBasicAuthPassword("sparky");
39 assertNotNull(restEndpointConfig.getBasicAuthPassword());
40 restEndpointConfig.setRestAuthenticationMode(RestAuthenticationMode.SSL_BASIC);
41 assertEquals(restEndpointConfig.getRestAuthenticationMode(),RestAuthenticationMode.SSL_BASIC);
42 restEndpointConfig.setConnectTimeoutInMs(6000);
43 assertEquals(restEndpointConfig.getConnectTimeoutInMs(),6000);
44 restEndpointConfig.setCertFileName("aai-client-cert.p12");
45 assertNotNull(restEndpointConfig.getCertFileName());
46 restEndpointConfig.setReadTimeoutInMs(4000);
47 assertEquals(restEndpointConfig.getReadTimeoutInMs(),4000);
48 restEndpointConfig.setCertPassword("1i9a1u2a1unz1lr61wn51wn11lss1unz1u301i6o");
49 assertNotNull(restEndpointConfig.getCertPassword());
50 restEndpointConfig.setTruststoreFileName("synchronizer.jks");
51 assertNotNull(restEndpointConfig.getTruststoreFileName());
52 assertNotNull(restEndpointConfig.toString());
54 restEndpointConfig.setEndpointIpAddress(null);
55 assertNull(restEndpointConfig.getEndpointIpAddress());
56 restEndpointConfig.setEndpointServerPort(null);
57 assertNull(restEndpointConfig.getEndpointServerPort());
58 restEndpointConfig.setCertFileName(null);
59 assertNull(restEndpointConfig.getCertFileName());
60 restEndpointConfig.setTruststoreFileName(null);
61 assertNull(restEndpointConfig.getTruststoreFileName());
62 restEndpointConfig.setRestAuthenticationMode(null);
63 assertNull(restEndpointConfig.getRestAuthenticationMode());
64 restEndpointConfig.setCertPassword(null);
65 assertNull(restEndpointConfig.getCertPassword());
66 restEndpointConfig.setBasicAuthUserName(null);
67 assertNull(restEndpointConfig.getBasicAuthUserName());
68 restEndpointConfig.setBasicAuthPassword(null);
69 assertNull(restEndpointConfig.getBasicAuthPassword());
70 assertNotNull(restEndpointConfig.toString());