io.restassured.config.EncoderConfig Java Examples
The following examples show how to use
io.restassured.config.EncoderConfig.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ArtifactsResourceTest.java From apicurio-registry with Apache License 2.0 | 5 votes |
@Test public void testWsdlArtifact() throws Exception { String artifactId = "testWsdlArtifact"; ArtifactType artifactType = ArtifactType.WSDL; String artifactContent = resourceToString("sample.wsdl"); // Create OpenAPI artifact (from YAML) given() .config(RestAssuredConfig.config().encoderConfig(EncoderConfig.encoderConfig().encodeContentTypeAs(CT_XML, ContentType.TEXT))) .when() .contentType(CT_XML) .header("X-Registry-ArtifactId", artifactId) .header("X-Registry-ArtifactType", artifactType.name()) .body(artifactContent) .post("/artifacts") .then() .statusCode(200) .body("id", equalTo(artifactId)) .body("type", equalTo(artifactType.name())); this.waitForArtifact(artifactId); // Get the artifact content (should be XML) given() .when() .pathParam("artifactId", "testWsdlArtifact") .get("/artifacts/{artifactId}") .then() .statusCode(200) .header("Content-Type", Matchers.containsString(CT_XML)); }
Example #2
Source File: MappingTest.java From quarkus with Apache License 2.0 | 5 votes |
@Test public void testNoopDefaultMappingGet() { RestAssured.given() .config(RestAssured.config.encoderConfig( EncoderConfig.encoderConfig().appendDefaultContentCharsetToContentTypeIfUndefined(false))) .contentType("") .header("ce-id", UUID.randomUUID().toString()) .header("ce-type", "noop") .header("ce-source", "test") .get("/") .then().statusCode(204) .header("ce-id", nullValue()) .header("ce-type", nullValue()) .header("ce-source", nullValue()); }
Example #3
Source File: MappingTest.java From quarkus with Apache License 2.0 | 5 votes |
@Test public void testNoopGet() { RestAssured.given() .config(RestAssured.config.encoderConfig( EncoderConfig.encoderConfig().appendDefaultContentCharsetToContentTypeIfUndefined(false))) .contentType("") .get("/noop") .then().statusCode(204) .header("ce-id", nullValue()) .header("ce-type", nullValue()) .header("ce-source", nullValue()); }
Example #4
Source File: FullApiTest.java From apicurio-registry with Apache License 2.0 | 4 votes |
@Test public void testGlobalRuleApplicationProtobuf() throws Exception { ArtifactType artifactType = ArtifactType.PROTOBUF; String artifactContent = resourceToString("protobuf-invalid-syntax.proto"); // First, create an artifact without the rule installed. Should work. createArtifact("testGlobalRuleApplicationProtobuf/API", artifactType, artifactContent); // Add a global rule Rule rule = new Rule(); rule.setType(RuleType.VALIDITY); rule.setConfig(ValidityLevel.SYNTAX_ONLY.name()); given() .when() .contentType(CT_JSON).body(rule) .post("/rules") .then() .statusCode(204) .body(anything()); // Get the global rule (make sure it was created) TestUtils.retry(() -> { given() .when() .get("/rules/VALIDITY") .then() .statusCode(200) .contentType(ContentType.JSON) .body("type", equalTo("VALIDITY")) .body("config", equalTo("SYNTAX_ONLY")); }); // Try to create an artifact that is not valid - now it should fail. String artifactId = "testGlobalRuleApplicationProtobuf/InvalidAPI"; given() .config(RestAssured.config().encoderConfig(new EncoderConfig().encodeContentTypeAs(CT_PROTO, ContentType.TEXT))) .when() .contentType(CT_PROTO) .header("X-Registry-ArtifactId", artifactId) .header("X-Registry-ArtifactType", artifactType.name()) .body(artifactContent) .post("/artifacts") .then() .statusCode(400) .body("error_code", equalTo(400)) .body("message", equalTo("Syntax violation for Protobuf artifact.")); }
Example #5
Source File: ArtifactsResourceTest.java From apicurio-registry with Apache License 2.0 | 4 votes |
@Test public void testYamlContentType() throws Exception { String artifactId = "testYamlContentType"; ArtifactType artifactType = ArtifactType.OPENAPI; String artifactContent = resourceToString("openapi-empty.yaml"); // Create OpenAPI artifact (from YAML) given() .config(RestAssuredConfig.config().encoderConfig(EncoderConfig.encoderConfig().encodeContentTypeAs(CT_YAML, ContentType.TEXT))) .when() .contentType(CT_YAML) .header("X-Registry-ArtifactId", artifactId) .header("X-Registry-ArtifactType", artifactType.name()) .body(artifactContent) .post("/artifacts") .then() .statusCode(200) .body("id", equalTo(artifactId)) .body("name", equalTo("Empty API")) .body("description", equalTo("An example API design using OpenAPI.")) .body("type", equalTo(artifactType.name())); this.waitForArtifact(artifactId); // Get the artifact content (should be JSON) given() .when() .pathParam("artifactId", "testYamlContentType") .get("/artifacts/{artifactId}") .then() .statusCode(200) .header("Content-Type", Matchers.containsString(CT_JSON)) .body("openapi", equalTo("3.0.2")) .body("info.title", equalTo("Empty API")); }
Example #6
Source File: BaseApiTest.java From ecommerce-order-service with Apache License 2.0 | 4 votes |
protected MockMvcRequestSpecification given() { return RestAssuredMockMvc.given() .config(RestAssuredMockMvcConfig.config().encoderConfig(new EncoderConfig().appendDefaultContentCharsetToContentTypeIfUndefined(false))) .config(RestAssuredMockMvcConfig.config().logConfig(LogConfig.logConfig().enableLoggingOfRequestAndResponseIfValidationFails())); }
Example #7
Source File: BaseApiTest.java From ecommerce-product-service with Apache License 2.0 | 4 votes |
protected MockMvcRequestSpecification given() { return RestAssuredMockMvc.given() .config(RestAssuredMockMvcConfig.config().encoderConfig(new EncoderConfig().appendDefaultContentCharsetToContentTypeIfUndefined(false))) .config(RestAssuredMockMvcConfig.config().logConfig(LogConfig.logConfig().enableLoggingOfRequestAndResponseIfValidationFails())); }
Example #8
Source File: MappingTest.java From quarkus with Apache License 2.0 | 4 votes |
@Test public void testNoopDefaultMapping() { RestAssured.given() .config(RestAssured.config.encoderConfig( EncoderConfig.encoderConfig().appendDefaultContentCharsetToContentTypeIfUndefined(false))) .contentType("") .header("ce-id", UUID.randomUUID().toString()) .header("ce-type", "noop") .header("ce-source", "test") .post("/") .then().statusCode(204) .header("ce-id", nullValue()) .header("ce-type", nullValue()) .header("ce-source", nullValue()); }