Java Code Examples for org.apache.camel.component.sql.SqlComponent#getDataSource()

The following examples show how to use org.apache.camel.component.sql.SqlComponent#getDataSource() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ComponentProxyWithCustomComponentTest.java    From syndesis with Apache License 2.0 5 votes vote down vote up
private void validate(Registry registry) throws Exception {
    final CamelContext context = new DefaultCamelContext(registry);

    try {
        context.setAutoStartup(false);
        context.addRoutes(new RouteBuilder() {
            @Override
            public void configure() throws Exception {
                from("direct:start")
                    .to("my-sql-proxy")
                    .to("mock:result");
            }
        });

        context.start();

        Collection<String> names = context.getComponentNames();

        assertThat(names).contains("my-sql-proxy");
        assertThat(names).contains("sql-my-sql-proxy");

        SqlComponent sqlComponent = context.getComponent("sql-my-sql-proxy", SqlComponent.class);
        DataSource sqlDatasource = sqlComponent.getDataSource();

        assertThat(sqlDatasource).isEqualTo(this.ds);

        Map<String, Endpoint> endpoints = context.getEndpointMap();
        assertThat(endpoints).containsKey("sql-my-sql-proxy://select%20from%20dual");
    } finally {
        context.stop();
    }
}
 
Example 2
Source File: ComponentOptionsTest.java    From syndesis with Apache License 2.0 4 votes vote down vote up
private void validatePojoOption(CamelContext context) throws Exception {
    context.start();

    Collection<String> names = context.getComponentNames();

    assertThat(names).contains("my-sql-proxy");
    assertThat(names).contains("sql-my-sql-proxy");

    SqlComponent sqlComponent = context.getComponent("sql-my-sql-proxy", SqlComponent.class);
    DataSource sqlDatasource = sqlComponent.getDataSource();

    assertThat(sqlDatasource).isEqualTo(this.ds);

    Map<String, Endpoint> endpoints = context.getEndpointMap();
    assertThat(endpoints).containsKey("sql-my-sql-proxy://select%20from%20dual");

    context.stop();
}
 
Example 3
Source File: ComponentOptionsTest.java    From syndesis with Apache License 2.0 4 votes vote down vote up
private static void validateRegistryOption(CamelContext context) throws Exception {
    context.start();

    Collection<String> names = context.getComponentNames();

    assertThat(names).contains("my-sql-proxy");
    assertThat(names).contains("sql");
    assertThat(names).doesNotContain("sql-my-sql-proxy");

    SqlComponent sqlComponent = context.getComponent("sql", SqlComponent.class);
    DataSource sqlDatasource = sqlComponent.getDataSource();

    assertThat(sqlDatasource).isNull();

    Map<String, Endpoint> endpoints = context.getEndpointMap();
    assertThat(endpoints).containsKey("sql://select%20from%20dual?dataSource=%23ds");


    context.stop();
}