Here’s a single Camel test that shows the issue.
package com.pronoia.camel;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.test.junit4.CamelTestSupport;
import org.junit.Test;
public class JavaTestRouteTest extends CamelTestSupport {
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
@Override
public void configure() throws Exception {
from( "direct://source")
.to( "test:file://data?noop=true" );
}
};
}
@Test
public void testRoute() throws Exception {
template.sendBody( "direct://source", "My Value");
assertMockEndpointsSatisfied();
}
}
> On Mar 10, 2016, at 8:11 AM, Quinn Stevenson <[email protected]>
> wrote:
>
> Forgot to mention I’m using v2.16.2.
>
> Also, here’s the full blueprint and test class
>
> <?xml version="1.0" encoding="UTF-8"?>
> <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0
> <http://www.osgi.org/xmlns/blueprint/v1.0.0>"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance
> <http://www.w3.org/2001/XMLSchema-instance>"
> xmlns:camel="http://camel.apache.org/schema/blueprint
> <http://camel.apache.org/schema/blueprint>"
> xsi:schemaLocation="
> http://www.osgi.org/xmlns/blueprint/v1.0.0
> <http://www.osgi.org/xmlns/blueprint/v1.0.0>
> http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
> <http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd>
> http://camel.apache.org/schema/blueprint
> <http://camel.apache.org/schema/blueprint>
> http://camel.apache.org/schema/blueprint/camel-blueprint.xsd
> <http://camel.apache.org/schema/blueprint/camel-blueprint.xsd>">
>
> <camel:routeContext id="test-route-context"
> xmlns="http://camel.apache.org/schema/blueprint
> <http://camel.apache.org/schema/blueprint>">
> <route id="direct-to-test">
> <from uri="direct://source <direct://source>"/>
> <to uri="test:file://data?noop=true" />
> </route>
> </camel:routeContext>
>
> <camel:camelContext id="blueprint-camel-context"
> xmlns="http://camel.apache.org/schema/blueprint
> <http://camel.apache.org/schema/blueprint>">
> <routeContextRef ref="test-route-context"/>
> </camel:camelContext>
>
> </blueprint>
>
>
> package com.pronoia.camel;
>
> import org.apache.camel.EndpointInject;
> import org.apache.camel.component.mock.MockEndpoint;
> import org.apache.camel.test.blueprint.CamelBlueprintTestSupport;
> import org.junit.Before;
> import org.junit.Test;
>
> public class BlueprintTestRouteTest extends CamelBlueprintTestSupport {
> @EndpointInject( uri = "test:file://data?noop=true")
> MockEndpoint targetEndpoint;
>
> @Override
> protected String getBlueprintDescriptor() {
> return "/OSGI-INF/blueprint/blueprint-test.xml";
> }
>
> @Override
> @Before
> public void setUp() throws Exception {
> super.setUp();
> template.setDefaultEndpointUri( "direct://source <direct://source>");
> }
>
> @Test
> public void testRoute() throws Exception {
> template.sendBody( "direct://source <direct://source>", "My Value");
>
> assertMockEndpointsSatisfied();
> }
>
> }
>
>
>
>> On Mar 10, 2016, at 8:07 AM, Quinn Stevenson <[email protected]
>> <mailto:[email protected]>> wrote:
>>
>> The route is defined in blueprint and I’m running the test using
>> CamelBlueprintTestSupport - does that make a difference?
>>
>>
>>> On Mar 10, 2016, at 8:04 AM, Claus Ibsen <[email protected]
>>> <mailto:[email protected]>> wrote:
>>>
>>> Hi
>>>
>>> Ah that test component is never really used. So the idea is that you
>>> have a file in that directory, that has the value "My Value" which the
>>> test component will load and compare agains the incoming message.
>>>
>>> But yeah seems like the file -> string conversion somehow fails. You
>>> just run this from straing junit ? No karaf or blueprint or osgi
>>> container?
>>>
>>> On Thu, Mar 10, 2016 at 4:01 PM, Quinn Stevenson
>>> <[email protected] <mailto:[email protected]>> wrote:
>>>> I’m trying to get the sample from the documentation for the Test Component
>>>> working ( http://camel.apache.org/test.html
>>>> <http://camel.apache.org/test.html> <http://camel.apache.org/test.html
>>>> <http://camel.apache.org/test.html>> ), but I keep getting a type
>>>> conversion error.
>>>>
>>>> Here’s the route definition:
>>>> <route id="direct-to-test">
>>>> <from uri="direct://source <direct://source>"/>
>>>> <to uri="test:file://data?noop=true" />
>>>> </route>
>>>>
>>>> Here’s the test method:
>>>> @Test
>>>> public void testRoute() throws Exception {
>>>> template.sendBody( "direct://source <direct://source>", "My Value");
>>>>
>>>> assertMockEndpointsSatisfied();
>>>> }
>>>>
>>>> Here’s the error:
>>>> java.lang.AssertionError: test://file://data?noop=true
>>>> <test://file//data?noop=true> There is no type conversion possible from
>>>> java.lang.String to org.apache.camel.component.file.GenericFile
>>>>
>>>> I can see that Camel is finding the file with the test data because I’m
>>>> getting a .camelLock file, but I can’t seem to figure out what I’m doing
>>>> wrong
>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>>
>>> --
>>> Claus Ibsen
>>> -----------------
>>> http://davsclaus.com <http://davsclaus.com/> @davsclaus
>>> Camel in Action 2: https://www.manning.com/ibsen2
>>> <https://www.manning.com/ibsen2>
>>
>