You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Steve Huston <sh...@riverace.com> on 2016/05/11 16:32:04 UTC

RE: Trouble sending a ByteBuffer to a mock

Closing the loop on this... the issue ended up being that when the Exchange got to the end of the route and went back to the 'from' (which was a cxfrs REST point) that piece complained about the ByteBuffer. In my case the solution ended up being adding another processor after the "end" to set up a Response for REST.

-Steve

> -----Original Message-----
> From: Steve Huston
> Sent: Thursday, April 28, 2016 7:04 PM
> To: 'users@camel.apache.org' <us...@camel.apache.org>
> Subject: Trouble sending a ByteBuffer to a mock
> 
> I am using Camel 2.16.3. I have a route like so:
> 
>        from("direct:sendPing").routeId("rms-send-ping")
>         .process(new Processor() {
>             public void process(Exchange exchange) throws Exception {
>             	Message in = exchange.getIn();
>                 AssetPing p = new AssetPing(in.getHeader("emp", String.class),
> in.getHeader("id", int.class));
>                 exchange.getIn().setBody(p);
>            }
>         })
>         .convertBodyTo(IsmpAssetPingMessage.class)
>         .process(new Processor() {
>         	public void process(Exchange exchange) throws Exception {
>         		IsmpAssetPingMessage emp =
> exchange.getIn().getBody(IsmpAssetPingMessage.class);
>         		emp.setSrcAddress(mrEmpAddress);
>         	}
>         })
>         .convertBodyTo(ByteBuffer.class)
>         .removeHeaders("*")
>         .to(toRoma).id("sendToRoma");
> 
> In a unit test, I adviceWIth it to replace that last "to", as:
> 
> 	context.getRouteDefinition("rms-send-ping").adviceWith(context,
> new AdviceWithRouteBuilder() {
> 	        @Override
> 	        public void configure() throws Exception {
> 	            weaveById("sendToRoma")
> 	            	.replace()
>                     .to("log:unit")
> 	            	.to("mock:pingCheck");
> 	        }
> 
> The intention being to extract the message from the mocked end point and
> run some checks on it.
> When the test runs, I see the output from the woven in "log:unit" then I
> have an error:
> 
> 2016-04-28 18:42:33 ERROR JAXRSUtils:1788 - No message body writer has
> been found for class java.nio.HeapByteBuffer, ContentType: text/plain
> 
> Is mock only allowed to have text message bodies written to it?
> 
> My searching for info related to that error has turned up only issues related
> to CXF and REST and problems marshalling to XML/JSON.
> 
> Thanks,
> -Steve Huston