本文整理汇总了Java中io.restassured.builder.RequestSpecBuilder类的典型用法代码示例。如果您正苦于以下问题:Java RequestSpecBuilder类的具体用法?Java RequestSpecBuilder怎么用?Java RequestSpecBuilder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RequestSpecBuilder类属于io.restassured.builder包,在下文中一共展示了RequestSpecBuilder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testCRUDOperationsAllTogether
import io.restassured.builder.RequestSpecBuilder; //导入依赖的package包/类
@Test
public void testCRUDOperationsAllTogether() {
final String token = queryForToken();
final RequestSpecification reqSpec = new RequestSpecBuilder()
.setContentType(ContentType.JSON)
.setAccept(ContentType.JSON)
.addHeader("Authorization", String.format("Bearer %s", token))
.setRelaxedHTTPSValidation("TLS")
.build();
final String newCustomerUrl = create(reqSpec);
final Customer createdCustomer = read(reqSpec, newCustomerUrl);
update(reqSpec, newCustomerUrl, createdCustomer);
delete(reqSpec, newCustomerUrl);
}
示例2: getRequestSpecification
import io.restassured.builder.RequestSpecBuilder; //导入依赖的package包/类
private RequestSpecification getRequestSpecification(UserTimingRequest userTimingRequest) {
RequestSpecBuilder requestSpecBuilder = new RequestSpecBuilder();
requestSpecBuilder.setConfig(getConfiguration());
requestSpecBuilder.setBody(userTimingRequest);
requestSpecBuilder.setContentType(ContentType.JSON);
getFilters(requestSpecBuilder);
return requestSpecBuilder.build();
}
示例3: should_get_v1_if_not_logged
import io.restassured.builder.RequestSpecBuilder; //导入依赖的package包/类
@Test
public void should_get_v1_if_not_logged() {
// given
final RequestSpecification requestConfiguration = new RequestSpecBuilder()
.setBaseUri(url.toString())
.build();
// when
given()
.spec(requestConfiguration)
.when()
.get("api/v1/products/{productId}/reviews", 0)
.then()
.assertThat()
.statusCode(200)
.body("$.reviews", not(hasKey("rating")));
}
示例4: getFilters
import io.restassured.builder.RequestSpecBuilder; //导入依赖的package包/类
private void getFilters(RequestSpecBuilder requestSpecBuilder) {
if (logErrors) {
requestSpecBuilder.addFilter(new ErrorLoggingFilter());
}
if (logRequests) {
requestSpecBuilder.addFilter(new RequestLoggingFilter());
}
if (logResponses) {
requestSpecBuilder.addFilter(new ResponseLoggingFilter());
}
}
示例5: setUp
import io.restassured.builder.RequestSpecBuilder; //导入依赖的package包/类
@Before
public void setUp() {
// Re-init main channel after clean-up.
channel = channelService.init();
account = accountFactory.register();
requestSpecification = new RequestSpecBuilder()
.setContentType(ContentType.JSON)
.addHeader(HttpHeaders.AUTHORIZATION, "Bearer " + tokenHandler.createToken(account).getToken())
.setBaseUri("http://localhost")
.setBasePath("/api/v1/channels")
.setPort(port)
.build();
}
示例6: setUp
import io.restassured.builder.RequestSpecBuilder; //导入依赖的package包/类
@Before
public void setUp() {
Account account = accountFactory.registerAdmin();
channel = channelRepository.save(new Channel(mainChannelName + "other"));
requestSpecification = new RequestSpecBuilder()
.setContentType(ContentType.JSON)
.addHeader(HttpHeaders.AUTHORIZATION, "Bearer " + tokenHandler.createToken(account).getToken())
.setBaseUri("http://localhost")
.setBasePath("/api/v1/admin/channels")
.setPort(port)
.build();
}
示例7: setUp
import io.restassured.builder.RequestSpecBuilder; //导入依赖的package包/类
@Before
public void setUp() {
account = accountFactory.registerAdmin();
requestSpecification = new RequestSpecBuilder()
.setContentType(ContentType.JSON)
.addHeader(HttpHeaders.AUTHORIZATION, "Bearer " + tokenHandler.createToken(account).getToken())
.setBaseUri("http://localhost")
.setBasePath("/api/v1/admin/accounts")
.setPort(port)
.build();
}
示例8: setUp
import io.restassured.builder.RequestSpecBuilder; //导入依赖的package包/类
@Before
public void setUp() {
requestSpecification = new RequestSpecBuilder()
.setContentType(ContentType.JSON)
.setBaseUri("http://localhost")
.setBasePath("/api/v1/accounts")
.setPort(port)
.build();
// Setup test account.
account = accountFactory.register();
}
示例9: fieldSpec
import io.restassured.builder.RequestSpecBuilder; //导入依赖的package包/类
@Override
public FieldSpec fieldSpec() {
return FieldSpec.builder(ParameterizedTypeName.get(
ClassName.get(Supplier.class),
ClassName.get(RequestSpecBuilder.class)
), name(), PRIVATE).build();
}
示例10: shouldBeAbleToCompile
import io.restassured.builder.RequestSpecBuilder; //导入依赖的package包/类
@Test
public void shouldBeAbleToCompile() throws Exception {
ApiExample.example(
ApiExample.Config.exampleConfig()
.withReqSpecSupplier(
() -> new RequestSpecBuilder().setBaseUri("http://your_host/")
)
)
.rpcApi()
.uid().withUid("1")
.info()
.get(identity()).prettyPeek();
}
示例11: shouldUseDuplicateParams
import io.restassured.builder.RequestSpecBuilder; //导入依赖的package包/类
@Test
public void shouldUseDuplicateParams() {
ApiExample.example(
ApiExample.Config.exampleConfig()
.withReqSpecSupplier(
() -> new RequestSpecBuilder().setBaseUri("http://your_host/")
)
).hardDuplicate().withDuplicatedParam("blah").post(identity()).prettyPeek();
}
示例12: configureRequestSpecBuilder
import io.restassured.builder.RequestSpecBuilder; //导入依赖的package包/类
void configureRequestSpecBuilder(@Observes RestAssuredConfiguration restAssuredConfiguration,
CubeDockerConfiguration cubeDockerConfiguration, RequestSpecBuilder requestSpecBuilder) {
if (restAssuredConfiguration.isBaseUriSet()) {
requestSpecBuilder.setBaseUri(restAssuredConfiguration.getBaseUri());
} else {
requestSpecBuilder.setBaseUri(
restAssuredConfiguration.getSchema() + "://" + cubeDockerConfiguration.getDockerServerIp());
}
if (restAssuredConfiguration.isPortSet()) {
requestSpecBuilder.setPort(SinglePortBindResolver.resolveBindPort(cubeDockerConfiguration,
restAssuredConfiguration.getPort(),
restAssuredConfiguration.getExclusionContainers()));
} else {
requestSpecBuilder.setPort(SinglePortBindResolver.resolveBindPort(cubeDockerConfiguration,
restAssuredConfiguration.getExclusionContainers()));
}
if (restAssuredConfiguration.isBasePathSet()) {
requestSpecBuilder.setBasePath(restAssuredConfiguration.getBasePath());
}
if (restAssuredConfiguration.isAuthenticationSchemeSet()) {
requestSpecBuilder.setAuth(restAssuredConfiguration.getAuthenticationScheme());
}
if (restAssuredConfiguration.isUseRelaxedHttpsValidationSet()) {
if (restAssuredConfiguration.isUseRelaxedHttpsValidationInAllProtocols()) {
requestSpecBuilder.setRelaxedHTTPSValidation();
} else {
requestSpecBuilder.setRelaxedHTTPSValidation(restAssuredConfiguration.getUseRelaxedHttpsValidation());
}
}
}
示例13: lookup
import io.restassured.builder.RequestSpecBuilder; //导入依赖的package包/类
@Override
public Object lookup(ArquillianResource resource, Annotation... qualifiers) {
RequestSpecBuilder requestSpecBuilder = requestSpecBuilderInstance.get();
if (requestSpecBuilder == null) {
throw new IllegalStateException("RequestSpecBuilder was not found.");
}
//Override with elements provided in DockerUrl
final Optional<DockerUrl> dockerUrlAnnotation = getDockerUrlAnnotation(qualifiers);
if (dockerUrlAnnotation.isPresent()) {
final DockerUrl dockerUrl = dockerUrlAnnotation.get();
//We only override in case of setting here as https, in other cases, the original value is used which correctly
// points to docker host.
if ("https".equals(dockerUrl.protocol())) {
requestSpecBuilder.setBaseUri(dockerUrl.protocol() + "://" + getHost());
}
final String containerName = dockerUrl.containerName();
final int exposedPort = dockerUrl.exposedPort();
final int bindPort = getBindingPort(containerName, exposedPort);
if (bindPort > 0) {
return requestSpecBuilder.setPort(bindPort);
} else {
logger.log(Level.WARNING, String.format("There is no container with id %s.", containerName));
}
requestSpecBuilder.setBasePath(dockerUrl.context());
}
return requestSpecBuilder;
}
示例14: configureRequestSpecBuilder
import io.restassured.builder.RequestSpecBuilder; //导入依赖的package包/类
void configureRequestSpecBuilder(@Observes RestAssuredConfiguration restAssuredConfiguration, CubeOpenShiftConfiguration openShiftConfiguration, RequestSpecBuilder requestSpecBuilder) {
if (restAssuredConfiguration.isBaseUriSet()) {
requestSpecBuilder.setBaseUri(restAssuredConfiguration.getBaseUri());
} else {
requestSpecBuilder.setBaseUri(
restAssuredConfiguration.getSchema() + "://" + openShiftConfiguration.getMasterUrl());
}
if (restAssuredConfiguration.isPortSet()) {
requestSpecBuilder.setPort(restAssuredConfiguration.getPort());
} else {
requestSpecBuilder.setPort(openShiftConfiguration.getOpenshiftRouterHttpPort());
}
if (restAssuredConfiguration.isBasePathSet()) {
requestSpecBuilder.setBasePath(restAssuredConfiguration.getBasePath());
}
if (restAssuredConfiguration.isAuthenticationSchemeSet()) {
requestSpecBuilder.setAuth(restAssuredConfiguration.getAuthenticationScheme());
}
if (restAssuredConfiguration.isUseRelaxedHttpsValidationSet()) {
if (restAssuredConfiguration.isUseRelaxedHttpsValidationInAllProtocols()) {
requestSpecBuilder.setRelaxedHTTPSValidation();
} else {
requestSpecBuilder.setRelaxedHTTPSValidation(restAssuredConfiguration.getUseRelaxedHttpsValidation());
}
}
}
示例15: configureRequestSpecBuilder
import io.restassured.builder.RequestSpecBuilder; //导入依赖的package包/类
private RequestSpecBuilder configureRequestSpecBuilder(URL route) {
final RequestSpecBuilder requestSpecBuilder = requestSpecBuilderInstance.get();
if (requestSpecBuilder == null) {
throw new IllegalStateException("RequestSpecBuilder was not found.");
}
requestSpecBuilder.setBaseUri(route.getProtocol() + "://" + route.getHost());
requestSpecBuilder.setPort(route.getPort());
requestSpecBuilder.setBasePath(route.getPath());
awaitRoute(route);
return requestSpecBuilder;
}