2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.onap.vid.asdc;
23 import java.io.IOException;
24 import java.io.InputStream;
26 import java.net.URISyntaxException;
27 import java.util.Properties;
29 import javax.net.ssl.HostnameVerifier;
30 import javax.net.ssl.SSLSession;
31 import javax.ws.rs.client.Client;
32 import javax.ws.rs.client.ClientBuilder;
34 import org.junit.Before;
35 import org.junit.Ignore;
36 import org.junit.Test;
37 import org.onap.vid.asdc.rest.RestfulAsdcClient;
40 * The Class RestfulClientTest.
43 public class RestfulClientTest extends BaseClientTest {
45 /** The rest client. */
46 private Client restClient;
51 /** The properties. */
52 private Properties properties;
60 * @throws URISyntaxException the URI syntax exception
61 * @throws IOException Signals that an I/O exception has occurred.
64 public void setUp() throws URISyntaxException, IOException {
65 final InputStream propertiesFile = getClass().getClassLoader().getResourceAsStream("asdc.properties");
67 properties = new Properties();
68 properties.load(propertiesFile);
70 final String protocol = properties.getProperty("protocol", "http");
72 restClient = ClientBuilder.newBuilder()
73 .hostnameVerifier(new HostnameVerifier() {
76 public boolean verify(String arg0, SSLSession arg1) {
81 uri = new URI(protocol + "://" + properties.getProperty("host", "localhost") + ":" + properties.getProperty("port", "80") + "/");
82 auth = properties.getProperty("auth");
88 * @throws AsdcCatalogException the asdc catalog exception
91 public void testResources() throws AsdcCatalogException {
93 runResourceTests(new RestfulAsdcClient.Builder(restClient, uri).auth(auth).build());
99 * @throws AsdcCatalogException the asdc catalog exception
100 * @throws URISyntaxException the URI syntax exception
103 public void testServices() throws AsdcCatalogException, URISyntaxException {
105 runServiceTests(new RestfulAsdcClient.Builder(restClient, uri).auth(auth).build());