美文网首页java8
接口自动化封装调接口类

接口自动化封装调接口类

作者: info_gu | 来源:发表于2020-06-09 15:18 被阅读0次

package com.nuanshui.frms.test.utils.http;

import io.restassured.response.Response;
import io.restassured.response.ValidatableResponse;

import java.net.URL;

import static io.restassured.RestAssured.given;
import static io.restassured.RestAssured.useRelaxedHTTPSValidation;

public class RequestUtil {
public static Response sendpostWithHttp(String surl, String token,String str) throws Exception{
String msg=null;
URL url = new URL(surl);
Response response = given().log().all().
header("accept", "application/json",
"token",token).
contentType("application/json").
body(str).
then().
when().
post(url);
response.getBody().prettyPrint();

    return response;
}
public static ValidatableResponse sendgetWithHttp(String surl,String token, String str) throws Exception{
    URL url = new URL(surl);
    ValidatableResponse response = given()
            .header("token",token)
            .log().all()
            .queryParam(str)
            .when()
            .get(surl)
            .then()
            .log().all();
    return response;
}
public static Response sendpostWithHttps(String surl,String token, String str) throws Exception{
    URL url = new URL(surl);
    useRelaxedHTTPSValidation();
    Response response = given().log().all().
            header("accept", "application/json",
                    "token",token).
            contentType("application/json").
            body(str).
            then().
            statusCode(200).
            when().
            post(url);
    response.getBody().prettyPrint();
    return response;
}
public static ValidatableResponse sendgetWithHttps(String surl,String token, String str) throws Exception{
    URL url = new URL(surl);
    useRelaxedHTTPSValidation();
    ValidatableResponse response = given()
            .header("token",token)
            .log().all()
            .queryParam(str)
            .when()
            .get(surl)
            .then()
            .log().all()
            .statusCode(200);
    return response;
}

}

相关文章

  • 接口自动化封装调接口类

    package com.nuanshui.frms.test.utils.http; import io.rest...

  • HttpURLConnection访问网络

    一,封装在一个工具类 二,回调接口 三,调用

  • Java回调深入理解

    1 接口回调 1.1 接口回调概念 什么是接口回调接口回调是指:可以把使用某一接口的类创建的对象的引用赋给该接口声...

  • java回调函数

    利用接口来实现回调,即在调用回调函数的类中实现接口,并实现接口中的方法即回调的方法,被调用类中存在接口的熟悉,并将...

  • python之接口自动化测试

    接口自动化post方法操作步骤:1、common常用方法封装2、调用common中封装好的json接口 1、com...

  • Android Module之间数据传递

    方法一:使用接口回调 (1)在子module创建回调接口(参数可变) (2)在子module 实现类设置接口回调 ...

  • JMeter-接口自动化之正则表达式关联

    JMeter-接口自动化之正则表达式关联 jmeter中,接口自动化的关键在于参数关联。比如需要登录的接口,如何调...

  • Java 基础知识1-10

    1 接口的意义 规范(基于接口编程)、扩展(松耦合)、回调 2 抽象类的意义 为其子类提供一个公共的类型,封装子类...

  • 多线程Future设计模式的两种用法

    多线程Future设计模式 Future接口定义: Future接口的实现类: 封装任务的FutureTask接口...

  • Java到Android逐步理解接口回调

    一,什么是接口回调: 接口回调(自己理解):例如A.class这个类实现了某一接口(C),我们可以把创建A类对象的...

网友评论

    本文标题:接口自动化封装调接口类

    本文链接:https://www.haomeiwen.com/subject/fmnstktx.html