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


Java RequestSpecification类代码示例

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


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

示例1: goPost

import com.jayway.restassured.specification.RequestSpecification; //导入依赖的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: setupTest

import com.jayway.restassured.specification.RequestSpecification; //导入依赖的package包/类
private Executable setupTest(YamlTestGroup yamlTestGroup, YamlTest yamlTest, String testcaseName) {

		RequestSpecification rs = given().spec(rspec);

		Executable executable = () -> {
			logger.info("\n\n\n-->start " + testcaseName);
			// Initialize current state to be access globally
			CurrentState.setState(yamlInitGroup, yamlTestGroup, yamlDataGroup, yamlTest);

			try {
				RestRequest.build(rs, yamlTest).request().doAssert();
			} catch (Throwable e) {
				e.printStackTrace();
				throw e;
			}

			logger.info("-->end " + testcaseName +"\n\n\n");
		};

		return executable;
	}
 
开发者ID:ERS-HCL,项目名称:rest-yaml-test,代码行数:22,代码来源:MainTest.java

示例3: searchRequest

import com.jayway.restassured.specification.RequestSpecification; //导入依赖的package包/类
public RequestSpecification searchRequest(String nodes, String nest, boolean getItems, String query, String filter,
	String order)
{
	RequestSpecification request = successfulRequest();
	request.queryParam("nodes", nodes);
	request.queryParam("getitems", getItems);

	if( nest != null )
	{
		request.queryParam("nest", nest);
	}
	if( query != null )
	{
		request.param("q", query);
	}
	if( filter != null )
	{
		request = request.queryParam("filter", filter);
	}
	if( order != null )
	{
		request = request.queryParam("order", order);
	}
	return request;
}
 
开发者ID:equella,项目名称:Equella,代码行数:26,代码来源:FacetRequests.java

示例4: cleanupDelete

import com.jayway.restassured.specification.RequestSpecification; //导入依赖的package包/类
public void cleanupDelete(ID id)
{
	Collection<Integer> acceptableCleanupDeletes = new HashSet<Integer>();
	acceptableCleanupDeletes.add(204);
	acceptableCleanupDeletes.add(404);
	RequestSpecification deleteRequest = deleteRequest(false).expect()
		.statusCode(Matchers.<Integer> isIn(acceptableCleanupDeletes)).with();
	try
	{
		delete(deleteRequest, id);
	}
	catch( AssertionError assertion )
	{
		throw new AssertionError("Error cleaning up after " + getResolvedPath(), assertion);
	}
}
 
开发者ID:equella,项目名称:Equella,代码行数:17,代码来源:AbstractCleanupRequests.java

示例5: searchRequest

import com.jayway.restassured.specification.RequestSpecification; //导入依赖的package包/类
public RequestSpecification searchRequest(String query, String filter, String order, String length)
{
	RequestSpecification request = successfulRequest().param("q", query);
	if( filter != null )
	{
		request = request.queryParam("filter", filter);
	}
	if( order != null )
	{
		request = request.queryParam("order", order);
	}
	if( length != null )
	{
		request = request.queryParam("length", length);
	}
	return request;
}
 
开发者ID:equella,项目名称:Equella,代码行数:18,代码来源:TaskRequests.java

示例6: restrictions

import com.jayway.restassured.specification.RequestSpecification; //导入依赖的package包/类
@Test
public void restrictions() throws IOException, DateParseException
{
	String stagingUrl = staging.create();

	// put a file to the folder1 content url
	final File file = new File(getPathFromUrl(Attachments.get("avatar.png")));

	Response response = staging.putFile(stagingUrl, AVATAR_PATH, file);
	assertEquals(response.getHeader("ETag"), AVATAR_PNG_ETAG);

	RequestSpecification notModified = staging.notModified();
	notModified.header("If-None-Match", AVATAR_PNG_ETAG);
	staging.get(notModified, stagingUrl, AVATAR_PATH);
	response = staging.head(stagingUrl, AVATAR_PATH);
	Date date = DateUtil.parseDate(response.header("Last-Modified"));

	notModified = staging.notModified();
	notModified.header("If-Modified-Since", DateUtil.formatDate(date));
	staging.get(notModified, stagingUrl, AVATAR_PATH);
}
 
开发者ID:equella,项目名称:Equella,代码行数:22,代码来源:StagingApiTest.java

示例7: restApi

import com.jayway.restassured.specification.RequestSpecification; //导入依赖的package包/类
public static RequestSpecification restApi() {
    String keyStorePath = TestHelper.class.getResource("/ssl/keystore").getPath();
    String keyStorePassword = "alterrae";
    KeyStore keyStore = getKeyStore(keyStorePath, keyStorePassword);
    return given()
            .baseUri("https://api.alterrae.com")
            .config(newConfig()
                    .httpClient(httpClientConfig()
                            .setParam("javax.net.ssl.trustStore", keyStorePath)
                            .setParam("javax.net.ssl.trustStorePassword", keyStorePassword)
                            .setParam("javax.net.ssl.keyStore", keyStorePath)
                            .setParam("javax.net.ssl.keyStorePassword", keyStorePassword)
                    )
                    .sslConfig(sslConfig()
                            .keystore(keyStorePath, keyStorePassword)
                            .trustStore(keyStore)
                    )
            );
}
 
