Package org.apache.tuscany.das.rdb

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


        String statement = "SELECT * FROM CUSTOMER LEFT JOIN ANORDER ON CUSTOMER.ID = ANORDER.CUSTOMER_ID WHERE CUSTOMER.ID = 1";

        // Read some customers and related orders
        // Create relationship config programmatically
        ConfigHelper helper = new ConfigHelper();
        helper.addRelationship("CUSTOMER.ID", "ANORDER.CUSTOMER_ID");
        DAS das = DAS.FACTORY.createDAS(helper.getConfig(), getConnection());
        Command select = das.createCommand(statement);

        DataObject root = select.executeQuery();
        DataObject customer = root.getDataObject("CUSTOMER[1]");

View Full Code Here


    public void test4() throws Exception {

        String statement = "SELECT * FROM BOOK WHERE BOOK.BOOK_ID = ?";

        // Create Table config programmatically
        ConfigHelper helper = new ConfigHelper();
        helper.addTable("BOOK", "Book");
        helper.addPrimaryKey("Book.BOOK_ID");

        DAS das = DAS.FACTORY.createDAS(helper.getConfig(), getConnection());
        Command select = das.createCommand(statement);
        select.setParameter(1, Integer.valueOf(1));

        DataObject root = select.executeQuery();

View Full Code Here

     */
    public void testAddColumnWithPropertyName() throws SQLException {
        String statement = "SELECT * FROM BOOK WHERE BOOK.BOOK_ID = ?";

        // Create Table config programmatically
        ConfigHelper helper = new ConfigHelper();
        Table table = helper.addTable("BOOK", "Book");
        helper.addPrimaryKey("Book.BOOK_ID");
        helper.addColumn(table, "NAME", "bookName");
        DAS das = DAS.FACTORY.createDAS(helper.getConfig(), getConnection());
        Command select = das.createCommand(statement);
        select.setParameter(1, Integer.valueOf(1));

        DataObject root = select.executeQuery();

View Full Code Here

    /**
     * Simple unit test for ConnectionInfo
     * @throws Exception
     */
    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

    /**
     * Simple unit test for ConnectionInfo
     * @throws Exception
     */
    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

    /**
     * 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

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.