本文整理汇总了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");
}
}
示例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());
}
}
}
示例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();
}
示例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();
}
示例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;
}
示例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();
}
示例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;
}