开发者ID:mbarberot,项目名称:alterrae-backend,代码行数:20,代码来源:TestHelper.java

示例8: scenarioExecution

import com.jayway.restassured.specification.RequestSpecification; //导入依赖的package包/类
private Response scenarioExecution(HttpScenarioStepBinary binaryScenario, String baseUrl) {
	RequestSpecification specification = expect().
			statusCode(binaryScenario._expectedHttpStatusCode).
			body(binaryScenario._expectedJsonBodyMatcher).
			when().
			given().
			multiPart(binaryScenario._filePartName, "", binaryScenario._requestBody, binaryScenario._requestBodyContentType).
			headers(binaryScenario._headers).
			queryParameters(binaryScenario._parameters);
	
	if (binaryScenario._httpMethod.equals(HttpMethod.POST.toString())) { 
		return specification.post(baseUrl + binaryScenario._partialRestURL);
	} else if (binaryScenario._httpMethod.equals(HttpMethod.PUT.toString())) {
		return specification.put(baseUrl + binaryScenario._partialRestURL);
	} else {
		throw new UnsupportedOperationException("Binary only works with POST and PUT");
	}
}
 
开发者ID:bioko,项目名称:http-test,代码行数:19,代码来源:ScenarioRunner.java

示例9: addLast

import com.jayway.restassured.specification.RequestSpecification; //导入依赖的package包/类
public static Queue addLast(int expectStatusCode, int qID, int... songIDs) throws IOException {
    final RequestSpecification req = given();
    final ResponseSpecification res;
    final Response r;
    
    res = req.then();
    res.expect().statusCode(expectStatusCode);
    res.expect().contentType(ContentType.JSON);
    
    r = res.put( //
            RESTTestConfig.getInstance().getFullURL("/queue/{qID}/last?{songIDs}"), //
            qID, //
            Arrays.stream(songIDs).mapToObj(id -> "songID=" + id).collect(Collectors.joining("&")));
    
    return expectStatusCode == 200 ? toQueue(r.getBody().asString()) : null;
}
 
开发者ID:eviljoe,项目名称:evilmusic,代码行数:17,代码来源:QueueRESTCalls.java

示例10: updateEQ

import com.jayway.restassured.specification.RequestSpecification; //导入依赖的package包/类
public static Equalizer updateEQ(Equalizer eq, int expectStatusCode) throws IOException {
    final RequestSpecification req = given();
    final ResponseSpecification res;
    final Response r;
    
    req.body(eq);
    req.contentType(ContentType.JSON);
    
    res = req.then();
    res.expect().statusCode(expectStatusCode);
    res.expect().contentType(ContentType.JSON);
    
    r = res.put(RESTTestConfig.getInstance().getFullURL("/eq/{id}"), eq.getID());
    
    return expectStatusCode == 200 ? toEQ(r.getBody().asString()) : null;
}
 
开发者ID:eviljoe,项目名称:evilmusic,代码行数:17,代码来源:EqualizerRESTCalls.java

示例11: addLast

import com.jayway.restassured.specification.RequestSpecification; //导入依赖的package包/类
public static Playlist addLast(int expectStatusCode, int pID, int... songIDs) throws IOException {
    final RequestSpecification req = given();
    final ResponseSpecification res;
    final Response r;
    
    res = req.then();
    res.expect().statusCode(expectStatusCode);
    res.expect().contentType(ContentType.JSON);
    
    r = res.put( //
            RESTTestConfig.getInstance().getFullURL("/playlists/{pID}/last?{songIDs}"), //
            pID, //
            Arrays.stream(songIDs).mapToObj(id -> "songID=" + id).collect(Collectors.joining("&")));
    
    return expectStatusCode == 200 ? toPlaylist(r.getBody().asString()) : null;
}
 
开发者ID:eviljoe,项目名称:evilmusic,代码行数:17,代码来源:PlaylistRESTCalls.java

示例12: getDetails

import com.jayway.restassured.specification.RequestSpecification; //导入依赖的package包/类
/**
 * Return the details of a preparation at a given (optional) step.
 *
 * @param preparationId the wanted preparation id.
 * @param wantedStepId the optional wanted step id.
 * @return the details of a preparation at a given (optional) step.
 */
