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


Java ContentType类代码示例

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


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

示例1: testCRUDOperationsAllTogether

import io.restassured.http.ContentType; //导入依赖的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);
}
 
开发者ID:dserradji,项目名称:reactive-customer-service,代码行数:18,代码来源:CustomerServiceIT.java

示例2: testPropertiesRelationships

import io.restassured.http.ContentType; //导入依赖的package包/类
@Test
public void testPropertiesRelationships() {
    // @formatter:off
    RestAssured
        .given()
        .when()
            .get(snitchURI)
        .then()
            .statusCode(200)
            .contentType(ContentType.JSON)
            .body("componentRelationships[0].component.name", Matchers.is("app-props-detector"))
            .body("componentRelationships[0].component.type", Matchers.is("properties/application"))
            .body("componentRelationships[0].dependencies", Matchers.hasSize(1))
            .body("componentRelationships[0].dependencies[0].component.name", Matchers.is("dependency"))
            .body("componentRelationships[0].dependencies[0].component.type", Matchers.is("properties/dependency"))
            .body("componentRelationships[0].consumers", Matchers.hasSize(1))
            .body("componentRelationships[0].consumers[0].component.name", Matchers.is("consumer"))
            .body("componentRelationships[0].consumers[0].component.type", Matchers.is("properties/consumer"));
    // @formatter:on
}
 
开发者ID:cereebro,项目名称:cereebro,代码行数:21,代码来源:SnitchEndpointConfigurationPropertiesDetectorTest.java

示例3: badSnitchUriShouldYield200AndResolutionError

import io.restassured.http.ContentType; //导入依赖的package包/类
@Test
public void badSnitchUriShouldYield200AndResolutionError() {
    // @formatter:off
    RestAssured
        .given()
            .accept(ContentType.JSON)
        .when()
            .get(systemURI)
        .then()
            .statusCode(200)
            .body("name", Matchers.is("error-system"))
            .body("errors.size()", Matchers.is(1))
            .body("errors[0].snitchUri", Matchers.is("http://cereebro.nope"))
            .body("errors[0].message", Matchers.not(Matchers.isEmptyOrNullString()))
            // cause (Throwable) should not be serialized
            .body("errors[0].cause", Matchers.nullValue());
    // @formatter:on
}
 
开发者ID:cereebro,项目名称:cereebro,代码行数:19,代码来源:CereebroServerErrorApplicationTest.java

示例4: getDataToSignOneDocument

import io.restassured.http.ContentType; //导入依赖的package包/类
@Test
public void getDataToSignOneDocument() throws Exception {

	DSSPrivateKeyEntry dssPrivateKeyEntry = token.getKeys().get(0);

	DataToSignOneDocumentDTO dataToSign = new DataToSignOneDocumentDTO();

	RemoteSignatureParameters parameters = new RemoteSignatureParameters();
	parameters.setSignatureLevel(SignatureLevel.CAdES_BASELINE_B);
	parameters.setSignaturePackaging(SignaturePackaging.ENVELOPING);
	parameters.setDigestAlgorithm(DigestAlgorithm.SHA256);
	parameters.setSigningCertificate(new RemoteCertificate(dssPrivateKeyEntry.getCertificate().getEncoded()));

	BLevelParameters bLevelParams = new BLevelParameters();
	bLevelParams.setSigningDate(new Date());
	parameters.setBLevelParams(bLevelParams);
	dataToSign.setParameters(parameters);

	RemoteDocument toSignDocument = new RemoteDocument();
	toSignDocument.setBytes("Hello".getBytes("UTF-8"));
	dataToSign.setToSignDocument(toSignDocument);

	RestAssured.given(this.spec).accept(ContentType.JSON).contentType(ContentType.JSON).body(dataToSign, ObjectMapperType.JACKSON_2)
			.post("/services/rest/signature/one-document/getDataToSign").then().assertThat().statusCode(equalTo(200));

}
 
开发者ID:esig,项目名称:dss-demonstrations,代码行数:27,代码来源:RestDocumentationApp.java

示例5: validateDoc

import io.restassured.http.ContentType; //导入依赖的package包/类
@Test
public void validateDoc() throws IOException {

	DataToValidateDTO dataToValidateDTO = new DataToValidateDTO();

	File signature = new File("src/test/resources/xades-detached.xml");
	RemoteDocument signedDoc = new RemoteDocument();
	signedDoc.setBytes(toByteArray(signature));
	signedDoc.setMimeType(MimeType.XML);
	signedDoc.setName(signature.getName());
	dataToValidateDTO.setSignedDocument(signedDoc);

	File detached = new File("src/test/resources/sample.xml");
	RemoteDocument originalDoc = new RemoteDocument();
	originalDoc.setBytes(toByteArray(detached));
	originalDoc.setMimeType(MimeType.XML);
	originalDoc.setName(detached.getName());

	dataToValidateDTO.setOriginalDocument(originalDoc);

	RestAssured.given(this.spec).accept(ContentType.JSON).contentType(ContentType.JSON).body(dataToValidateDTO, ObjectMapperType.JACKSON_2)
			.post("/services/rest/validation/validateSignature").then().assertThat().statusCode(equalTo(200));

}
 
