2 * ============LICENSE_START====================================================
4 * ===========================================================================
5 * Copyright (c) 2018 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====================================================
22 package org.onap.aaf.auth.hello.test;
24 import java.net.ConnectException;
25 import java.net.HttpURLConnection;
27 import java.net.URISyntaxException;
29 import org.onap.aaf.auth.common.Define;
30 import org.onap.aaf.cadi.CadiException;
31 import org.onap.aaf.cadi.LocatorException;
32 import org.onap.aaf.cadi.PropAccess;
33 import org.onap.aaf.cadi.aaf.v2_0.AAFConHttp;
34 import org.onap.aaf.cadi.aaf.v2_0.AAFLocator;
35 import org.onap.aaf.cadi.client.Future;
36 import org.onap.aaf.cadi.client.Rcli;
37 import org.onap.aaf.cadi.client.Retryable;
38 import org.onap.aaf.cadi.config.SecurityInfoC;
39 import org.onap.aaf.misc.env.APIException;
41 public class HelloTester {
43 public static void main(String[] args) {
44 // Do Once and ONLY once
45 PropAccess access = new PropAccess(args);
48 String uriPrefix = access.getProperty("locatorURI","https://aaftest.test.att.com");
50 SecurityInfoC<HttpURLConnection> si = SecurityInfoC.instance(access, HttpURLConnection.class);
51 AAFLocator loc = new AAFLocator(si,new URI(uriPrefix+"/locate/"+Define.ROOT_NS()+".hello:1.0"));
52 AAFConHttp aafcon = new AAFConHttp(access,loc,si);
55 String pathinfo = "/hello";
56 final int iterations = Integer.parseInt(access.getProperty("iterations","5"));
57 System.out.println("Calling " + loc + " with Path " + pathinfo + ' ' + iterations + " time" + (iterations==1?"":"s"));
58 for(int i=0;i<iterations;++i) {
59 aafcon.best(new Retryable<Void> () {
61 public Void code(Rcli<?> client) throws CadiException, ConnectException, APIException {
62 Future<String> fs = client.read("/hello","text/plain");
64 System.out.print(fs.body());
66 System.err.println("Ooops, missed one: " + fs.code() + ": " + fs.body());
74 } catch (CadiException | LocatorException | URISyntaxException | APIException | InterruptedException e) {