Package org.apache.tuscany.das.rdb.config

Examples of org.apache.tuscany.das.rdb.config.Config


    public void testAddDeleteStatement() throws Exception {
        ConfigHelper helper = new ConfigHelper();
        Table table = helper.addTable("widgets", "WIDGETS");
        helper.addDeleteStatement(table, "delete from widgets where id = ?", "ID");

        Config cfg = helper.getConfig();
        assertEquals(1, cfg.getTable().size());
        Table widgets = (Table) cfg.getTable().get(0);
        assertEquals("delete from widgets where id = ?", widgets.getDelete().getSql());
        assertEquals("WIDGETS", widgets.getTypeName());
        assertEquals("ID", widgets.getDelete().getParameters());

    }
View Full Code Here


    public void testAddCreateStatement() throws Exception {
        ConfigHelper helper = new ConfigHelper();
        Table table = helper.addTable("widgets", "WIDGETS");
        helper.addCreateStatement(table, "insert into widgets values (?,?)", "ID NAME");

        Config cfg = helper.getConfig();
        assertEquals(1, cfg.getTable().size());
        Table widgets = (Table) cfg.getTable().get(0);
        assertEquals("insert into widgets values (?,?)", widgets.getCreate().getSql());
        assertEquals("WIDGETS", widgets.getTypeName());
        assertEquals("ID NAME", widgets.getCreate().getParameters());

    }
View Full Code Here

    /**
     * Read
     */
    public void testReadUsingConfigInput() throws Exception {
        Config config = ConfigUtil.loadConfig(getConfig("CustomersOrdersConfig.xml"));
        DAS das = DAS.FACTORY.createDAS(config, getConnection());

        Command read = das.getCommand("all customers");
        DataObject root = read.executeQuery();

View Full Code Here

        }
    }

    public void testProvidedConfig() throws Exception {
        // Create config programmatically
        Config config = ConfigFactory.INSTANCE.createConfig();
        ConfigHelper helper = new ConfigHelper(config);
        helper.addPrimaryKey("BOOK.BOOK_ID");
        DAS das = DAS.FACTORY.createDAS(helper.getConfig(), getConnection());

        // Read a book instance
View Full Code Here

        }
    }

    public void testProvidedConfig() throws SQLException  {
        // Create config programmatically
        Config config = ConfigFactory.INSTANCE.createConfig();
        ConfigHelper helper = new ConfigHelper(config);
        helper.addPrimaryKey("BOOK.BOOK_ID");
        DAS das = DAS.FACTORY.createDAS(helper.getConfig(), getConnection());

        // Read a book instance
View Full Code Here

     */
    public void testConnectionInfo() throws Exception {
        ConfigHelper helper = new ConfigHelper();
        helper.addConnectionInfo("jdbc/adatasource");

        Config config = helper.getConfig();
        ConnectionInfo info = config.getConnectionInfo();
        assertEquals(info.getDataSource(), "jdbc/adatasource");
        assertEquals(info.isManagedtx(), true);
    }
View Full Code Here

     */
    public void testConnectionInfo2() throws Exception {
        ConfigHelper helper = new ConfigHelper();
        helper.addConnectionInfo("jdbc/adatasource", false);

        Config config = helper.getConfig();
        ConnectionInfo info = config.getConnectionInfo();
        assertEquals(info.getDataSource(), "jdbc/adatasource");
        assertEquals(info.isManagedtx(), false);
    }
View Full Code Here

     */
    public void testConnectionInfoDriverManager() throws Exception {
        ConfigHelper helper = new ConfigHelper();
        helper.addConnectionInfo("org.apache.derby.jdbc.EmbeddedDriver","jdbc:derby:target/dastest", "user", "password", 600);

        Config config = helper.getConfig();
        ConnectionInfo info = config.getConnectionInfo();
        assertNull(info.getDataSource());
        assertEquals(info.getConnectionProperties().getDriverClass(), "org.apache.derby.jdbc.EmbeddedDriver");
        assertEquals(info.getConnectionProperties().getDatabaseURL(), "jdbc:derby:target/dastest");
        assertEquals(info.getConnectionProperties().getUserName(), "user");
        assertEquals(info.getConnectionProperties().getPassword(), "password");
View Full Code Here

     */
    public void testAddSelectCommand() throws Exception {
        ConfigHelper helper = new ConfigHelper();
        helper.addSelectCommand("get all customers", "select * from customers");

        Config config = helper.getConfig();
        List commands = config.getCommand();
        assertEquals(1, commands.size());
        org.apache.tuscany.das.rdb.config.Command cmd = (org.apache.tuscany.das.rdb.config.Command) commands.get(0);
        assertEquals("select", cmd.getKind());
        assertEquals("get all customers", cmd.getName());
        assertEquals("select * from customers", cmd.getSQL());
View Full Code Here

     */
    public void testAddUpdateCommand() throws Exception {
        ConfigHelper helper = new ConfigHelper();
        helper.addUpdateCommand("update a customer", "update customers set name = ? where id = ?");

        Config config = helper.getConfig();
        List commands = config.getCommand();
        assertEquals(1, commands.size());
        org.apache.tuscany.das.rdb.config.Command cmd = (org.apache.tuscany.das.rdb.config.Command) commands.get(0);
        assertEquals("update", cmd.getKind());
        assertEquals("update a customer", cmd.getName());
        assertEquals("update customers set name = ? where id = ?", cmd.getSQL());
View Full Code Here

TOP

Related Classes of org.apache.tuscany.das.rdb.config.Config

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.