开发者ID:esig,项目名称:dss-demonstrations,代码行数:25,代码来源:RestDocumentationApp.java

示例6: using

import io.restassured.http.ContentType; //导入依赖的package包/类
/**
 * @author wasiq.bhamla
 * @since 20-Aug-2017 3:42:25 PM
 * @return instance
 */
public RequestHandler using () {
	final String endPoint = this.setting.getEndPoint ();
	final int port = this.setting.getPort ();
	final ContentType type = this.setting.getContentType ();
	this.request = RestAssured.given ()
		.baseUri (endPoint);
	LOG.info (LINE);
	LOG.info ("Preparing to execute request with following parameters:");
	LOG.info (LINE);
	LOG.info (format ("End-point url: %s", endPoint));
	if (port > 0) {
		LOG.info (format ("End-point port: %d", port));
		this.request = this.request.port (port);
	}
	if (type != null) {
		LOG.info (format ("End-point content-tyoe: %s", type));
		this.request = this.request.contentType (type);
	}
	return this;
}
 
开发者ID:WasiqB,项目名称:coteafs-services,代码行数:26,代码来源:RequestHandler.java

示例7: getRequestSpecification

import io.restassured.http.ContentType; //导入依赖的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();
}
 
开发者ID:kaygee,项目名称:timings-client,代码行数:9,代码来源:TimingsFacade.java

示例8: testWithRestAssured

import io.restassured.http.ContentType; //导入依赖的package包/类
@Test
public void testWithRestAssured() {
 
 Weather weather = new Weather();
 weather.setFlagColor("blue");
 weather.setPostalCode("99425");
 weather.setProduct(Product.ForecastBasic);

 given() // can be ommited when GET only
     .contentType(ContentType.JSON)
        .body(weather)
    .when() // can be ommited when GET only
        .post("http://localhost:8080/weather/general/outlook")
    .then()
        .statusCode(HttpStatus.SC_OK)
        .contentType(ContentType.JSON)
        .assertThat()
            .equals(IncredibleLogic.generateGeneralOutlook());
 
 GeneralOutlook outlook = given() // can be ommited when GET only
         .contentType(ContentType.JSON)
         .body(weather).post("http://localhost:8080/weather/general/outlook").as(GeneralOutlook.class);
 
 assertEquals("Weimar", outlook.getCity());
}
 
开发者ID:jonashackt,项目名称:cxf-spring-cloud-netflix-docker,代码行数:26,代码来源:WeatherBackendApplicationTests.java

示例9: getWeatherInformationPdf_should_return_correct_Pdf

import io.restassured.http.ContentType; //导入依赖的package包/类
@Test
public void getWeatherInformationPdf_should_return_correct_Pdf() throws IOException {

    byte[] pdf = given()
                    .contentType(ContentType.JSON)
                    .pathParam("zip", "99425")
                .when()
                    .get("http://localhost:8080/weather/general/outlook/{zip}")
                .then()
                    .statusCode(HttpStatus.SC_OK).extract().asByteArray();

    String textInPdf = extractPdfText(pdf);
    assertThat(textInPdf, containsString("Weather in your city"));
    assertThat(textInPdf, containsString("Weimar"));
    assertThat(textInPdf, containsString("18.1"));
    assertThat(textInPdf, containsString("Wind Gentle Breeze 3.6 m/s"));
    assertThat(textInPdf, containsString("West-southwest"));
    assertThat(textInPdf, containsString("Cloudiness scattered clouds"));
    assertThat(textInPdf, containsString("Pressure 1018 hpa"));
    assertThat(textInPdf, containsString("Humidity 55 %"));
    assertThat(textInPdf, containsString("Sunrise 23:30"));
    assertThat(textInPdf, containsString("Sunset 13:1"));

}
 
开发者ID:jonashackt,项目名称:cxf-spring-cloud-netflix-docker,代码行数:25,代码来源:WeatherBackendApplicationTests.java

示例10: testPostGroup

