@Test
    @Configuration("{ \"direction\" : \"both\", \"logStatusCode\" : true }")
	public void testLogHeadersHappyFlow() throws PolicyFailureError, Throwable {
        PrintStream out = System.out;
        ByteArrayOutputStream testOutput = new ByteArrayOutputStream();
        System.setOut(new PrintStream(testOutput));
        try {
    		PolicyTestResponse response = send(PolicyTestRequest.build(PolicyTestRequestType.GET, "/some/resource")
    				.header("X-Test-Name", "testGet"));
    		Assert.assertEquals(200, response.code());
    		EchoResponse entity = response.entity(EchoResponse.class);
    		Assert.assertEquals("testGet", entity.getHeaders().get("X-Test-Name"));
            String output = testOutput.toString("UTF-8");
            output = redactDates(output);
            output = normalize(output);
            String expected = "INFO: Logging 1 HTTP Request headers for io.apiman.test.policies.EchoBackEndApi\n" +
                    "Key : X-Test-Name, Value : testGet\n" +
                    "INFO: Status code 200 for io.apiman.test.policies.EchoBackEndApi\n" +
                    "INFO: Logging 4 HTTP Response headers for io.apiman.test.policies.EchoBackEndApi\n" +
                    "Key : Content-Length, Value : 199\n" +
                    "Key : Content-Type, Value : application/json\n" +
                    "Key : Date, Value : XXX\n" +
                    "Key : Server, Value : apiman.policy-test\n" +
                    "";
            Assert.assertEquals(expected, output);
        } finally {
            System.setOut(out);
        }
	}
A simple happy flow test to verify the policy does not blow up in our face.
plugins/log-policy/src/test/java/io/apiman/plugins/log_policy/LogHeadersPolicyTest.java