java调用fsgui的接口示例
package cn.dreampie.example; import cn.dreampie.client.HttpClientRequest; import cn.dreampie.client.HttpClient; import cn.dreampie.client.HttpClientResult; import cn.dreampie.client.HttpClientUser; import cn.dreampie.common.util.json.Jsoner; import org.junit.Before; import org.junit.FixMethodOrder; import org.junit.Test; import org.junit.runners.MethodSorters; import java.io.FileNotFoundException; import java.util.ArrayList; import java.util.HashMap;
@FixMethodOrder(MethodSorters.JVM)
public class HttpClientTest {
private HttpClient httpClient;
public main(){
Client httpClient = new Client("http://ip:8085/api"); ClientRequest postRequest = new ClientRequest("/login");
postRequest.setJsonParam("{\"username\": \"admin\", \"password\": \"admin\"}") ;
ClientResult postResult = httpClient.build(postRequest).post(); String json = postResult.getResult() ;
DemoToKen token = FasterJsonTool.readValue(json, DemoToKen.class) ;
System.out.println(token.getToken());
ClientRequest postRequest1 = new ClientRequest("/get_uuid"); Map<String, String> headers = new HashMap<>() ;
headers.put("Authorization", "Nway " + token.getToken()) ;
postRequest1.setHeaders(headers) ;
System.out.println(httpClient.build(postRequest1).get().getResult());
}
}