Package org.apache.tuscany.das.rdb

Examples of org.apache.tuscany.das.rdb.ConfigHelper


    /**
     * Simple unit test for ConnectionInfo using DriverManager
     * @throws Exception
     */
    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");
View Full Code Here


    /**
     * Simple unit test for adding a select command
     * @throws Exception
     */
    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());
View Full Code Here

    /**
     * Simple unit test for adding an update command
     * @throws Exception
     */
    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());
View Full Code Here

    /**
     * Simple unit test for adding an insert command
     * @throws Exception
     */
    public void testAddInsertCommand() throws Exception {
        ConfigHelper helper = new ConfigHelper();
        helper.addInsertCommand("insert customer", "insert into customers(ID,NAME) values (?,?)");

        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("insert", cmd.getKind());
        assertEquals("insert customer", cmd.getName());
View Full Code Here

    /**
     * Simple unit test for adding a delete command
     * @throws Exception
     */
    public void testAddDeleteCommand() throws Exception {
        ConfigHelper helper = new ConfigHelper();
        helper.addDeleteCommand("delete customer", "delete from customers 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("delete", cmd.getKind());
        assertEquals("delete customer", cmd.getName());
View Full Code Here

    /**
     * Simple unit test for DataObjectModel
     * @throws Exception
     */
    public void testDataObjectModel() throws Exception {
        ConfigHelper helper = new ConfigHelper();
        helper.setDataObjectModel("org.apache.tuscany/mytypes");

        Config config = helper.getConfig();
        assertEquals("org.apache.tuscany/mytypes", config.getDataObjectModel());

    }
View Full Code Here

    /**
     * Simple unit test for adding a Delete statement to a Table
     * @throws Exception
     */
    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", ConfigUtil.getParameters(widgets.getDelete()));
View Full Code Here

    /**
     * Simple unit test for adding a Create statement to a Table
     * @throws Exception
     */
    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", ConfigUtil.getParameters(widgets.getCreate()));
View Full Code Here

        assertEquals("ID NAME", ConfigUtil.getParameters(widgets.getCreate()));

    }
   
    public void testAddInvalidPrimaryKey() throws Exception {
        ConfigHelper helper = new ConfigHelper();
        try {
            helper.addPrimaryKey("PK");
        } catch (RuntimeException ex) {
            this.assertEquals ("Column PK must be qualified with a table name and optional schema name", ex.getMessage());
        }
    }
View Full Code Here

     */
    public void test0() throws Exception {
        String commandName = "select book by id";
        String commandSQL = "SELECT * FROM BOOK WHERE BOOK_ID =?";
        // Create config programmatically
        ConfigHelper helper = new ConfigHelper();
        helper.addSelectCommand( commandName, commandSQL );
        helper.addPrimaryKey("BOOK.BOOK_ID");
        DAS das = DAS.FACTORY.createDAS(helper.getConfig(), getConnection());

        // Read a book instance
        Command select = das.getCommand("select book by id");
        select.setParameter(1, new Integer(1));
        DataObject root = select.executeQuery();
View Full Code Here

TOP

Related Classes of org.apache.tuscany.das.rdb.ConfigHelper

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.