Package org.apache.tuscany.das.rdb

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


     * Simple read followed by a write. Config instance is generated
     * programmatically using the ConfigHelper.
     */
    public void test2() throws Exception {
        // Create config programmatically
        ConfigHelper helper = new ConfigHelper();
        helper.addPrimaryKey("BOOK.BOOK_ID");
        DAS das = DAS.FACTORY.createDAS(helper.getConfig(), getConnection());

        // Read a book instance
        Command select = das.createCommand("SELECT * FROM BOOK WHERE BOOK_ID = 1");
        DataObject root = select.executeQuery();
        DataObject book = root.getDataObject("BOOK[1]");
View Full Code Here


        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, new Integer(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, new Integer(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

            assertEquals("Foreign key properties should not be set when the corresponding relationship has changed", ex.getMessage());
        }
    }
   
    public void testInvalidFKColumn() throws SQLException {
        ConfigHelper helper = new ConfigHelper();
        Relationship r = helper.addRelationship("CUSTOMER.ID", "ANORDER.CUSTOMER_ID_INVALID");
        r.setName("orders");
      

        DAS das = DAS.FACTORY.createDAS(helper.getConfig(), getConnection());
        Command select = das.createCommand("select * from CUSTOMER left join ANORDER "
                + "ON CUSTOMER.ID = ANORDER.CUSTOMER_ID");

        DataObject root = select.executeQuery()
        DataObject cust1 = root.getDataObject("CUSTOMER[1]")
View Full Code Here

        }
    }
   
    //<Config> useGetGeneratedKeys set to TRUE - Customer - flag should be ignored during insert
    public void testInsert3() throws Exception {
        ConfigHelper helper = new ConfigHelper();
        Config config = helper.getConfig();
        config.setGeneratedKeysSupported("true");
     
        DAS das = DAS.FACTORY.createDAS(config, getConnection());
        Command insert = das.createCommand("insert into CUSTOMER (ID, LASTNAME, ADDRESS) values (?, ?, ?)");
        String key = "10";
View Full Code Here

        assertEquals(key, root.get("CUSTOMER[1]/ID").toString());
    }
   
    //<Config> useGetGeneratedKeys set to FALSE - Customer, flag has no effect
    public void testInsert4() throws Exception {
        ConfigHelper helper = new ConfigHelper();
        Config config = helper.getConfig();
        config.setGeneratedKeysSupported("false");
     
        DAS das = DAS.FACTORY.createDAS(config, getConnection());
        Command insert = das.createCommand("insert into CUSTOMER (ID, LASTNAME, ADDRESS) values (?, ?, ?)");
        String key = "10";
View Full Code Here

        assertEquals(key, root.get("CUSTOMER[1]/ID").toString());
    }
   
    //<Config> useGetGeneratedKeys not set - Customer - default TRUE is ignored
    public void testInsert5() throws Exception {
        ConfigHelper helper = new ConfigHelper();
        Config config = helper.getConfig();
     
        DAS das = DAS.FACTORY.createDAS(config, getConnection());
        Command insert = das.createCommand("insert into CUSTOMER (ID, LASTNAME, ADDRESS) values (?, ?, ?)");
        String key = "10";
        insert.setParameter(1, key);
View Full Code Here

     * Read and modify a customer. Provide needed Create/Update/Delete statements programatically
     */
    public void testReadModifyApply() throws Exception {

        // Provide updatecommand programmatically via config
        ConfigHelper helper = new ConfigHelper();
        Table customerTable = helper.addTable("CUSTOMER", "CUSTOMER");
        helper.addUpdateStatement(customerTable, "update CUSTOMER set LASTNAME = ?, ADDRESS = ? "
                + "where ID = ?", "LASTNAME ADDRESS ID");

        DAS das = DAS.FACTORY.createDAS(helper.getConfig(), getConnection());
        // Read customer 1
        Command select = das.createCommand("Select * from CUSTOMER where ID = 1");
        DataObject root = select.executeQuery();
        assertFalse(root.get("CUSTOMER[1]/LASTNAME").equals("Pavick"));

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.