当前位置: 首页>>代码示例>>Java>>正文


Java Response.getStatusCode方法代码示例

本文整理汇总了Java中io.restassured.response.Response.getStatusCode方法的典型用法代码示例。如果您正苦于以下问题:Java Response.getStatusCode方法的具体用法?Java Response.getStatusCode怎么用?Java Response.getStatusCode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在io.restassured.response.Response的用法示例。


在下文中一共展示了Response.getStatusCode方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: login

import io.restassured.response.Response; //导入方法依赖的package包/类
public void login() {

        Response response = httpMessageSender.getResponseFrom("/login");

        String authenticity_token =
                        getAuthenticityTokenFromResponse(response);

        // post the login form and get the cookies
        response = loginUserPost(username, password, authenticity_token);

        if(response.getStatusCode()==302) {
            //get the cookies
            loggedInCookieJar = response.getCookies();
        }else{
            System.out.println(response.asString());
            new RuntimeException("Could not login");
        }
    }
 
开发者ID:eviltester,项目名称:tracksrestcasestudy,代码行数:19,代码来源:TracksAppAsApi.java

示例2: createContextsForUser

import io.restassured.response.Response; //导入方法依赖的package包/类
private void createContextsForUser(TestEnv env, String[] contexts,
                                   String aUserName, String aPassword) {
    // create the contexts for the user
    for(String aContext : contexts){

        // each user needs to create their own context
        TracksApi normalTracksUser = new TracksApi( env.getURL(),
                                                    aUserName, aPassword);

        Response response = normalTracksUser.createContext(aContext);

        if(response.getStatusCode()==201 || response.getStatusCode()==409){
            // 201 - Created
            // 409 - Already exists
        }else{
            System.out.println( "Warning: Creating Context " + aContext +
                                " Status Code " + response.getStatusCode());
        }
    }
}
 
开发者ID:eviltester,项目名称:tracksrestcasestudy,代码行数:21,代码来源:SetupTracksTestDataUtilityTest.java

示例3: to

import io.restassured.response.Response; //导入方法依赖的package包/类
@When("^I send an empty body to ([\\w-]+)(/[\\w-]+)$")
public void I_send_an_empty_body_to_service_api(String serviceName, String api) {
    RequestSpecification request = request(serviceName);
    request.header("Content-Type", "application/json");
    request.header("token", "ZVtrRXcpTnYWpsjnIpS3olQFGek84E5Z");
    request.body(new byte[0]);
    Response response = request.post(api);
    statusCode = response.getStatusCode();
}
 
开发者ID:intellead,项目名称:intellead-integration-tests,代码行数:10,代码来源:Steps.java

示例4: id

import io.restassured.response.Response; //导入方法依赖的package包/类
@When("^I send lead with id (\\d+) to ([\\w-]+)(/[\\w-/]+)$")
public void I_send_lead_with_id_to_service_api(int leadId, String serviceName, String api) {
    RequestSpecification request = request(serviceName);
    request.header("Content-Type", "application/json");
    request.header("token", "ZVtrRXcpTnYWpsjnIpS3olQFGek84E5Z");
    request.body(Leads.getLead(leadId).toString());
    Response response = request.post(api);
    statusCode = response.getStatusCode();
}
 
开发者ID:intellead,项目名称:intellead-integration-tests,代码行数:10,代码来源:Steps.java

示例5: createUser

import io.restassured.response.Response; //导入方法依赖的package包/类
public Response createUser(String username, String password){

        Response response= httpMessageSender.getResponseFrom(
                                                    "/signup",
                                                    loggedInCookieJar);

        String authenticity_token =
                            getAuthenticityTokenFromResponse(response);

        // cookies seem to change after signup
        // - if I don't use these then the request fails
        loggedInCookieJar = response.getCookies();

        response =  createUserPost(username, password,
                                    authenticity_token,
                                    loggedInCookieJar);

        if(response.getStatusCode()!=302) {
            //get the cookies
            loggedInCookieJar = response.getCookies();
        }else{
            System.out.println(response.asString());
            new RuntimeException(
                    String.format("Could not create user %s %s",
                                        username, password));
        }

        return response;
    }
 
开发者ID:eviltester,项目名称:tracksrestcasestudy,代码行数:30,代码来源:TracksAppAsApi.java

示例6: TracksResponse

import io.restassured.response.Response; //导入方法依赖的package包/类
public TracksResponse(Response response) {
    this.statusCode = response.getStatusCode();

    this.responseHeaders = new HashMap<>();
    Headers headers = response.getHeaders();
    for(Header header: headers){
        responseHeaders.put(header.getName(), header.getValue());
    }

    this.body = response.body().asString();
}
 
开发者ID:eviltester,项目名称:tracksrestcasestudy,代码行数:12,代码来源:TracksResponse.java

示例7: checkStatusCode

import io.restassured.response.Response; //导入方法依赖的package包/类
/**
 * Отправка запроса и сравнение кода http ответа
 *
 * @param typeOfRequest      тип http запроса
 * @param address            url, на который будет отправлен запрос
 * @param expectedStatusCode ожидаемый http статус код
 * @param paramsTable        список параметров для http запроса
 * @return возвращает true или false в зависимости от ожидаемого и полученного http кодов
 * @throws Exception
 */
public boolean checkStatusCode(String typeOfRequest, String address, int expectedStatusCode, List<RequestParam> paramsTable) throws Exception {
    address = resolveVars(address);
    RequestSender request = createRequestByParamsTable(paramsTable);
    Response response = request.request(Method.valueOf(typeOfRequest), address);
    int statusCode = response.getStatusCode();
    if (statusCode != expectedStatusCode) {
        akitaScenario.write("Получен неверный статус код ответа " + statusCode + ". Ожидаемый статус код " + expectedStatusCode);
    }
    return statusCode == expectedStatusCode;
}
 
开发者ID:alfa-laboratory,项目名称:akita,代码行数:21,代码来源:DefaultApiSteps.java


注:本文中的io.restassured.response.Response.getStatusCode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。