Package org.mule.transport.jdbc

Examples of org.mule.transport.jdbc.JdbcConnector


        return dataSource;
    }

    public Connector createConnector() throws Exception
    {
        JdbcConnector connector = new JdbcConnector(muleContext);
        connector.setDataSource(getDataSource());
        connector.setName(CONNECTOR_NAME);
        connector.getDispatcherThreadingProfile().setDoThreading(false);
        connector.setPollingFrequency(5000);

        Map queries = new HashMap();
        queries.put("getTest", SQL_READ);
        queries.put("getTest.ack", SQL_ACK);
        queries.put("writeTest", SQL_WRITE);
        connector.setQueries(queries);

        return connector;
    }
View Full Code Here


        return "jdbc-namespace-config.xml";
    }

    public void testWithDataSource() throws Exception
    {
        JdbcConnector c = (JdbcConnector) muleContext.getRegistry().lookupConnector("jdbcConnector1");
        assertNotNull(c);       

        assertTrue(c.getDataSource() instanceof TestDataSource);
        assertNull(c.getQueries());
        assertEquals(-1, c.getQueryTimeout());
    }
View Full Code Here

        assertEquals(-1, c.getQueryTimeout());
    }

    public void testWithDataSourceViaJndi() throws Exception
    {
        JdbcConnector c = (JdbcConnector) muleContext.getRegistry().lookupConnector("jdbcConnector2");
        assertNotNull(c);
       
        assertTrue(c.getDataSource() instanceof TestDataSource);
        assertNull(c.getQueries());
        assertTrue(c.isConnected());
        assertTrue(c.isStarted());
        assertEquals(3, c.getQueryTimeout());
    }
View Full Code Here

        assertEquals(3, c.getQueryTimeout());
    }
   
    public void testFullyConfigured() throws Exception
    {
        JdbcConnector c = (JdbcConnector) muleContext.getRegistry().lookupConnector("jdbcConnector3");
        assertNotNull(c);
       
        assertTrue(c.getDataSource() instanceof TestDataSource);
       
        assertNotNull(c.getQueries());
        assertEquals(3, c.getQueries().size());

        assertTrue(c.isConnected());
        assertTrue(c.isStarted());
    }
View Full Code Here

    }
   
   
    public void testEndpointQueryOverride() throws Exception
    {
        JdbcConnector c = (JdbcConnector) muleContext.getRegistry().lookupConnector("jdbcConnector3");
        ImmutableEndpoint testJdbcEndpoint = muleContext.getRegistry()
            .lookupEndpointFactory()
            .getInboundEndpoint("testJdbcEndpoint");
       
        //On connector, not overridden
        assertNotNull(c.getQuery(testJdbcEndpoint, "getTest"));
       
        //On connector, overridden on endpoint
        assertNotNull(c.getQuery(testJdbcEndpoint, "getTest2"));
        assertEquals("OVERRIDDEN VALUE", c.getQuery(testJdbcEndpoint, "getTest2"));
       
        //Only on endpoint
        assertNotNull(c.getQuery(testJdbcEndpoint, "getTest3"));

        //Does not exist on either
        assertNull(c.getQuery(testJdbcEndpoint, "getTest4"));
        assertEquals("3", testJdbcEndpoint.getProperty("queryTimeout"));
       
        QueryRunner queryRunner = c.getQueryRunnerFor(testJdbcEndpoint);
        assertEquals(ExtendedQueryRunner.class, queryRunner.getClass());
        assertEquals(3, ((ExtendedQueryRunner) queryRunner).getQueryTimeout());
    }
View Full Code Here

    }

    public void testSqlStatementStrategyFactoryOverride() throws Exception
    {
        // class config
        JdbcConnector c = (JdbcConnector) muleContext.getRegistry().lookupConnector("jdbcConnector4");
        assertNotNull(c.getSqlStatementStrategyFactory());
        assertTrue(c.getSqlStatementStrategyFactory() instanceof TestSqlStatementStrategyFactory);

        // ref config
        c = (JdbcConnector) muleContext.getRegistry().lookupConnector("jdbcConnector5");
        assertNotNull(c.getSqlStatementStrategyFactory());
        assertTrue(c.getSqlStatementStrategyFactory() instanceof TestSqlStatementStrategyFactory);
    }
View Full Code Here

    public void testComplexExpressionJdbcParsing() throws Exception
    {
        muleContext.getExpressionManager().registerEvaluator(new GroovyExpressionEvaluator());

        List parsedParams = new ArrayList();
        JdbcConnector c = new JdbcConnector(muleContext);
        String result = c.parseStatement("#[groovy:payload[0]] - #[groovy:payload[1].toUpperCase()]", parsedParams);

        assertEquals("Wrong number of parsed parameters for a statement", 2, parsedParams.size());
        assertEquals("#[groovy:payload[0]]", parsedParams.get(0));
        assertEquals("#[groovy:payload[1].toUpperCase()]", parsedParams.get(1));
View Full Code Here

        return dataSource;
    }

    public Connector createConnector() throws Exception
    {
        JdbcConnector connector = new JdbcConnector(muleContext);
        connector.setDataSource(getDataSource());
        connector.setName(CONNECTOR_NAME);
        connector.getDispatcherThreadingProfile().setDoThreading(false);
        connector.setPollingFrequency(5000);

        Map queries = new HashMap();
        queries.put("getTest", SQL_READ);
        queries.put("getTest.ack", SQL_ACK);
        queries.put("writeTest", SQL_WRITE);
        connector.setQueries(queries);

        return connector;
    }
View Full Code Here

    public void testComplexExpressionJdbcParsing() throws Exception
    {
        muleContext.getExpressionManager().registerEvaluator(new GroovyExpressionEvaluator());

        List<String> parsedParams = new ArrayList<String>();
        JdbcConnector c = new JdbcConnector(muleContext);
        String result = c.parseStatement("#[groovy:payload[0]] - #[groovy:payload[1].toUpperCase()]", parsedParams);

        assertEquals("Wrong number of parsed parameters for a statement", 2, parsedParams.size());
        assertEquals("#[groovy:payload[0]]", parsedParams.get(0));
        assertEquals("#[groovy:payload[1].toUpperCase()]", parsedParams.get(1));
View Full Code Here

    }

    @Test
    public void testWithDataSource() throws Exception
    {
        JdbcConnector c = (JdbcConnector) muleContext.getRegistry().lookupConnector("jdbcConnector1");
        assertNotNull(c);

        assertTrue(c.getDataSource() instanceof TestDataSource);
        assertNull(c.getQueries());
        assertEquals(-1, c.getQueryTimeout());
    }
View Full Code Here

TOP

Related Classes of org.mule.transport.jdbc.JdbcConnector

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.