camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alex Soto <alex.s...@envieta.com>
Subject Re: Remove breadcrumbId from Rest Service Response Headers
Date Mon, 15 Jun 2015 12:52:12 GMT
Hello:

I guess it must be the way I am writing my integration test.

When manually testing the service with curl, the header is not preset, as expected. 
When I try to verify it in an integration test, the header is present:


    	ProducerTemplate testProducer = camelContext.createProducerTemplate();
    	testProducer.start();
    	
    	Exchange response = 
    		testProducer.request(
    			"https://localhost:8890/test?throwExceptionOnFailure=false",
    			new Processor() {
					@Override
					public void process(Exchange exchange) throws Exception {
						exchange.getIn().setHeader(Exchange.HTTP_METHOD, "POST");
					}
				}
    		);
    	
        assertNotNull(response);
        assertTrue(response.hasOut());
        
        final Message out = response.getOut();
        assertNotNull(out);
        
        assertEquals("", out.getBody(String.class));

        int code = out.getHeader(Exchange.HTTP_RESPONSE_CODE, Integer.class);
        assertEquals(500, code);
        
        final Map<String, Object> headers = out.getHeaders();
        assertNotNull(headers);

        assertFalse(headers.containsKey(Exchange.BREADCRUMB_ID));



Last assertion is not passing!!!

Best regards,
Alex soto



> On Jun 14, 2015, at 11:44 AM, Claus Ibsen <claus.ibsen@gmail.com> wrote:
> 
> Hi
> 
> You should be able to remove the header. Can you try adding a step
> after the removeHeader, eg
> 
> <removeHeader  headerName="breadcrumbId"/>
> <log message="bla bla"/>
> 
> And see if that works.
> 
> 
> On Wed, Jun 10, 2015 at 5:16 PM, Alex Soto <alex.soto@envieta.com> wrote:
>> Hi there,
>> 
>> Is there a way to remove the “breadcrumbId" header from the Rest Service response?
>> 
>> I am using Camel 2.15.1
>> Here is my Route :
>> 
>> <onException>
>>        <exception>java.lang.Exception</exception>
>>        <redeliveryPolicy maximumRedeliveries="1" />
>>        <handled>
>>                <constant>true</constant>
>>        </handled>
>>        <camel:setHeader headerName="CamelHttpResponseCode">
>>                <constant>500</constant>
>>        </camel:setHeader>
>>        <camel:setBody>
>>                <constant></constant>
>>        </camel:setBody>
>>        <camel:removeHeader headerName="breadcrumbId"/>
>> </onException>
>> 
>> <rest path="/">
>>        <post uri="test">
>>                <to uri="direct:test" />
>>        </post>
>> </rest>
>> 
>> <route>
>>        <from uri="direct:test" />
>>        <throttle
>>                asyncDelayed="false"
>>                callerRunsWhenRejected="false"
>>                rejectExecution="true"
>>                timePeriodMillis="1000">
>>                <constant>10000</constant>
>> 
>> 
>>                <unmarshal ref="myDataFormat"/>
>>                <removeHeader  headerName="breadcrumbId"/>
>>        </throttle>
>> </route>
>> 
>> 
>> Adding the removeHeaders does not seem to cause any effect; I am still getting the
breadcrumbId header in the HTTP response headers.
>> 
>> 
>> Best regards,
>> Alex soto
>> 
>> 
>> 
> 
> 
> 
> -- 
> Claus Ibsen
> -----------------
> Red Hat, Inc.
> Email: cibsen@redhat.com
> Twitter: davsclaus
> Blog: http://davsclaus.com
> Author of Camel in Action: http://www.manning.com/ibsen
> hawtio: http://hawt.io/
> fabric8: http://fabric8.io/


Mime
View raw message