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


Java ResponseSpecBuilder.expectHeader方法代码示例

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


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

示例1: post

import com.jayway.restassured.builder.ResponseSpecBuilder; //导入方法依赖的package包/类
public static Response post(String path, String json, RequestSpecification requestSpecification, Optional<ResponseSpecification> responseSpecification) {
    ResponseSpecBuilder defaultSpecBuilder = new ResponseSpecBuilder();
    defaultSpecBuilder.expectStatusCode(201);
    defaultSpecBuilder.expectHeader("Location", startsWith(path));
    defaultSpecBuilder.expectBody("status", equalTo("OK"));

    Response response = given().spec(requestSpecification).content(json).when().post(path);
    response.then().spec(responseSpecification.orElse(defaultSpecBuilder.build()));
    return response;
}
 
开发者ID:projectomakase,项目名称:omakase,代码行数:11,代码来源:RestIntegrationTests.java

示例2: notFoundResponseSpecification

import com.jayway.restassured.builder.ResponseSpecBuilder; //导入方法依赖的package包/类
/**
 * Returns a {@link com.jayway.restassured.specification.ResponseSpecification} that can be used to validate a 404 NOT FOUND was returned.
 *
 * @return a {@link com.jayway.restassured.specification.ResponseSpecification} that can be used to validate a 404 NOT FOUND was returned.
 */
public static ResponseSpecification notFoundResponseSpecification() {
    ResponseSpecBuilder builder = new ResponseSpecBuilder();
    builder.expectStatusCode(404);
    builder.expectHeader("Warning", "HTTP 404 Not Found");
    builder.expectBody("status", equalTo("ERROR"));
    builder.expectBody("message", equalTo("HTTP 404 Not Found"));
    return builder.build();
}
 
开发者ID:projectomakase,项目名称:omakase,代码行数:14,代码来源:RestIntegrationTests.java

示例3: forbiddenResponseSpecification

import com.jayway.restassured.builder.ResponseSpecBuilder; //导入方法依赖的package包/类
/**
 * Returns a {@link com.jayway.restassured.specification.ResponseSpecification} that can be used to validate a 403 NOT AUTHORIZED was returned.
 *
 * @return a {@link com.jayway.restassured.specification.ResponseSpecification} that can be used to validate a 403 NOT AUTHORIZED was returned.
 */
public static ResponseSpecification forbiddenResponseSpecification() {
    ResponseSpecBuilder builder = new ResponseSpecBuilder();
    builder.expectStatusCode(403);
    builder.expectHeader("Warning", "Not authorized");
    builder.expectBody("status", equalTo("ERROR"));
    builder.expectBody("message", equalTo("Not authorized"));
    return builder.build();
}
 
开发者ID:projectomakase,项目名称:omakase,代码行数:14,代码来源:RestIntegrationTests.java

示例4: badRequestResponseSpecification

import com.jayway.restassured.builder.ResponseSpecBuilder; //导入方法依赖的package包/类
/**
 * Returns a {@link com.jayway.restassured.specification.ResponseSpecification} that can be used to validate a 400 BAD REQUEST was returned.
 *
 * @param message
 *         an Optional containing the expected error message, if empty the message will be validated to make sure it is not null.
 * @return a {@link com.jayway.restassured.specification.ResponseSpecification} that can be used to validate a 400 BAD REQUEST was returned.
 */
public static ResponseSpecification badRequestResponseSpecification(Optional<String> message) {
    ResponseSpecBuilder builder = new ResponseSpecBuilder();
    builder.expectStatusCode(400);
    builder.expectHeader("Warning", notNullValue(String.class));
    builder.expectBody("status", equalTo("ERROR"));
    if (message.isPresent()) {
        builder.expectBody("message", equalTo(message.get()));
    } else {
        builder.expectBody("message", notNullValue(String.class));
    }
    return builder.build();
}
 
开发者ID:projectomakase,项目名称:omakase,代码行数:20,代码来源:RestIntegrationTests.java

示例5: notImplementedResponseSpecification

import com.jayway.restassured.builder.ResponseSpecBuilder; //导入方法依赖的package包/类
/**
 * Returns a {@link com.jayway.restassured.specification.ResponseSpecification} that can be used to validate a 501 NOT IMPLEMENTED was returned.
 *
 * @param message
 *         an Optional containing the expected error message, if empty the message will be validated to make sure it is not null.
 * @return a {@link com.jayway.restassured.specification.ResponseSpecification} that can be used to validate a 501 NOT IMPLEMENTED was returned.
 */
public static ResponseSpecification notImplementedResponseSpecification(Optional<String> message) {
    ResponseSpecBuilder builder = new ResponseSpecBuilder();
    builder.expectStatusCode(501);
    builder.expectHeader("Warning", notNullValue(String.class));
    builder.expectBody("status", equalTo("ERROR"));
    if (message.isPresent()) {
        builder.expectBody("message", equalTo(message.get()));
    } else {
        builder.expectBody("message", notNullValue(String.class));
    }
    return builder.build();
}
 
开发者ID:projectomakase,项目名称:omakase,代码行数:20,代码来源:RestIntegrationTests.java

示例6: assertNoCORSNoOptions

import com.jayway.restassured.builder.ResponseSpecBuilder; //导入方法依赖的package包/类
@Test
@InSequence(1)
public void assertNoCORSNoOptions() throws MalformedURLException {
	ResponseSpecBuilder response = new ResponseSpecBuilder();
	response.expectStatusCode(200);
	response.expectHeader(ACCESS_CONTROL_ALLOW_ORIGIN, isEmptyOrNullString());
	response.expectHeader(ACCESS_CONTROL_ALLOW_CREDENTIALS, isEmptyOrNullString());
	response.expectContentType(ContentType.JSON);
	ResponseSpecification responseSpec = response.build();

	given().contentType(ContentType.JSON).expect().spec(responseSpec).log().ifError().when()
			.get(new URL(context, SearchRestServiceTest.SEARCH_REST_API).toExternalForm());
}
 
开发者ID:searchisko,项目名称:searchisko,代码行数:14,代码来源:CORSWithCredentialsTest.java


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