Hi,
I would write integration tests with all the magic provided by camel
starters and spring boot test starter, so with this dependencies:

<dependency>
    <groupId>org.apache.camel</groupId>
    <artifactId>camel-mybatis-starter</artifactId>
    <version>${camel.version}</version>
</dependency>
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-test</artifactId>
    <scope>test</scope>
</dependency>
<dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <scope>test</scope>
</dependency>

I can simply write integration tests like:

@RunWith(SpringRunner.class)
@SpringBootTest
public class MyRouteTest {

    @Autowired
    ProducerTemplate template;

    @Test
    public void thisShouldWork() {
        template.sendBody("direct:start", null);
    }
}

zoran


On Fri, Mar 31, 2017 at 1:13 AM, jbailie1992
<jordan.bai...@libertymutual.com> wrote:
> I've got a Spring Boot app that makes use of Camel and Mybatis. I've got the
> following mybatis dependencies in pom.xml:
>
> *pom.xml*
>
>     ....
>     <dependency>
>         <groupId>org.apache.camel</groupId>
>         <artifactId>camel-mybatis</artifactId>
>         <version>${camel.version}</version>
>     </dependency>
>     ....
>     <dependency>
>         <groupId>org.mybatis.spring.boot</groupId>
>         <artifactId>mybatis-spring-boot-starter</artifactId>
>         <version>1.0.1</version>
>     </dependency>
>     ....
>
> I've got the following route:
>
> *MyRoute.java*
>
>     @Component
>     public class MyRoute extends SpringRouteBuilder{
>
>         @Autowired
>         MQConnectionProperties mqConnectionProperties;
>
>         @Override
>         public void configure() throws Exception {
>             from(mqConnectionProperties.getResponseQueue())
>             .to("mybatis:selectLogByPrimaryKey?statementType=SelectOne")
>             .process(new TargetSystemProcessor())
>             .end()
>         }
>     }
>
> and the test for the route:
>
> *MyRouteUnitTest.java*
>
>     @RunWith(SpringJUnit4ClassRunner.class)
>     @ContextConfiguration(classes = {MyRouteTestConfiguration.class})
>     @DirtiesContext(classMode = ClassMode.AFTER_EACH_TEST_METHOD)
>     public class MyRouteUnitTest extends CamelTestSupport{
>
>         @Mock
>         MyBatisComponent mybatis;
>         @Autowired
>         MQConnectionProperties mqProps;
>         @Autowired
>         MyRouteBuilder route;
>
>         @Before
>         public void setup() throws Exception {
>             super.setUp();
>             context.addComponent("mybatis", mybatis);
>         }
>
>         @Test
>         public void test() throws Exception {
>             startCamelContext();
>
>             assertTrue(true);
>
>             stopCamelContext();
>         }
>     }
>
> When I try to start the test without adding mybatis as a component to the
> context, I get this error:
>
>     org.apache.camel.FailedToCreateRouteException: Failed to create route
> My_Route at: >>>
> To[mybatis:selectAuditLogByPrimaryKey?statementType=SelectOne] <<< in route:
> Route(My_Route)[[From[seda:inpu... because of Failed to resolve endpoint:
> mybatis://selectAuditLogByPrimaryKey?statementType=SelectOne due to: Cannot
> auto create component: mybatis
>     ....
>     Caused by: org.apache.camel.ResolveEndpointFailedException: Failed to
> resolve endpoint:
> mybatis://selectAuditLogByPrimaryKey?statementType=SelectOne due to: Cannot
> auto create component: mybatis
>     ....
>     Caused by: java.io.FileNotFoundException: Cannot find resource:
> SqlMapConfig.xml in classpath for URI: SqlMapConfig.xml
>
>
>
> Whenever I add the component to the context as shown i nthe test above, I
> get this error:
>
>     org.apache.camel.FailedToCreateRouteException: Failed to create route
> My_Route at: >>>
> To[mybatis:selectAuditLogByPrimaryKey?statementType=SelectOne] <<< in route:
> Route(My_Route)[[From[seda:inpu... because of Failed to resolve endpoint:
> mybatis://selectAuditLogByPrimaryKey?statementType=SelectOne due to: No
> component found with scheme: mybatis
>
>
> As far as I can tell, I've got the right dependencies i nthe pom file to
> hook all of this together, and mybatis works fine in the source code. For
> unit testing I can work around it by replacing the endpoint, but I can't
> write any integration tests for my route
>
>
>
> --
> View this message in context: 
> http://camel.465427.n5.nabble.com/Camel-No-component-found-with-scheme-mybatis-tp5796762.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Zoran Regvart

Reply via email to