本文整理汇总了Java中com.jayway.restassured.builder.RequestSpecBuilder.build方法的典型用法代码示例。如果您正苦于以下问题:Java RequestSpecBuilder.build方法的具体用法?Java RequestSpecBuilder.build怎么用?Java RequestSpecBuilder.build使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.jayway.restassured.builder.RequestSpecBuilder
的用法示例。
在下文中一共展示了RequestSpecBuilder.build方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: goPost
import com.jayway.restassured.builder.RequestSpecBuilder; //导入方法依赖的package包/类
public Response goPost(String url,String input)
{
Response resp=null;
try
{
RequestSpecBuilder builder = new RequestSpecBuilder();
builder.setBody(input);
builder.setContentType("application/json; charset=UTF-8");
RequestSpecification requestSpec = builder.build();
resp = given().spec(requestSpec).when().post(url);
}catch(Exception ex)
{
ex.printStackTrace();
}
return resp;
}
示例2: setUp
import com.jayway.restassured.builder.RequestSpecBuilder; //导入方法依赖的package包/类
/**
* Initial Setup
*/
@Before
public void setUp() {
this.activeProfile = RestUtil.getCurrentProfile();
this.conf = ConfigFactory.load("application-" + this.activeProfile);
this.baseURI = conf.getString("server.baseURI");
this.port = conf.getInt("server.port");
this.timeout = conf.getInt("service.api.timeout");
final RequestSpecBuilder build = new RequestSpecBuilder().setBaseUri(baseURI).setPort(port);
rspec = build.build();
RestAssured.config = new RestAssuredConfig().encoderConfig(encoderConfig().defaultContentCharset("UTF-8")
.encodeContentTypeAs("application-json", ContentType.JSON));
}
示例3: abstractSetUp
import com.jayway.restassured.builder.RequestSpecBuilder; //导入方法依赖的package包/类
public static void abstractSetUp() throws Exception {
baseURL = Environment.instance().getBaseURL();
port = Environment.instance().getPort();
certificates = Environment.instance().getCertificates();
final RequestSpecBuilder build = new RequestSpecBuilder().setBaseUri(baseURL).setPort(port);
rspec = build.build();
RestAssured.config().sslConfig(SSLConfig.sslConfig().relaxedHTTPSValidation());
RestAssured.config = new RestAssuredConfig().encoderConfig(encoderConfig().defaultContentCharset("UTF-8"))
.redirect(redirectConfig().followRedirects(false));
}
示例4: requestSpecification
import com.jayway.restassured.builder.RequestSpecBuilder; //导入方法依赖的package包/类
/**
* Returns the default {@link com.jayway.restassured.specification.ResponseSpecification} used when submitting requests.
*
* @param username
* the username used to authenticate the request
* @param password
* the password used to authenticate the request
* @param version
* an Optional containing the request api version to use or empty if the default version should be used.
* @return the default {@link com.jayway.restassured.specification.ResponseSpecification} used when submitting requests.
*/
public static RequestSpecification requestSpecification(String username, String password, Optional<String> version) {
RequestSpecBuilder builder = new RequestSpecBuilder();
String contentType = ContentType.JSON.toString();
if (version.isPresent()) {
contentType = "application/" + version.get() + "+json";
}
builder.addHeader("Accept", "application/json");
builder.addRequestSpecification(given().auth().preemptive().basic(username, password).contentType(contentType));
return builder.build();
}
示例5: patchRequestSpecification
import com.jayway.restassured.builder.RequestSpecBuilder; //导入方法依赖的package包/类
/**
* Returns the PATCH {@link com.jayway.restassured.specification.ResponseSpecification} used when submitting PATCH requests.
*
* @param username
* the username used to authenticate the request
* @param password
* the password used to authenticate the request
* @param version
* an Optional containing the request api version to use or empty if the default version should be used.
* @return the PATCH {@link com.jayway.restassured.specification.ResponseSpecification} used when submitting PATCH requests.
*/
public static RequestSpecification patchRequestSpecification(String username, String password, Optional<String> version) {
RequestSpecBuilder builder = new RequestSpecBuilder();
String contentType = "application/json-patch+json";
if (version.isPresent()) {
contentType = "application/json-patch." + version.get() + "+json";
}
builder.addHeader("Accept", "application/json");
builder.addRequestSpecification(given().auth().preemptive().basic(username, password).contentType(contentType));
return builder.build();
}