Add unit test for MSB JAVA SDK
[msb/java-sdk.git] / src / test / java / org / onap / msb / sdk / httpclient / conf / HttpClientConfTest.java
1 /**
2  * Copyright 2017 ZTE Corporation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5  * in compliance with the License. You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software distributed under the License
10  * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11  * or implied. See the License for the specific language governing permissions and limitations under
12  * the License.
13  */
14 package org.onap.msb.sdk.httpclient.conf;
15
16 import java.util.HashSet;
17 import java.util.Set;
18
19 import org.junit.Assert;
20 import org.junit.Test;
21
22 public class HttpClientConfTest {
23
24     @Test
25     public void testEquals() {
26         HttpClientConf conf1 = new HttpClientConf();
27         conf1.setConnectTimeout(100000);
28         conf1.setReadTimeout(200000);
29         conf1.setWriteTimeout(30000);
30
31         HttpClientConf conf2 = new HttpClientConf();
32         conf2.setConnectTimeout(100000);
33         conf2.setReadTimeout(200000);
34         conf2.setWriteTimeout(30000);
35
36         Assert.assertEquals(conf1, conf2);
37
38         conf2.setWriteTimeout(10000);
39         Assert.assertNotEquals(conf1, conf2);
40     }
41
42     @Test
43     public void testHashCode() {
44         HttpClientConf conf1 = new HttpClientConf();
45         conf1.setConnectTimeout(100000);
46         conf1.setReadTimeout(200000);
47         conf1.setWriteTimeout(30000);
48
49         HttpClientConf conf2 = new HttpClientConf();
50         conf2.setConnectTimeout(100000);
51         conf2.setReadTimeout(200000);
52         conf2.setWriteTimeout(30000);
53
54         Set set = new HashSet();
55         set.add(conf1);
56         set.add(conf2);
57
58         Assert.assertEquals(set.size(), 1);
59
60         HttpClientConf conf3 = new HttpClientConf();
61         conf3.setConnectTimeout(100000);
62         conf3.setReadTimeout(200000);
63         conf3.setWriteTimeout(10000);
64         set.add(conf3);
65         Assert.assertEquals(set.size(), 2);
66     }
67
68
69 }