import io.restassured.http.ContentType; //导入依赖的package包/类
@Test
public void testPostGroup() {
    Map<String, String> requestBody = new HashMap<>();
    requestBody.put(PARAM_NAME, POST_GROUP_NAME);
    
    given()
        .contentType(ContentType.JSON)
        .body(requestBody)
        .when()
            .post(GROUP_URL)
        .then()
            .statusCode(200)
            .body(PARAM_NAME, equalTo(POST_GROUP_NAME))
            .body(PARAM_ID, is(notNullValue()))
            .body(PARAM_CURRENCY, is(notNullValue()))
            .body(PARAM_UPDATE_TIME, is(notNullValue()))
            .body(PARAM_CREATE_TIME, is(notNullValue()));
}
 
开发者ID:teiler,项目名称:api.teiler.io,代码行数:19,代码来源:GroupEndpointControllerTest.java

示例11: testPostPerson

import io.restassured.http.ContentType; //导入依赖的package包/类
@Test
public void testPostPerson() {
    Map<String, String> requestBody = new HashMap<>();
    requestBody.put(PARAM_NAME, POST_PERSON_NAME);
    
    given()
        .contentType(ContentType.JSON)
        .body(requestBody)
        .when()
            .post(PERSON_URL)
        .then()
            .statusCode(200)
            .body(PARAM_NAME, equalTo(POST_PERSON_NAME))
            .body(PARAM_ID, is(notNullValue()))
            .body(PARAM_ACTIVE, is(true))
            .body(PARAM_UPDATE_TIME, is(notNullValue()))
            .body(PARAM_CREATE_TIME, is(notNullValue()));
}
 
开发者ID:teiler,项目名称:api.teiler.io,代码行数:19,代码来源:PersonEndpointControllerTest.java

示例12: testPutPerson

import io.restassured.http.ContentType; //导入依赖的package包/类
@Test
public void testPutPerson() {
    Map<String, String> requestBody = new HashMap<>();
    requestBody.put(PARAM_NAME, PUT_PERSON_NAME);
    
    given()
        .contentType(ContentType.JSON)
        .body(requestBody)
        .when()
            .put(PERSON_URL + "/" + PUT_PERSON_ID)
        .then()
            .statusCode(200)
            .body(PARAM_ID, equalTo(PUT_PERSON_ID))
            .body(PARAM_NAME, equalTo(PUT_PERSON_NAME))
            .body(PARAM_ACTIVE, is(true))
            .body(PARAM_UPDATE_TIME, is(notNullValue()))
            .body(PARAM_CREATE_TIME, is(notNullValue()));
}
 
开发者ID:teiler,项目名称:api.teiler.io,代码行数:19,代码来源:PersonEndpointControllerTest.java

示例13: test

import io.restassured.http.ContentType; //导入依赖的package包/类
@Test
public void test() {
	Map<String, Object> map = new HashMap<>();
	map.put("mode", 2);
	map.put("id", "23452345234");
	map.put("identity", "11111111");
	map.put("challenge", "s234523452345g");
	map.put("response", "98CF0059D520E39E2016EB3AC70763BB26B665D77CD81378F11E5479E7094ACD");
	map.put("sign", "1232321");

	given()
			.contentType(ContentType.JSON)
			.request()
			.body(JSON.toJSONString(map))
			.post("/test").then().assertThat()
			.body("mode", equalTo("2"),"id",equalTo("23452345234")).time(lessThan(1000L), TimeUnit.SECONDS);

}
 
开发者ID:strictnerd,项目名称:LearningSummary,代码行数:19,代码来源:HTTPAPITest.java

示例14: testPostGet

import io.restassured.http.ContentType; //导入依赖的package包/类
@Test
public void testPostGet() {

    int value = 42;

    CNL_X x = new CNL_X();
    x.value = value;

    String id = given().contentType(ContentType.JSON)
            .body(x)
            .post(baseUrlOfSut + "/api/x")
            .then()
            .statusCode(201)
            .extract().body().path("id").toString();

    String location = baseUrlOfSut + "/api/x/"+  id;

    given().accept(ContentType.JSON)
            .get(location)
            .then()
            .statusCode(200)
            .body("value", CoreMatchers.equalTo(value));
}
 
开发者ID:EMResearch,项目名称:EvoMaster,代码行数:24,代码来源:CNLManualTest.java

示例15: readIdpById

import io.restassured.http.ContentType; //导入依赖的package包/类
public void readIdpById(Long idpId, String expectedResponseJson) {
    String readIdpResponse =
            requestFactory
                    .request()
                    .contentType(ContentType.JSON)
                    .method(Method.GET)
                    .url("/1/identityProvider/" + idpId)
                    .execute()
                    .statusCode(200)
                    .extract().response().asString();

    String[] readIdpGeneratedFields = {
            "$.id",
            "$.createdDate"
    };

    assertJsonEquals(expectedResponseJson, readIdpResponse, readIdpGeneratedFields);
}
 
开发者ID:Atypon-OpenSource,项目名称:wayf-cloud,代码行数:19,代码来源:IdentityProviderTestUtil.java


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