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


Java RequestSpecBuilder类代码示例

本文整理汇总了Java中com.jayway.restassured.builder.RequestSpecBuilder的典型用法代码示例。如果您正苦于以下问题:Java RequestSpecBuilder类的具体用法?Java RequestSpecBuilder怎么用?Java RequestSpecBuilder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


RequestSpecBuilder类属于com.jayway.restassured.builder包,在下文中一共展示了RequestSpecBuilder类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
 
开发者ID:kattavijay,项目名称:spring-microservices,代码行数:24,代码来源:ServiceCalls.java

示例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));
}
 
开发者ID:ERS-HCL,项目名称:itest-starter,代码行数:20,代码来源:AbstractITest.java

示例3: createBaseSpec

import com.jayway.restassured.builder.RequestSpecBuilder; //导入依赖的package包/类
/**
 * Create base request spec with configurations common to all tests
 * @param username ambari server admin username
 * @param password ambari server admin password
 * @return a base request specification that can be extended & built for tests
 */
public static RequestSpecBuilder createBaseSpec(String username, String password) {
	PreemptiveBasicAuthScheme basicAuth = new PreemptiveBasicAuthScheme();
	basicAuth.setUserName(username);
	basicAuth.setPassword(password);

	return new RequestSpecBuilder().
			setAuth(basicAuth).
			setKeystore("data/certs/BigInsights.jks","passw0rd").
			setContentType(ContentType.JSON).
			addHeader("X-Requested-By", "ambari");
}
 
开发者ID:odpi-attic,项目名称:deploy-cluster,代码行数:18,代码来源:Setup.java

示例4: ServiceTestBase

import com.jayway.restassured.builder.RequestSpecBuilder; //导入依赖的package包/类
public ServiceTestBase(String propertiesFile) {
    logger = LoggerFactory.getLogger(getClass());
    if (configDir == null) {
        String currentEnvironment = System
                .getProperty(BaseConstant.ENVIRONMENT_PROPERTY);
        if (currentEnvironment == null) {
            currentEnvironment = System
                    .getenv(BaseConstant.ENVIRONMENT_PROPERTY);
            if (currentEnvironment == null) {
                currentEnvironment = BaseConstant.ENVIRONMENT_DEFAULT;
            }
        }
        configDir = "/" + currentEnvironment;
    }
    this.propertiesFile = propertiesFile;
    requestSpecBuilder = new RequestSpecBuilder();
    responseSpecBuilder = new ResponseSpecBuilder();

    if (internalProperties == null) {
        // Only need to read from properties file and set http defaults once for all tests
        readFromPropertiesFile();
        setHttpDefaults();
    }
}
 
开发者ID:eing,项目名称:restassured_cli,代码行数:25,代码来源:ServiceTestBase.java

示例5: 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));
}
 
开发者ID:ERS-HCL,项目名称:rest-yaml-test,代码行数:12,代码来源:AbstractITest.java

示例6: simpleMessageTest

import com.jayway.restassured.builder.RequestSpecBuilder; //导入依赖的package包/类
@Test
public void simpleMessageTest(){
    RequestSpecification requestSpec = new RequestSpecBuilder()
            .setBaseUri("http://localhost")
            .setBasePath("/simple-app/slack/message")
            .setPort(8080)
            .setBody("Message from "+this.getClass().getName())
            .setContentType("application/json")
            .setAccept("text/plain")
            .build();
    
    assertEquals("OK",given().spec(requestSpec).when().post().andReturn().body().asString());
}
 
开发者ID:aol,项目名称:micro-server,代码行数:14,代码来源:SlackRunnerTest.java

示例7: setUp

import com.jayway.restassured.builder.RequestSpecBuilder; //导入依赖的package包/类
@Before
public void setUp() {
	RestAssured.port = port;

	RestAssured.requestSpecification = new RequestSpecBuilder().addHeader(
			"X-Broker-Api-Version", "2.4").build();

	bindingRepo.deleteAll();
}
 
开发者ID:krujos,项目名称:data-lifecycle-service-broker,代码行数:10,代码来源:BrokerIntegrationTest.java

示例8: setupRestAssured

import com.jayway.restassured.builder.RequestSpecBuilder; //导入依赖的package包/类
@Before
public void setupRestAssured() {
	RestAssured.port = this.port;
	final RequestSpecification requestSpec = new RequestSpecBuilder().setContentType("application/hal+json").build();
	RestAssured.requestSpecification = requestSpec;
	RestAssured.enableLoggingOfRequestAndResponseIfValidationFails();
}
 
开发者ID:kmbulebu,项目名称:NickNack,代码行数:8,代码来源:_AbstractJettyTest.java

示例9: givenWithContent

import com.jayway.restassured.builder.RequestSpecBuilder; //导入依赖的package包/类
public static RequestSpecification givenWithContent(String authToken) {
    RequestSpecification spec = given().spec(new RequestSpecBuilder()
            .addHeader("Content-Type", "application/json;charset=UTF-8")
            .build());
    if (authToken != null) {
        return spec.header("Authorization", "Bearer " + authToken);
    } else {
        return spec;
    }
}
 
开发者ID:HSLdevcom,项目名称:parkandrideAPI,代码行数:11,代码来源:AbstractIntegrationTest.java

示例10: setUp

import com.jayway.restassured.builder.RequestSpecBuilder; //导入依赖的package包/类
@Before
public void setUp() {
	RestAssured.port = port;
	RestAssured.requestSpecification = new RequestSpecBuilder().addHeader(
			"X-Broker-Api-Version", "2.4").build();
}
 
开发者ID:krujos,项目名称:data-lifecycle-service-broker,代码行数:7,代码来源:CatalogIntegrationTest.java

示例11: setUp

import com.jayway.restassured.builder.RequestSpecBuilder; //导入依赖的package包/类
@Before
public void setUp() {
    this.documentationSpec = new RequestSpecBuilder()
            .addFilter(documentationConfiguration(restDocumentation)).build();
}
 
开发者ID:AchieveMe,项目名称:achieve-carminp-core,代码行数:6,代码来源:IndexTest.java

示例12: startSparkCopyOnNewPort

import com.jayway.restassured.builder.RequestSpecBuilder; //导入依赖的package包/类
private Service startSparkCopyOnNewPort() {
    Service spark = Service.ignite();

    String hostName = config.getProperty(GraknConfigKey.SERVER_HOST_NAME);

    configureSpark(spark, hostName, port(), config.getPath(GraknConfigKey.STATIC_FILES_PATH),
                    64);

    RestAssured.baseURI = "http://" + hostName + ":" + port();

    RestAssured.requestSpecification = new RequestSpecBuilder().build();

    return spark;
}
 
开发者ID:graknlabs,项目名称:grakn,代码行数:15,代码来源:SparkContext.java

示例13: 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();
}
 
开发者ID:projectomakase,项目名称:omakase,代码行数:22,代码来源:RestIntegrationTests.java

示例14: 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();
}
 
开发者ID:projectomakase,项目名称:omakase,代码行数:22,代码来源:RestIntegrationTests.java


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