Search in sources :

Example 51 with Configuration

use of io.apiman.test.policies.Configuration in project apiman-plugins by apiman.

the class TransformationPolicyTest method keepServerJsonResponseAsJson.

@Test
@Configuration("{\"clientFormat\": \"JSON\", \"serverFormat\": \"JSON\"}")
@BackEndApi(ProduceJsonBackEndApi.class)
public void keepServerJsonResponseAsJson() throws Throwable {
    PolicyTestRequest request = PolicyTestRequest.build(PolicyTestRequestType.GET, "/some/resource");
    PolicyTestResponse response = send(request);
    String expectedResponse = "{\"name\":\"apiman\"}";
    assertEquals("application/json", response.header("Content-Type"));
    assertEquals(String.valueOf(expectedResponse.getBytes("UTF-8").length), response.header("Content-Length"));
    assertEquals(expectedResponse, response.body());
}
Also used : PolicyTestRequest(io.apiman.test.policies.PolicyTestRequest) PolicyTestResponse(io.apiman.test.policies.PolicyTestResponse) ProduceXmlBackEndApi(io.apiman.plugins.transformation_policy.backend.ProduceXmlBackEndApi) ProduceJsonBackEndApi(io.apiman.plugins.transformation_policy.backend.ProduceJsonBackEndApi) ProduceComplexJsonBackEndApi(io.apiman.plugins.transformation_policy.backend.ProduceComplexJsonBackEndApi) BackEndApi(io.apiman.test.policies.BackEndApi) ConsumeJsonBackEndApi(io.apiman.plugins.transformation_policy.backend.ConsumeJsonBackEndApi) ConsumeXmlBackEndApi(io.apiman.plugins.transformation_policy.backend.ConsumeXmlBackEndApi) Configuration(io.apiman.test.policies.Configuration) ApimanPolicyTest(io.apiman.test.policies.ApimanPolicyTest) Test(org.junit.Test)

Aggregations

ApimanPolicyTest (io.apiman.test.policies.ApimanPolicyTest)51 Configuration (io.apiman.test.policies.Configuration)51 Test (org.junit.Test)51 PolicyTestRequest (io.apiman.test.policies.PolicyTestRequest)40 PolicyTestResponse (io.apiman.test.policies.PolicyTestResponse)39 PolicyFailureError (io.apiman.test.policies.PolicyFailureError)24 EchoResponse (io.apiman.test.common.mock.EchoResponse)23 PolicyFailure (io.apiman.gateway.engine.beans.PolicyFailure)19 BackEndApi (io.apiman.test.policies.BackEndApi)15 ConsumeJsonBackEndApi (io.apiman.plugins.transformation_policy.backend.ConsumeJsonBackEndApi)8 ConsumeXmlBackEndApi (io.apiman.plugins.transformation_policy.backend.ConsumeXmlBackEndApi)8 ProduceComplexJsonBackEndApi (io.apiman.plugins.transformation_policy.backend.ProduceComplexJsonBackEndApi)8 ProduceJsonBackEndApi (io.apiman.plugins.transformation_policy.backend.ProduceJsonBackEndApi)8 ProduceXmlBackEndApi (io.apiman.plugins.transformation_policy.backend.ProduceXmlBackEndApi)8 HashSet (java.util.HashSet)8 IPolicyTestBackEndApi (io.apiman.test.policies.IPolicyTestBackEndApi)7 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)4 ByteArrayOutputStream (java.io.ByteArrayOutputStream)4 PrintStream (java.io.PrintStream)4 TimeoutConfigBean (io.apiman.plugins.timeoutpolicy.beans.TimeoutConfigBean)1