public PreparationMessage getDetails(String preparationId, String wantedStepId) {
    final RequestSpecification specs = given();

    if (StringUtils.isNotBlank(wantedStepId)) {
        specs.queryParam("stepId", wantedStepId);
    }
    final Response response = specs.when().get("/preparations/{id}/details", preparationId);

    if (response.getStatusCode() != 200) {
        throw new MockTDPException(response);
    }

    try {
        return mapper.readerFor(PreparationMessage.class).readValue(response.asString());
    } catch (IOException e) {
        throw new TDPException(UNABLE_TO_READ_CONTENT);
    }

}
 
开发者ID:Talend,项目名称:data-prep,代码行数:27,代码来源:PreparationClientTest.java

示例13: createPreparationFromDataset

import com.jayway.restassured.specification.RequestSpecification; //导入依赖的package包/类
/**
 * Create an empty preparation from a dataset.
 *
 * @param dataSetId the dataset id to create the preparation from.
 * @param name the preparation name.
 * @param folderId where to create the preparation.
 * @return the preparation id.
 * @throws IOException sh*t happens.
 */
public String createPreparationFromDataset(final String dataSetId, final String name, final String folderId)
        throws IOException {

    RequestSpecification request = given() //
            .contentType(JSON) //
            .body("{ \"name\": \"" + name + "\", \"dataSetId\": \"" + dataSetId + "\"}");

    if (folderId != null) {
        request = request.queryParam("folder", folderId);
    }

    final Response response = request //
            .when() //
            .expect().statusCode(200).log().ifError() //
            .post("/api/preparations");

    assertThat(response.getStatusCode(), is(200));

    final String preparationId = response.asString();
    assertThat(preparationId, notNullValue());
    assertThat(preparationId, not(""));

    return preparationId;
}
 
开发者ID:Talend,项目名称:data-prep,代码行数:34,代码来源:APIClientTest.java

示例14: testCompleteGetParameters

import com.jayway.restassured.specification.RequestSpecification; //导入依赖的package包/类
@Test
public void testCompleteGetParameters() {

  Map<String, String> queryParameters = getCompleteStringQueryParameters();

  RequestSpecification requestSpecification = given().contentType(POST_JSON_CONTENT_TYPE);
  for (Entry<String, String> paramEntry : queryParameters.entrySet()) {
    requestSpecification.parameter(paramEntry.getKey(), paramEntry.getValue());
  }

  requestSpecification.expect().statusCode(Status.OK.getStatusCode())
    .when().get(GROUP_QUERY_URL);

  verify(mockQuery).groupName(MockProvider.EXAMPLE_GROUP_NAME);
  verify(mockQuery).groupNameLike("%" + MockProvider.EXAMPLE_GROUP_NAME + "%");
  verify(mockQuery).groupType(MockProvider.EXAMPLE_GROUP_TYPE);
  verify(mockQuery).groupMember(MockProvider.EXAMPLE_USER_ID);
  verify(mockQuery).memberOfTenant(MockProvider.EXAMPLE_TENANT_ID);

  verify(mockQuery).list();

}
 
开发者ID:camunda,项目名称:camunda-bpm-platform,代码行数:23,代码来源:GroupRestServiceQueryTest.java

示例15: testCompleteGetParameters

import com.jayway.restassured.specification.RequestSpecification; //导入依赖的package包/类
@Test
public void testCompleteGetParameters() {

  List<Authorization> mockAuthorizations = MockProvider.createMockGlobalAuthorizations();
  AuthorizationQuery mockQuery = setUpMockQuery(mockAuthorizations);

  Map<String, String> queryParameters = getCompleteStringQueryParameters();

  RequestSpecification requestSpecification = given().contentType(POST_JSON_CONTENT_TYPE);
  for (Entry<String, String> paramEntry : queryParameters.entrySet()) {
    requestSpecification.parameter(paramEntry.getKey(), paramEntry.getValue());
  }

  requestSpecification.expect().statusCode(Status.OK.getStatusCode())
    .when().get(SERVICE_PATH);

  verify(mockQuery).authorizationId(MockProvider.EXAMPLE_AUTHORIZATION_ID);
  verify(mockQuery).authorizationType(MockProvider.EXAMPLE_AUTHORIZATION_TYPE);
  verify(mockQuery).userIdIn(new String[]{MockProvider.EXAMPLE_USER_ID, MockProvider.EXAMPLE_USER_ID2});
  verify(mockQuery).groupIdIn(new String[]{MockProvider.EXAMPLE_GROUP_ID, MockProvider.EXAMPLE_GROUP_ID2});
  verify(mockQuery).resourceType(MockProvider.EXAMPLE_RESOURCE_TYPE_ID);
  verify(mockQuery).resourceId(MockProvider.EXAMPLE_RESOURCE_ID);

  verify(mockQuery).list();

}
 
开发者ID:camunda,项目名称:camunda-bpm-platform,代码行数:27,代码来源:AuthorizationRestServiceQueryTest.java


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