aboutsummaryrefslogtreecommitdiffstats
path: root/base/http/provider/src/test/java/org/onap/ccsdk/sli/adaptors/base/http/AbstractHttpAdapterTest.java
blob: d0973d90e0d34f8c888f7fa98bbf221f94c9bf88 (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
package org.onap.ccsdk.sli.adaptors.base.http;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;

import java.util.Properties;
import java.util.Set;

import javax.ws.rs.client.Client;

import org.junit.Test;

public class AbstractHttpAdapterTest {
    
    public class TestAdapter extends AbstractHttpAdapter {

    }
    
    @Test
    public void checkTimeouts() throws Exception {
        TestAdapter adapter = new TestAdapter();
        Client client = adapter.getClientBuilder().build();
        assertNotNull(client.getConfiguration().getProperty("jersey.config.client.readTimeout"));
        assertNotNull(client.getConfiguration().getProperty("jersey.config.client.connectTimeout"));
    }
    
    @Test
    public void propertiesTest() throws Exception {
        System.setProperty(AbstractHttpAdapter.SDNC_CONFIG_DIR, "src/test/resources/");
        TestAdapter adapter = new TestAdapter();
        Properties props = adapter.getProperties("testprops.properties");
        assertNotNull(props);
        assertEquals("world", props.get("hello"));
    }
    
    @Test
    public void basicAuthFilter() throws Exception {
        TestAdapter adapter = new TestAdapter();
        adapter.addBasicAuthCredentials("hello", "world");
        Set<Object> objs = adapter.getClientBuilder().getConfiguration().getInstances();
        assertEquals(BasicAuthFilter.class,objs.iterator().next().getClass());
    }

}